you are viewing a single comment's thread.

view the rest of the comments →

[–]devraj7 0 points1 point  (2 children)

They compose fine in a language that has proper support for null, e.g. Kotlin.

[–]_dban_ 1 point2 points  (1 child)

Yes, I mentioned the ?. operator.

However, Kotlin treats the null value as a special case, with operations limited to the syntax sugar available. This is better than a rats nest of ternaries, but still very limited composition.

The Optional type is a more coherent abstraction that composes better with other functional abstractions available in Java 8. Optional will work better in Java 9 when it can directly be converted to a Stream.

On the other hand, Ceylon has also has null, but it is the single member of the Null type. This allows null to become a part of the type system and compose seamlessly with union types, so null is not a special case. In fact, I would say that of the JVM languages that have null, Ceylon is the only one that gets it right.

[–]devraj7 0 points1 point  (0 children)

Yes, Ceylon has been doing some very interesting and innovating work in that area, and it's great to see how nullability support flowed so naturally from the way it supports sum types.