Tony Hoare Called Null His Billion-Dollar Mistake. He Had Turned Down the Fix in 1965.

Tony Hoare in 2011, smiling in wire-rimmed glasses, beside a dark panel with his name and a code motif about null references.


In 1965, Tony Hoare added the null reference to ALGOL W, a programming language in the ALGOL (“algorithmic language”) family. His best-known explanation fits in one line: he did it “simply because it was so easy to implement.”

That line hides a contradiction. Hoare was designing what he later called “the first comprehensive type system for references in an object oriented language.” His goal, in his own words, was that every use of a reference “should be absolutely safe, with checking performed automatically by the compiler.”

Null was the exception. A reference could now point to nothing, and nothing in the language forced a program to check before following it.

Forty-four years later, in March 2009, Hoare spoke at QCon London, a software conference, in a track titled “Historically bad ideas.” In the abstract of his talk he wrote: “I call it my billion-dollar mistake.”

The abstract also named the fix. Newer languages such as Spec#, a Microsoft Research extension of C#, let programmers declare references that can never be null. “This is the solution,” Hoare wrote, “which I rejected in 1965.”

Hoare, who died in March 2026 at the age of 92, is better known for Quicksort and for Hoare logic, a formal system for proving that programs are correct. He received the Turing Award in 1980. Yet in a track about historically bad ideas, the bad idea he talked about was his own.

Every subscript, checked every time

The exception stands out because of what Hoare had built before. At Elliott Brothers, the British computer maker he joined as a programmer in 1960, he led work on an early compiler for ALGOL 60. In that compiler, he recalled in his Turing Award lecture, “every occurrence of every subscript of every subscripted variable was on every occasion checked at run time.” In plain terms, every array access was checked against the array’s bounds.

Years later, the company asked its customers whether they wanted an option to switch those checks off so that production programs would run faster. “Unanimously, they urged us not to,” Hoare recalled; they already knew how often subscript errors turned up in production runs. In any respectable branch of engineering, he added, failure to observe “such elementary precautions” would long since have been against the law.

So why make an exception for null? Hoare’s answer, given in an interview later in 2009, was that the safe alternative had costs of its own.

The fix he turned down

In ALGOL W, programmers could already declare a class with “variant records,” in which each variant had its own set of attributes, or fields. A null reference, Hoare told Redgate’s Simple Talk site, could simply have been a variant with no attributes at all.

The catch was the check. The compiler would then insist that every access to an attribute come with a test, plus code for the empty case. “Problem solved!” Hoare said. “But only by passing it on to the user.”

He had practical objections too. The tests would often be unnecessary, which would hurt efficiency. The variable could change between the test and the access. And a “scan-mark” garbage collector, the part of a running system that finds and frees unused memory, needs every reference to have an initial value; null, he said, was the right choice. For cyclic data structures, he added, there was no easy alternative to null.

These were real engineering arguments. What Hoare said he could not see was the total: “I was not able to predict the enormous cumulative cost of null reference errors in the decades to come.” He also offered what he called his only other excuse: “if I had not invented the null reference, somebody else would have.”

The billion dollars was a rough estimate

The famous number is softer than it sounds. Hoare’s abstract said the errors, vulnerabilities and crashes that null led to “have probably caused a billion dollars of pain and damage in the last forty years.” It was his own rough estimate, hedged with “probably,” and the abstract points to no study behind it.

Retellings can inflate it. A 2025 article on heise online, a technology news site, said that according to Hoare the error “has caused billions of dollars in damage.” He said one billion, probably, over forty years.

What the fix looks like now

Look closely at the fix Hoare endorsed. It does not remove the empty value. It makes the type say where the empty value is allowed.

That solution is now built into widely used languages. In Kotlin, a variable of type String cannot hold null. To allow null you declare a variable, say b, as String?, and from then on the compiler reports an error if you write b.length without a check or a safe call. Kotlin’s documentation describes null safety as a feature designed to “significantly reduce the risk of null references, also known as The Billion-Dollar Mistake.”

Rust goes further: it has no null references. A value that may be absent has the type Option<T>, which is either None or Some(T), and you have to convert it to a T before you can use the value as one. That is close to the variant-record design Hoare described: one variant with nothing in it, and one that carries a value.

C# took a gentler route. Version 8.0, released in September 2019, added nullable reference types, but they are annotations that drive compiler warnings; at run time, a nullable and a non-nullable reference behave the same.

Who pays for “easy to implement”

Both of Hoare’s options put work on programmers. Variant records would have demanded a check at every access, enforced by the compiler. Null made the check optional, and the cost came back as what his abstract called “innumerable errors, vulnerabilities, and system crashes.”

Modern languages kept the check and made it cheaper to write. The type shows where null is allowed, and Kotlin’s safe-call operator, ?., returns null instead of throwing an exception when the object is null.

The cost of an easy default is rarely paid by the person who chooses it. It is paid by everyone who builds on it, for as long as it lasts.

So the next time a design choice looks “so easy to implement,” ask the question Hoare said he could not answer in 1965: what will it cost everyone who uses it, added up over decades?

Related stories

Sources

Share this article
FacebookThreadsLinkedInX

Leave a Reply

Your email address will not be published. Required fields are marked *