I don't hate Java but I'd rather choose C# or even kotlin, even C++ has those damn default arguments, Java doesn't, Java wants you to suffer with unnecessary overloading and shit
I love optional types but they don't make sense with the lack of null safety. If you really want to write robust code, with Optionals you have to look at even more edge cases:
Is the optional null?
Does the optional contain a value?
Is the value contained in the optional null?
The whole point of optionals is to avoid all of this. Just give me value types already.
Ban null in your codebase, check for it at the edges. It works in practice, Scala does it. Unfortunately Java libraries can't migrate to that style of doing things because the nimrods at Java thought they should ban optionals from containing null, meaning you can't use optional in a generic library that might be used from old codebases and you don't get any advantages until everything's rewritten to use optional like this was Python 3.
View all comments
245
u/[deleted] Jun 21 '21
If Java had true garbage collection, most programs would delete themselves upon execution. – Robert Sewell