Null Safety Debate

The cluster focuses on criticisms of implicit nulls in mainstream programming languages like Java and advocacy for null safety features such as non-nullable types by default and explicit null annotations in languages like Rust, Kotlin, C#, and TypeScript.

📉 Falling 0.4x Programming Languages
3,348
Comments
19
Years Active
5
Top Authors
#2340
Topic ID

Activity Over Time

2008
4
2009
32
2010
37
2011
67
2012
56
2013
148
2014
154
2015
186
2016
206
2017
220
2018
253
2019
175
2020
265
2021
290
2022
383
2023
273
2024
338
2025
235
2026
26

Keywords

NullMarked e.g NULL JVM IMO SQL IME NullReferenceException nickknowlson.com TypeScript null nullable languages type types java language kotlin value safety

Sample Comments

arein3 Jun 11, 2023 View on HN

Is it too much to ask for null safety in the type system?

orclev Jun 18, 2013 View on HN

Implicit nulls are the underlying problem. If you default to non-nullable types and only allow nulls when explicitly annotated then it becomes much simpler to spot and handle all the cases where nulls might creep into your code. There are multiple ways of accomplishing that of course. Rust forces you to explicitly declare a variable as nullable and won't allow you to assign a nullable value to a non-nullable variable without performing a null check first. Haskell simply doesn't have a

lucian1900 Apr 9, 2013 View on HN

It's more a failing of mainstream programming languages having nulls.

int_19h Sep 27, 2022 View on HN

The problem isn't null/nil as such, it's when the type system treats null values as legal at compile-time.But if you look at e.g. Kotlin, or C# with "#nullable enable", it tracks whether a given reference can be null or not. So you write if-else code instead of match, but you have to do that in order to actually do something with a reference.

kllrnohj May 10, 2018 View on HN

Surprised there's no mention of Kotlin here. It handles this really nicely, forcing you to declare if a value can be null and if it is null it requires a null check before it can be used (with some syntax sugar to make that cleaner)

FooBadDev Feb 28, 2019 View on HN

Wouldn't using Koltin or Scala, which benefit from the engineering effort of JVM and arguably its ecosystem solve this problem ? (Since NULL is not idiomatic in either language)

toastal Jun 28, 2019 View on HN

Any type system that allows null or any shouldn't be trusted any more than a dynamic language

lmm May 10, 2018 View on HN

It's the same mistake as checked exceptions all over again. If you make null a special case in the type system then anything that interacts with the type system has to know about null or will handle it wrong. Far better to have the type system work with plain (non-nullable) values, and implement a plain old library type like Maybe/Option for use in places that need absence semantics; that way your concerns are properly separated and you can spend your type system complexity budget in m

mirekrusin Jan 31, 2025 View on HN

Also missing null safety in modern language is weird.

zapzupnz Aug 31, 2021 View on HN

Agree. It's not null that's the issue. Null can be fine, especially in a union type like Some|None (which in most languages is a type called Optional).It's mainly to do with languages that couldn't signify that some value could be null so you'd be forever doing defensive nullity checks. Developers get lazy or forgetful and miss out those checks when they need to be there; without language support, the compiler has no reason to assume that's a problem and lets cod