The Billion-Dollar Mistake

In 1965, Tony Hoare was designing the type system for ALGOL W, an early and influential programming language. He wanted a type system that would guarantee, by the compiler’s checking, that every use of a reference was safe. Then he made one exception. He allowed any reference to hold a special value, null, meaning “no object.” He did it, by his own later account, “simply because it was so easy to implement.” It was a small, convenient decision in a language most programmers have never used, and it spread through the languages that followed it for the next half century.

Decades later, at QCon San Francisco in August 2009, Hoare stood up to call that decision his “billion-dollar mistake.” The recorded talk, “Null References: The Billion Dollar Mistake,” is a remarkable thing: one of the most distinguished computer scientists of the twentieth century publicly apologizing for a feature he invented. His estimate of a billion dollars in damage, he allowed, was if anything conservative, given how many crashes, vulnerabilities, and lost hours of debugging null references have caused across all the languages that copied the idea.

The reason null was so damaging is that it quietly defeated the very safety Hoare had been trying to build. A reference whose type promised it pointed at an object could, at runtime, point at nothing instead. Every use of such a reference therefore carried a hidden obligation to check for null first, and any single forgotten check produced a null-pointer dereference: a crash, an exception, or worse. The convenience of one implementer in 1965 turned into an open-ended tax on every programmer who came after.

The anecdote endures because of who told it and how. It is rare for a foundational mistake in computing to come with a confession from its author, named, dated, and recorded. That candor is part of why the phrase “the billion-dollar mistake” became shorthand in the industry for the whole problem of nullability, invoked far more often than the ALGOL W reference manual that started it.

The story also has a constructive ending, which is why it is told so often by language designers. The alternative Hoare’s talk pointed toward, making the possibility of absence explicit in the type rather than implicit in every reference, is exactly the option-type approach that Haskell, ML, Rust, and Swift adopted. The billion-dollar mistake became the standard cautionary tale that justifies designing null out of a language from the start.