2
kiki
251d

In Go, one symbol is called a rune. A string is a string, but when I try to manipulate it, it turns into an array of bytes, not an array of runes. I then have to deal with this crap.
Can you suggest some mental gymnastics to justify this behavior to people who use real programming languages?

Comments
  • 1
    I don't know Go, but

    - arrays are evenly spaced in low level languages for O(1) indexing
    - strings are Unicode in modern languages
    - strings are more compact than an array of their code points, because they're understood to consist overwhelmingly of low values, and also represent most of a program's memory usage.
  • 1
    Rust doesn't represent strings as character arrays either.
  • 5
    Go is definitely overhyped. But JS doesn‘t treat utf8 strings correctly, either. To be fair, most languages don‘t do it right. The only language that I know which handles strings correctly is Swift.

    For example most languages will report a simple "🤡" string as length 4. and when you try to access the first character you get something wrong, not the original emoji.

    Handling strings correctly is a very, very complex and complicated topic. I heard a talk about that. One but not the only problem is that utf8 characters (or what we intuitively think of as characters) can have variable size/length.
    Most languages are too old or too lazy (Go?) to make it right.
  • 2
    @Lensflare Elixir also handles graphemes, and Rust has a very popular crate for this purpose. The problem is that unlike codepoints, with graphemes you can't take the first grapheme from a byte stream without lookahead, because any valid grapheme can also be the first half of a combination using an infix ZWJ, and indeed the most common way to denote some Arabic letters uses an infix ZWJ.
  • 0
    Go, another language that came too late and is just not better than it's parents.

    I've heard / read that a go executable is just your source compiled in a go interpreter binary. Not even efi, not native.

    We should've stopped by python. Python had a huge performsnce recently
Add Comment