How will you handle null references if you are designing a new language?
▻https://hackernoon.com/how-will-you-handle-null-references-if-you-are-designing-a-new-language-
Kotlin’s idiomatic approach to Null SafetyComputer scientist Tony Hoare Said:I call it my billion-dollar mistake. It was the invention of the null reference in 1965The nullable objects introduces a fundamental problem with type system. For e.g If you declare a object as String, it doesn’t guarantee that the value is real String or null.We normally skip null checks based on our assumptions in control flow of code. But when we are wrong, the code crashes with Null Pointer Exception. Java 8 introduced Optionals to deal with Nullable objects. But it has some flawsWhy Java Optionals is not a greatway to handle nulls?Wrapping and unwrapping objects into Optional class makes code verbose. Also since it was introduced only in JDK8, you still need to deal with null values returned from older JDK (...)
#tony-hoare #kotlin #null-references #null-safety #computer-science