3 ms·
The fact that null != null (and NaN != NaN) is, to me, a helpful reminder that the mathematical model behind SQL is not as simple and elegant as newcomers would
by hathawsh 7y ago
The fact that null != null (and NaN != NaN) is, to me, a helpful reminder that the mathematical model behind SQL is not as simple and elegant as newcomers would like it to be. It reminds me of the classic "proof" that 1 = 2, based on simple algebra:
https://www.math.toronto.edu/mathnet/falseProofs/first1eq2.html https://www.math.toronto.edu/mathnet/falseProofs/first1eq2.h...
If even basic algebra has a trap like that, then all of us need to be prepared for similar traps.
- shezi 7y agoThere is not a trap in algebra that is shown in that proof: there is a mistake in that proof. They do something that is not allowed, even if it's not obvious what that was at first glance. I don't think one can compare mistakes with thoughtful and powerful modelling.
- hathawsh 7y agoBy trap I mean a surprising exception to the common rules. Most high school graduates learn algebra, yet they rarely learn how to avoid accidental division by zero. It's a surprising exception. "null != null" is also a surprising exception to the common rules. I honestly wouldn't expect most developers to know it until their code breaks because of it. That doesn't mean the surprising rule is wrong, it just means people have to learn it. Once they learn it, they may try to find the deeper model where the rule is no longer a surprise but rather an important feature.