logoalt Hacker News

adrian_b • today at 6:37 PM • 1 reply • view on HN

Null and zero are synonymous, but null is preferable when used as an adjective and zero is preferable when used as a noun.

There are 2 words for the same concept because "null" comes from Latin, while "zero" comes from Sanskrit through Arabic.

Etymologically, "null" means "not even one" (by being a diminutive form of "not one").

The use of "null" in some programming languages to mean things like "undefined", "not applicable" or "nothing" is incorrect. For those the right choice is NIL, as in LISP (NIL means nothing).

While LISP had made the right choice by using NIL, it made later the mistake of calling NULL the predicate that tests if something is NIL. That predicate should have been called something like "is_nil".

When C.A.R. Hoare had introduced the word "null", he applied "null" to references, i.e. to pointers, not to the things pointed by those pointers. So a "null" pointer, whose value is zero, points to NIL, i.e. to nothing, and this is an alternative to devising an encoding for the things that are pointed to, where a special value is reserved to encode NIL (like the Not-a-Number values of floating-point numbers).


Replies

ninalanyon • today at 8:01 PM

I presume you didn't make all that up, but which authorities did you consult and under which circumstances would which audience immediately agree with you on all points?

In British English nil means zero as in a nil-nil draw in football. In this case it is effectively an ordinal number and it means none, not nothing.