Live data from Hacker News

Tony Hoare's Null References: The Billion Dollar Mistake

infoq.com

11–14 of 14 posts

Re: Tony Hoare's Null References: The Billion Dollar Mistake

#11
post #7
post #6

I particularly appreciate that as a billion-dollar mistake, Javascript decided to make it twice (null and undefined).

The question is, what is the order of the mistake. When you have two, is it linear ($2b), quadratic ($1e18), or exponential?

Probably logarithmic due to diminishing returns. Having 20 nullish types isn't much worse than having 2. The biggest difference is going from 0 to 1.

Re: Tony Hoare's Null References: The Billion Dollar Mistake

#13
post #10
post #5

Earlier quoted context omitted.

The simple existence of "Not an object" value is fine. The abstraction built over the raw value should be good enough that it will confront you when you attempt to use it. The next level is constructing types in a way that you can avoid such low level details of whether the pointer is valid. In other words, encode the state in the type instead of a value that you need to test against every time you want to use it.

That's easier said than done, and it's not obvious how to do it with types. Consider a non-blocking read. What the caller does depends on whether the read returns a value or "no data available". If the type of the object returned depends on whether there was a value, you just replaced a null check with a type check. You can avoid that check with a caller with multiple return points and have the callee pick between th…

Callee can make that decision, it is called the continuation passing style.

Re: Tony Hoare's Null References: The Billion Dollar Mistake

#14
post #13
post #10

Earlier quoted context omitted.

That's easier said than done, and it's not obvious how to do it with types. Consider a non-blocking read. What the caller does depends on whether the read returns a value or "no data available". If the type of the object returned depends on whether there was a value, you just replaced a null check with a type check. You can avoid that check with a caller with multiple return points and have the callee pick between th…

Callee can make that decision, it is called the continuation passing style.

Multiple continuations is "multiple exit points".

There aren't many languages which support multiple continuations and SQL isn't one of them.

Post reply on HN