| ▲ | 9rx 5 hours ago | |||||||||||||||||||||||||
> Nil exists in C and is widely considered to be a massive mistake in the language. You're almost there, but it is wildly considered to be massive mistake in context of arrays. C has weird array semantics that are confusing and hard to get right, even for seasoned developers. That is where NULL comes to bite people time and time again. Go did not inherit C's arrays. Neither did Javascript. They go out of their way to avoid what C did. In Go, you can come close to the same semantics if you use the unsafe package, but take note the name. Yes, they still have nil, but the scope is tightly constrained and while it is technically possible to misuse, you have to try pretty hard to do so. There are many other things that are more likely to end up being misused. Those would be the more massive mistakes. > But Go could have been better. Obviously. Every language ever created can be better. | ||||||||||||||||||||||||||
| ▲ | stouset 5 hours ago | parent [-] | |||||||||||||||||||||||||
> You're almost there, but it is wildly considered to be massive mistake in context of arrays. From Tony Hoare: "I call it my billion-dollar mistake. It was the invention of the null reference in 1965. At that time, I was designing the first comprehensive type system for references in an object-oriented language (ALGOL W). My goal was to ensure that all use of references should be absolutely safe, with checking performed automatically by the compiler. But I couldn't resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years." Odd that he wouldn't mention the word "array" anywhere in that quote. > Yes, they still have nil, but the scope is tightly constrained and while it is technically possible to misuse, you have to try pretty hard to do so. Like by not remembering to check if a pointer is nil? Or actually comparing one typed nil to a different typed nil? > Obviously. Every language ever created can be better. Only one of us is arguing that reimplementing C’s mistakes is actually a good thing. | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||