News for hackers. Stuff that matters.
Re:Can I get some reasons to use Java instead of Kotlin? by stickfigure on Monday May 17, 2021 @01:57PM (#27186177)
Java went the route of Optional<?> instead of nullable types. You still end up with some nullability issues working with old libraries (and even the std lib, like Map.get()) but by and large you can force a "never use null" policy on Java codebases and NPEs become very rare.

I fairly strongly prefer Optional over nullable types. Especially how it works seamlessly with streams.

Re:Can I get some reasons to use Java instead of Kotlin? by Quekid5 on Monday May 17, 2021 @03:27PM (#27187293)
It's actually kind of instructive to consider how Scala mostly solved the NPE issue by simply having Option available and discouraging use of null.

There are still issues at the API boundaries with Java or JS code, but that's about it. Outside of that, NPEs are usually in more niche places to do with initialization order and that sort of stuff.

Of course if you're inventing a totally new language you probably want to just avoid the possibility of null outright.

Re:Can I get some reasons to use Java instead of Kotlin? by ByteWelder on Tuesday May 18, 2021 @04:21AM (#27192329)
The "never use null" policy doesn't work across your third party dependencies, unless those dependencies coincidentally use the same policy as you.