TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Tony Hoare's Null References: The Billion Dollar Mistake

19 pointsby dlcmhabout 3 years ago

6 comments

jfengelabout 3 years ago
I particularly appreciate that as a billion-dollar mistake, Javascript decided to make it twice (null and undefined).
评论 #30725599 未加载
评论 #30722446 未加载
ljosifovabout 3 years ago
Not sure if it is possible to have "only valid object exists, ever" and have it working for real. In pointers we have NULL to signal "not a pointer". In floats we have NAN to signal "not a number". In integers I miss not-an-integer enough that I often designate INT_MIN as not-an-integer representation. I notice when working with indices, index 0 is a convenient not-an-index value. Don't know enough theory to figure if this empirical anecdote amounts to something more than that.
评论 #30720936 未加载
oofabzabout 3 years ago
I agree that null pointers are a bad idea and I try to avoid them in my code as often as possible. I go out of my way to avoid returning null to indicate an error condition. I use value types instead of reference types whenever possible, since a value type can&#x27;t be null. Instead of using null to indicate an error condition, I use a second variable or throw an exception.<p>Just because your programming language supports null pointers, doesn&#x27;t mean you need to use them. You can avoid the pitfalls discussed by Tony Hoare by simply refraining to use them. You will still need to handle null pointers coming into your code from outside, like from libraries, but your own code does not need to generate them.
bsenftnerabout 3 years ago
Please, stop this nonsense. It is not as if the NULL&#x2F;zero value was introduced after some code was written. This is a human written logic error, programmer(s) write logic and that logic will sometimes have bugs. This is someone getting paid to state an obvious fact and then throw philosophical phrases around in an attempt to sound like they are doing something. This is pure time wasted nonsense.
musicaleabout 3 years ago
On the other hand, having messages to nil do nothing in Objective-C had the interesting effect of making some iOS apps crash gradually rather than all at once. One might argue that it improved robustness in a strange way.
anamaxabout 3 years ago
The problem with NULL is that there&#x27;s only one.