4 ms·
No really, it is almost the opposite. The mistake was to have null be a valid value for all object types. Languages where nullability is represent in the type s
by goto11 8y ago
No really, it is almost the opposite. The mistake was to have null be a valid value for all object types. Languages where nullability is represent in the type system (e.g. Typescript) does not have this problem. But the null-object pattern introduces the same problem in a new way.
- paulddraper 8y agoIn languages without "everything can be null", the null-object pattern is what is always done. The problem with "everything can be null" is the type system is prevented from finding very common "you can't do this thing" errors. Without it, everyone uses null objects (or Maybe, a generic for of this) and there are no segmentation faults/dereferencing errors. (Yes there can be other sorts of errors, but the problem has been made far better.)
- goto11 8y agoThe "Null object pattern" is a particular pattern where missing values are represented with an object with "neutral" behavior. This is not the same as an actual null or an option type.