Null is definitely the billion dollar mistake. It’s not the “null” value however, since this could indeed be seen as a badly implemented option monad.
It’s the implicit nullability of all reference types which is the mistake, since it leads to undefined behaviour at runtime.
Also; in regards to the linked style discussion in the post; you’re wrong about all of it :p
How does the implicit nullability of all reference types lead to "undefined behaviour at runtime" in, for example, Java or C#?
I'm aware that dereferencing NULL pointers in C/C++ is undefined behavior, but I haven't seen this in any other language.
It especially doesn't help in languages like Java, where nulls completely subvert static types and static type checking and it turns a whole class of issues into runtime errors.
Allowing null means you're implicitly codifying Type class | null for every single reference type everywhere in your code. By doing it implicitly, you're not providing any semantics in the programming language or in the runtime to be able to deal with it at the same abstraction level as the code around any particular point where something can be null. This is incredibly error prone and makes for ugly, brittle code.
Yeah, it's a billion dollar mistake.
While Optional being nullable is aesthetically ugly, you're going to crash on the next method call in the Optional class sooner rather than later if someone got the silly idea to return a null instead of Optional.empty(). What's far worse is that in the case of someone not using Optional, you simply have no idea whether you should expect null or not, so you assume null is possible either way, gaining you nothing. In an ironic twist, Optional tells you when the return value is unlikely to be null. The exact opposite of how it should work!
Then there is all the legacy code (yes it is legacy code by now) written since 2020 taking advantage of Java records. An obvious opportunity to make record fields non-nullable by default was wasted! I await the day they introduce class2 and record2 keywords to fix the defaults...
Given that Java source code will increasingly be written by AI, it makes sense to incorporate coding patterns that are both defensive and clear for an AI to read.
Additionally, LLM code generation understands and writes Java using null values to represent cases of object absence.
How can I take this seriously. The language's shortcomings is from being written practically overnight, not from inverse proportional value elsewhere. This post might be a $100 mistake.
Filters out the records where UserName is not Null.
Where UserName Is Null
Filters out the records where UserName is null and possibly didn't finish the registration process.