6 ms·
I don't see a valid use case for null. It's just a easy-to-make billion dollar mistake. Null exist because people are being lazy, and don't want to think refer
by namelosw 7y ago
I don't see a valid use case for null. It's just a easy-to-make billion dollar mistake.
Null exist because people are being lazy, and don't want to think reference type T to be T | null. Instead, in most of the cases they ignore null unless they know it will crash.
It seems to be every use case for null could be handled well in Haskell, which means null is not mandatory in language design. Everywhere using null can be replaced with Maybe or concrete union type like Int | NaN just fine.
- nerdponx 7y agoNo. The problem is conflating "logical null" (the absence of data) with "technical null" (a pointer to nothing). Logical null is often essential for expressing business logic in code. Technical null is (as far as I can tell) a C implementation detail that probably never should exist in a higher-level language. The Haskell equivalent of logical null is Nothing. There is no technical null because there is no need to represent that one specific implementation detail in Haskell. As for using NaN to represent logical null instead of a special reserved value, that has a lot of ergonomic problems. Anyone who has used Python for data analysis can attest.