Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, it’s not orthogonal. In Java, all reference types are implicitly optional. The explicit Optional type is only intended as a stop-gap in situations where the implicit version is especially error-prone. But in general it doesn’t make sense to have both the implicit and explicit solution, in particular when the explicit Optionals simultaneously also have the implicit optionality on top.

It’s exactly the presence of the implicit optionality that makes Optional nonviable as a general-purpose optionality mechanism (in addition to its performance implications).



If you use the implicit optional type then you have no way to express 'not optional'. If you use the explicit optional then you can express optional/not-optional but you're stuck with a potential 3rd state. One of these problems can be fixed by convention (don't use null, ever) and the other has no fix.

(unless you go down the path of annotations)




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

Search: