Hacker News new | past | comments | ask | show | jobs | submit login

Seeing all this discussion reinforces the idea that no new programming language should have this "every type implicitly contains null" thing



Tony Hoare calls it (null) his Billion Dollar Mistake.

https://www.infoq.com/presentations/Null-References-The-Bill...


We use None in Python - is that similar?


Yes, 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)


Also 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()).


Yes, 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.


It’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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: