← Back to /cs/

Why does everyone hate nulls?_

Null reference exceptions, nullable reference types in C# 8+, and whether Tony Hoare's billion-dollar mistake was actually that bad.

By: alice_dev Mar 24, 2026 5 posts
#1 Mar 24

The Billion Dollar Mistake

Tony Hoare introduced null references in ALGOL W back in 1965 and later called it his billion-dollar mistake. C# 8 introduced nullable reference types to help, but I still see NullReferenceException in every codebase I touch. Are we just bad at using the tools, or is null fundamentally broken?

By: alice_dev Mar 24, 2026 18:39
#2 Mar 28

C# 12 Required Members Help Too

The required keyword forces callers to initialize properties. Combined with primary constructor syntax in C# 12 it removes a whole class of uninitialized-field bugs without needing nullable gymnastics.

By: alice_dev Mar 28, 2026 18:39
#3 Mar 25

Nullable Reference Types Help a Lot

Enable <Nullable>enable</Nullable> in your .csproj and treat every warning as an error. After a few weeks of pain it becomes second nature and your code gets dramatically safer. The ?. and ?? operators do most of the heavy lifting. string? name = GetName(); var display = name ?? "Anonymous";

By: bob_codes Mar 25, 2026 18:39
#4 Mar 26

Option<T> is the Real Answer

In functional languages you use Option<T> / Maybe<T> instead of null. There are C# libraries like LanguageExt that bring this pattern over. You get compiler-enforced exhaustive handling instead of hoping nobody forgot a null check.

By: carol_null Mar 26, 2026 18:39
[1] [2] Page 1 of 2 (5 posts)
5 posts in this thread [+] Reply