Hacker News new | ask | show | jobs
by Diggsey 1750 days ago
It's clearly not the "only sensible one" given that no other language works the way Go does here.

In C++ this is UB, which is bad, but in keeping with the rest of the language.

In Rust, the compiler will not allow you to do any operation that would re-allocate the backing store whilst there are outstanding references into it.

In most other languages (eg. Java, C#, python, etc.), you can't get a pointer/reference to an array index, only a pointer/reference to the item at that index at the time you looked.

Go's decision here is especially weird given that this same thing is seemingly prevented for maps (why the inconsistency?).

Given the three goals of memory-safety, "simplicity" and performance, it's true there are not many other options Go could have chosen, but personally I think Go's interpretation of "simplicity" is incredibly warped: it's a kind of superficial simplicity that leads to programs that are much more complicated to reason about.