What Is Null? (2010)
Non nullability is probably one of the most important concepts I&#x27;ve learned. People can talk your ear off about macros or about borrow checking or whatever cool feature is in their favorite languages. But non nullability isn&#x27;t a feature as much as the removal of a terrible one: types being automatically unifiable with null.<p>What does that mean? Well basically that every single (reference) type in most languages comes with an implicit &quot;and null&quot;. String in Java? More like &quot;String and null&quot;. Car object? Actually it&#x27;s &quot;Car and null&quot;.<p>Why is this a bad thing? Well null is a very specific type with a very specific meaning, but because it&#x27;s automatically included with every type, people end up using it for a bunch of situations where a different type or value would work. Let&#x27;s take a simple parser. A naive implementation, upon reaching the end of the string, might just return null. After all, nothing has been found. But that&#x27;s not a null value, that&#x27;s an EndOfString value! The moment you pass that value out of the context of the function, you need to remember that null means EndOfString. Or maybe the string you&#x27;re passing in is a null value in the first place. It&#x27;d be tempting to return out null, right? Except you&#x27;ve now lost information on whether the string itself was null, or if something happened in the parse function that caused it to return null.<p>That isn&#x27;t to say null is wholly evil. There&#x27;s certainly uses for null. But it&#x27;s often way better to contain its use with Option or Maybe, essentially wrappers that detail &quot;hey, this value could be null&quot;. These wrappers are <i></i>not<i></i> unifiable with regular values, which forces you to think about where values can and cannot be null.<p>I totally understand if language designers want to omit features that they deem unnecessary or overcomplicated. I get it if you want a language sans generics or sans macros. But I don&#x27;t understand keeping a feature that has caused far too much pain and encouraged far too many bad practices.