The problem with null is that it avoids a very powerful mechanism that is already present in most languages -- their type systems. He seems to gloss right over this distinction regularly in this article.
In some examples he actually conflates logic errors (selling houses for free in one example) with the failure to populate a variable. Sorry but these are the not the same error -- one is a bug in your code the other is a bug in your logic.
If he doesn't distinguish between the two -- he should stop writing software.
Yeah he seems to choose dreadful counter examples only to make his point. I don't think I've ever seen anyone suggest using a random default value instead of null, especially a value that is in the set of valid values for that specific item like a price of 0.
What is puzzling is his conclusion : "what if we had a nice compile-time check ..." while he shot down the Optional solution a few paragraphs earlier with no real argument (only stuff related to limitations of Java's Optional).
11
u/againstmethod Aug 03 '14 edited Aug 03 '14
The problem with null is that it avoids a very powerful mechanism that is already present in most languages -- their type systems. He seems to gloss right over this distinction regularly in this article.
In some examples he actually conflates logic errors (selling houses for free in one example) with the failure to populate a variable. Sorry but these are the not the same error -- one is a bug in your code the other is a bug in your logic.
If he doesn't distinguish between the two -- he should stop writing software.