| ▲ | stouset 5 hours ago | ||||||||||||||||
> 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. | |||||||||||||||||
| ▲ | 9rx 5 hours ago | parent [-] | ||||||||||||||||
> Like by not remembering to check if a pointer is nil? Rule of thumb is to not introduce values that aren't valid. Equally, don't put in -1 for an age value, even if the language allows you to. You might later forget to validate that the age value is valid. Yes, mistakes are possible, but these types of mistakes are pretty rare. There is some value in eliminating the possibility of those mistakes, sure, but we cannot pretend that it comes cost-free. There is good reason why almost nobody uses Rocq. > Or actually comparing one typed nil to a different typed nil? This is something that is likely to confuse, but not a facet of nil. It is related to interfaces. Let's not flail around like one of those wacky blow up things at the used auto lot. | |||||||||||||||||
| |||||||||||||||||