r/java • • Jun 27 '16

Null pointer exceptions hell

http://dobegin.com/npe-hell/
0 Upvotes

18 comments sorted by

View all comments

5

u/Luolong Jun 27 '16

Also Ceylon language has a fairly unique approach to null safety: http://ceylon-lang.org/documentation/1.2/introduction/#typesafe_null_and_flow_sensitive_typing

2

u/QshelTier Jun 28 '16

It’s not unique, Kotlin does that, too. See link from /u/thatsIch below.

1

u/Luolong Jun 29 '16

Well. Syntax wise the Kotlin approach does seem to have a similar flavor, but the internals of the null safety in Ceylon seem to be completely different.

From what I understand (and feel free to fix my misunderstanding if I am wrong), Kotlin achieves null safety by special casing nullable types in the type system and performing special static analyses for nullability.

Ceylon on the other hand uses same type algebra it uses for the rest of the type system to determine type of a value. Nullable references are nothing special to type checker - they are simply union types of Null|T and all the same rules apply as to any other union types.

1

u/QshelTier Jun 30 '16

Yes, the implementation is different but on the surface it looks the same, what with smart casts after null checks and what not…