I'm quickly becoming a fan of SQL. Not just because of the revered database query language's utility (in all its incompatible dialects, natch), but because it reflects a well-thought-out design that makes sense beyond the usefulness of the language down to the philosophy of computer languages in general. Let's take, for example, IS NULL.
In C++, to check if something is NULL, you can compare it to NULL. Or zero. Or false. And, according to the language, these are all actual values: if "int a=0;" then "a==false", "a==0" and "a==NULL". I don't like this.
See, the null set, ΓΈ, is not just a set with nothing in it. It is, quite literally, the set with no thing in it. Comparisons between something that "IS NULL" and something that has a value shouldn't even make sense. Thus, in MySQL, Oracle et al, you have to use "WHERE a IS NULL" instead of "WHERE a = 0" or "WHERE a = 'false'".
"NULL IS NULL" is true.
"0 IS NULL" is false.
"NULL = 0" is also false.
I like SQL.
Tuesday, October 24, 2006
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment