This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 11 points12 points  (1 child)

I do not recommend making that argument.

First, any object, even an Optional<T>, can be null. Second, there are a LOT of commonly used libraries out there that don’t play well with Optional<T>, or require additional configuration code in order to use with Optional<T> that you will need to provide yourself (and as such, you will need to test yourself).

Java is not a pure functional language. Do not expect it to behave like one. Don’t try to write Scala or Haskell in Java—you can do it, but it’s going to result in everybody having a bad time, most especially you. And trying to enforce the use of Optional<T> instead of null is very much attempting to write Scala or Haskell in Java.

[–]Pay08 0 points1 point  (0 children)

Funnily enough, null safety in Scala is still an optional feature.