This article describes the history of nullability in F# and how the feature builds upon in to deliver improved null safety in F# code as well as in interoperability scenarios with other languages. F#’s Nullable Reference Types are part of F# 9 which shipped along side .NET 9.
The null reference was famously admitted by Tony Hoare to be his Billion-Dollar mistake, with many developers claiming it to have cost a lot more. Many of us, developers, do have experience with getting a NullReferenceException at runtime and have spent considerable amount of time trying to fix bugs related to it. Given Tony Hoare’s presence at Microsoft Research, it was natural for programming languages researchers to rectify this mistake in language design.
F# has long been at the forefront of making it possible and practical to code without the routine use of null. F# avoided null values for F#-only code in its early design, and for idiomatic F#-originated code, assigning null to a value leads to a compile-time error. For many years, F# was the only language widely available on the JVM or .NET runtimes which routinely avoided null values.