3 ms·
Seeing all this discussion reinforces the idea that no new programming language should have this "every type implicitly contains null" thing
by nextaccountic 3y ago
Seeing all this discussion reinforces the idea that no new programming language should have this "every type implicitly contains null" thing
- eru 3y agoYes, sum types and generics solve this nicely. It's a shame Java was designed before they had generics, so the core of the language can't take advantage of them.
- ruszki 3y agoIt’s still possible to do something like TypeScript, where everything is like generics in Java. But Java try to be consistent, while TypeScript purposefully not. There are a ton of features in TypeScript which are awesome, but it breaks in some rare cases. Java won’t allow that.
- ruszki 3y agoAlso no new languages should default to mutable variables, fields, and types, when the language supposed to be in the same field as Java, eg. large enterprise services. And for both problems, they should be consistent, because now they are mess (there is an example in the article regarding nulls in collections, and for mutability a great example is collect(Collectors.toList()) vs toList()).
- tialaramex 3y agoTony Hoare calls it (null) his Billion Dollar Mistake. https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/ https://www.infoq.com/presentations/Null-References-The-Bill...
- fud101 3y agoWe use None in Python - is that similar?
- nextaccountic 3y agoYes, and no dynamically typed language can do much better than this, because in those your value of type X can always be another type (and you need to defensively check if you want to catch errors)