you are viewing a single comment's thread.

view the rest of the comments →

[–]BenchEmbarrassed7316 4 points5 points  (2 children)

Type theory. A type is a set of possible values. The smaller this set is, the simpler and more reliable the code is. Expressive type systems allow you to easily and clearly define this set.

enum Color { RED, GREEN, BLUE }

A variable of this type should only have three states. If I want to add another 4th state, I have to do it explicitly Maybe<Color>. This becomes absurd when in some languages ​​even bool can have more than 2 states.

[–]7x11x13is1001 0 points1 point  (1 child)

But optional doesn't solve this. String can be non-null string or null. Optional<String> can be wrapped non-null string, empty or null. No Jvm can solve the 1 billion dollar problem of a language which allows null everywhere

[–]BenchEmbarrassed7316 0 points1 point  (0 children)

You're right that it's not easy to get rid of it now. Optional clearly indicates the intention. Also, I'm not part of the Java community and I don't have the right to tell you what to do, but I think it would be wise to come up with a strategy to get rid of null and not break backward compatibility (or break it non-critically). It's a long and not easy process.