4 ms·
significant mastery ahead! This is a success story and a teaching document. .. have to point to this : "Now that I’ve seen Go strings… holy hell, Python 3 un
by mistrial9 7y ago
significant mastery ahead!
This is a success story and a teaching document.
.. have to point to this : "Now that I’ve seen Go strings… holy hell, Python 3 unicode strings sure look like a nasty botch in retrospect. " (!)
- AnimalMuppet 7y agoI wish he had been a bit more explicit there, TBH. What's better about Go strings?
- Izkata 7y agoSkimming over a post from a quick search [0], it looks like Go strictly uses byte strings and manipulates them with various keywords and functions. No encoding/decoding between byte strings (and picking an encoding) and unicode strings like in python. [0] https://blog.golang.org/strings https://blog.golang.org/strings
- rauhl 7y agoI think that’s not really the right way to put it. Rather, go offers UTF-8 strings and byte slices, with a simple typecast in either way, with various keywords and functions to DTRT to each. One still must worry about encoding & decoding if one doesn’t want UTF-8, and one must worry about invalid UTF-8 in a byte slice when casting, but in general Go does what one would expect with a minimum of fuss.
- 0xjnml 7y agoGo strings are just a sequence of bytes in no particular encoding, i.e they can contain arbitrary data. Converting strings to byte slices and vice versa works always without ever changing a single bit.
- pk2200 7y agoHe wrote about this more detail in an earlier blog post (about halfway down the page). http://esr.ibiblio.org/?p=8161 http://esr.ibiblio.org/?p=8161