Re:Java 8’s new Optional type doesn't solve anything
by Manishearth on Monday October 26, 2015 @11:56AM
(#10452232)
The difference is that Optional itself can be null, and in Java everything can be null.
Re:Java 8’s new Optional type doesn't solve anything
by peeters on Monday October 26, 2015 @12:08PM
(#10452304)
It can be, and it's annoying, but that's still a step forward. It's trivial for a good static checker to treat all Optional references as if they were annotated with your favorite @Nonnull annotation.
Re:Java 8’s new Optional type doesn't solve anything
by krisdol on Monday October 26, 2015 @05:59PM
(#10454790)
But in Java you'd never use a library that calls System.exit when it reaches an unexpected null
Re:Java 8’s new Optional type doesn't solve anything
by Manishearth on Monday October 26, 2015 @07:38PM
(#10455257)
See my other comment: https://news.ycombinator.com/item?id=10452408
In Rust you'd rarely write a library that panics on unexpected nulls.
(Also, panic != abort, yada yada)
If you use Optional.get() without Optional.isPresent(), how is that any different? It's not as nice as pattern decomposition, but it's still fundamentally the same, and on top of that, transform functions are provided so that most of the time you can do null-safe operations.