Null-Safety vs Maybe/Option - A Thorough Comparison

submited by
Style Pass
2021-06-22 00:00:07

An in-depth and practical comparison between Null-safety and the Maybe/Option type, both used to discard the infamous null pointer error.

For an introduction to Maybe / Option I recommend: F#: The Option type. You can also search the net for "haskell maybe" or "f# option".

I call it my billion-dollar mistake. It was the invention of the null reference in 1965. ... This has led to innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years. ...

Besides showing the reason for the null pointer error, this article also aims to demonstrate how the null pointer error can be eliminated.

This approach is mostly used in some functional programming languages. But it can as well be used in non-functional languages.

In this chapter we'll look at some source code examples of common use cases involving 'the absence of a value'. We will compare the code written in the three following languages representing the three approaches mentioned in the previous chapter:

Leave a Comment