# What Is Null in Programming?

> Null means no value. It is not zero or an empty string. Learn null vs undefined, SQL NULL, Hoare's billion-dollar mistake, and null safety.

*2026-10-29T19:08:12Z*

# What Is Null in Programming? The Billion-Dollar Mistake

*Originally published in Arabic on parmgy.com on June 4, 2019. Updated October 2026.*

Null is a special value that means "no value" or "points to nothing". It is not zero and it is not an empty string: it says that the variable intentionally holds nothing at all.

<!-- VIDEO_EMBED: parmgy-10-null-mistake (9:16 short, add the player here after release) -->

## In 60 seconds (the video)

1. **One programmer, one mistake.** By his own estimate, the null reference may have cost a billion dollars.
2. **1965.** British computer scientist Tony Hoare added it to ALGOL W, simply because it was easy to implement.
3. **2009.** At QCon London he called it his billion-dollar mistake: countless errors, vulnerabilities and crashes followed.
4. **null is not 0 and not "".** Zero is a number, an empty string is text, null means there is no value at all.
5. **The fix.** Kotlin, Dart and Rust make you handle it before the program runs.

## Null, zero, and empty are three different things

| Value | Meaning | Example |
|---|---|---|
| `0` | A real number | Items in cart: 0 |
| `""` | A real text, with no characters | A name field the user left blank |
| `null` | Nothing is there | A middle name we never collected |

The difference matters. An empty cart (0 items) is a known fact. A `null` age means "we don't know". If you treat them the same, an unknown age may be silently counted as 0 in an average.

## Where null shows up

- **Placeholders.** A variable can reserve a spot until a real value is assigned later in the program.
- **Missing results.** A search that finds nothing returns `null` (or `None`, `nil`, depending on the language).
- **Databases.** A column can be `NULL` when the data is missing or not applicable.

```javascript
let user = null;            // intentionally empty
let x;                      // JavaScript gives this undefined, not null
console.log(user === null); // true
```

In JavaScript, `null` is something you assign on purpose, while `undefined` is what the language gives a variable you declared but never set. Other languages use different words: Python has `None`, Ruby and Lua have `nil`, and Perl has `undef`.

## The "billion-dollar mistake"

Tony Hoare (1934–2026) introduced the null reference in 1965 while designing ALGOL W. In a 2009 talk at QCon London, *Null References: The Billion Dollar Mistake*, he said he could not resist the temptation to add it, "simply because it was so easy to implement", and that it had led to innumerable errors, vulnerabilities and system crashes which had probably caused a billion dollars of pain and damage in the last forty years. Note the wording: it is his own rough estimate, not an audited figure. Sir Tony Hoare died on 5 March 2026, aged 92. The classic symptom is the program crashing when it tries to use something that is actually `null`, such as a `NullPointerException` in Java.

## SQL has its own rules

In SQL, `NULL` means unknown, and comparing anything to unknown gives unknown, not true:

```sql
SELECT * FROM users WHERE age = NULL;   -- returns nothing, always
SELECT * FROM users WHERE age IS NULL;  -- the correct check
```

## Safer ways to handle null

Modern tools make "can this be null?" part of the type system:

- **Kotlin** separates `String` from `String?`. The compiler forces you to handle the nullable one.
- **TypeScript** with `strictNullChecks` (included in `strict`) reports uses of a possibly-null value. It is opt-in, so it does not force you by default.
- **Dart** has sound null safety (mandatory since Dart 3), with the same `?` idea.
- **Java** added `Optional<T>` in Java 8 to represent a value that may be absent.
- **Rust** has no null at all. It uses `Option<T>`.

Whatever your language, the habit is the same: check before you use, and prefer designs where "no value" is explicit.

## FAQ

### Is null the same as zero?
No. Zero is a number. Null means there is no value.

### What is the difference between null and undefined in JavaScript?
`null` is assigned deliberately to mean "empty". `undefined` is the default for a variable that was declared but never given a value.

### Why does `WHERE column = NULL` return nothing in SQL?
Because NULL means unknown, and a comparison with unknown is never true. Use `IS NULL` or `IS NOT NULL`.

### How do I avoid null errors?
Check for null before using a value, give variables sensible defaults, and use languages and tools with null safety, such as Kotlin, TypeScript strict mode, or Dart.

## Sources

- Tony Hoare, *Null References: The Billion Dollar Mistake*, QCon London 2009 (abstract and recording on InfoQ).
- Computer History Museum, *In Memoriam: Sir Antony Hoare (1934–2026)*, and Merton College, Oxford, on his death on 5 March 2026.
- Kotlin docs: Null safety. Dart docs: Null safety. Rust std docs: `Option`.

## Next steps

- [What Is a Variable in Programming?](https://fadymondy.com/en/blog/what-is-a-variable)
- [Hash vs. Array: What's the Difference?](https://fadymondy.com/en/blog/hash-vs-array)
- [What Is Object-Oriented Programming?](https://fadymondy.com/en/blog/object-oriented-programming-oop)

---

Source: https://fadymondy.com/en/blog/what-is-null
