3 ms·
The difference is that Optional itself can be null, and in Java everything can be null.
by Manishearth 11y ago
The difference is that Optional itself can be null, and in Java everything can be null.
- peeters 11y agoIt 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.
- krisdol 11y agoBut in Java you'd never use a library that calls System.exit when it reaches an unexpected null
- Manishearth 11y agoSee my other comment: https://news.ycombinator.com/item?id=10452408 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)