Excellent question.
Try not to think of null
as a specific value but rather "nothing to see here." The documentation defines null
as
The null
keyword is a literal that represents a null reference, one that does not refer to any object.
With that in mind, the fact that null
is not an object means that the classical laws of thought don't exactly apply to it (or, at least, don't apply to it in the same way that it would apply to an actual object).
That being said, the fact that 10 >= null
and 10 <= null
are both false
isn't, strictly speaking, a contradiction - after all, null
is quite literally nothing. If you said 10 >= (some actual thing)
and 10 <= (some actual thing)
were both false, then clearly that would be contradictory, but you can't exactly have a contradiction in the classical sense without some actual object. Aristotle's definition of the law from Metaphysics is as follows:
It is impossible that the same thing can at the same time both belong and not belong to the same object and in the same respect, and all other specifications that might be made, let them be added to meet local objections...
So, we have a bit of a "loophole" here in a sense. At least as Aristotle formulated the Law of Non-Contradiction, it was referring specifically to objects. There are, of course, multiple interpretations of the Law of Non-Contradiction at this point.
Now, turning to the case of 10 + null
. We could say that this is the same thing as null + 10
if it's easier. In a sense, then, what should happen at this point - should null
"swallow up" the 10, or should we just say "10 + (nothing at all) really should just equal 10"? Truthfully, I don't have a very convincing answer here from a logical perspective beyond saying "well, that's kind of a design choice." I suspect that the language designers wanted to distinguish 10 + null
from 10 + 0
, but I don't have documentation to prove that. (Indeed, it would be slightly strange if they were the same; after all, 0 is an actual value that can be constructed from the natural numbers, but null
is "no value whatever").