I ran across this article recently:

http://peat.org/2013/12/07/null-considered-harmful/

The author points out that attempts to dereference null values are a frequent source of errors in modern programming languages, and proposes that languages should not support null references. He draws a parallel to memory management — languages that require manual memory management (C, for example) have more memory-related issues than languages that incorporate memory management. 

It’s a compelling idea. Most of the Java runtime issues I’ve seen over the years have been NullPointerExceptions; a language that prevented the occurrence of these exceptions would not have allowed these errors to occur. 

Of course, there’s a gap between theory and practice, and I’d have to see how such a language would work for real-world development. If a 100% prohibition is impractical, perhaps a “nullable” modifier could be introduced in order to flag fields that can potentially have null values; variables without this flag would be prohibited from holding null values. 

Advertisements