3 ms·
The problem with null is that when anything can be null, your type system is always lying to you and as a result you don't get the full benefits of a real type
by sgk284 15y ago
The problem with null is that when anything can be null, your type system is always lying to you and as a result you don't get the full benefits of a real type system (see Haskell for a great type system).
When a var is a boolean, you can't assume it's true or false, because it could also be null. Or when you pass a Car object into a function, you've been promised a Car but were lied to because it might also be null.
In a proper type system, if you ask for a boolean, you know that variable is either true or false and when you ask for a car, you're guaranteed to get a car.
Of course, you can always have the option of allowing null values, but you should explicitly have to state that it's okay.