Tony Hoare's Null References: The Billion Dollar Mistake
infoq.com
infoq.com
There's no standard, widely-accepted way to unambiguously serialize and deserialize nulls within querystrings. JavaScript is perhaps one of the more frequent client languages for that, but Python and many other server-side languages are affected too. Could we do something about that?
I liked the look of the proposal at https://github.com/whatwg/url/issues/469 that was working towards this.
In short, it provides the ability for "?a&b=" to represent the variable "a" containing null and "b" containing an empty-string.
The next level is constructing types in a way that you can avoid such low level details of whether the pointer is valid.
In other words, encode the state in the type instead of a value that you need to test against every time you want to use it.
Consider a non-blocking read. What the caller does depends on whether the read returns a value or "no data available". If the type of the object returned depends on whether there was a value, you just replaced a null check with a type check.
You can avoid that check with a caller with multiple return points and have the callee pick between them. Exceptions are the most obvious way to do that. However, exceptions happen immediately, while type/null checks can be done later.
There aren't many languages which support multiple continuations and SQL isn't one of them.
Just because your programming language supports null pointers, doesn't mean you need to use them. You can avoid the pitfalls discussed by Tony Hoare by simply refraining to use them. You will still need to handle null pointers coming into your code from outside, like from libraries, but your own code does not need to generate them.