3 ms·
> This will cause a lot of indirect access It causes strictly less indirect access if you store it as part of the string struct, as C++, Go, or Rust do.
by masklinn 4y ago
> This will cause a lot of indirect access
It causes strictly less indirect access if you store it as part of the string struct, as C++, Go, or Rust do.
- vlovich123 4y agoBut makes passing around the type challenging to do efficiently. I agree it was probably the wrong choice in the end, but given the information available at the time, it’s not clear to me there was enough data / reasonable way to predict what the consequences would be and which approach would be better. It’s more clear today but that’s because we’ve had 20 years of data of various experiments and ideas like small string optimizations on modern architectures that didn’t exist 40+ years ago.
- masklinn 4y ago> But makes passing around the type challenging to do efficiently. Doesn't seem to be much of an issue in practice, even when strings are 3 words wide (as is the case for C++ and Rust because their strings are mutable[0], Go's strings are not so only 2 words). Especially as it's a good tradeoff for safety, reliability, gains you performances elsewhere, and allows slicing. [0] Rust String specifically, &str is immutable and 2 words, C++17 added string_view but I don't know how large it is, or whether it's used much if at all