While ranting about how much I hate about null values in Java(and other langauges) on Haskell IRC channel, someone in the channel reminded me that we have
undefined in Haskell, which is actually similar to null values in some sense.
The difference between Haskell’s
undefined and null values in other languages is that Haskell’s
undefined is unobservable. This means you can’t test for a value being
undefined or not in Haskell, but you can test for null values in Java and other languages.
This means you can’t rely on some values being
undefined or not. This makes it only useful for 1) unreachable code and 2) filling some parts in the code for now just to make it compile and later complete that parts(and I’m using
undefined for this purpose very often).
This is what makes Haskell’s
undefined a useful feature, while null values is clearly Considered Harmful™.