Live data from Hacker News

NULL: The worst mistake of computer science? (2015)

lucidchart.com

81–90 of 377 posts

Re: NULL: The worst mistake of computer science? (2015)

#81
NULL in 'relational' databases in particular is a disaster. Or at least according to the notorious Fabian Pascal.

http://www.dbdebunk.com/2017/04/null-value-is-contradiction-...

Codd never proposed it in his original relational model. For good reason.

Re: NULL: The worst mistake of computer science? (2015)

#82

Isn't there an inherent need in programming to express an explicit "nothing" value? Coming from Python and JS, I never found None/null to be much of a problem. I in fact like the distinction of null and undefined in JS. Using null allows you to distinguish from the accidental undefined.

> Isn't there an inherent need in programming to express an explicit "nothing" value? In numerical calculus: yes, most certainly. What do you expect the result of log(-1) to be? The alternative is to use specially tagged particular numbers as "no-data", and pray so that they do not appear naturally as the result of computations.

Or exceptions.

Re: NULL: The worst mistake of computer science? (2015)

#83

Isn't there an inherent need in programming to express an explicit "nothing" value? Coming from Python and JS, I never found None/null to be much of a problem. I in fact like the distinction of null and undefined in JS. Using null allows you to distinguish from the accidental undefined.

In C++ I practically never feel like I need a null for anything but a pointer. A null string or integer makes no sense to me.

Re: NULL: The worst mistake of computer science? (2015)

#85

Isn't there an inherent need in programming to express an explicit "nothing" value? Coming from Python and JS, I never found None/null to be much of a problem. I in fact like the distinction of null and undefined in JS. Using null allows you to distinguish from the accidental undefined.

In C++ I practically never feel like I need a null for anything but a pointer. A null string or integer makes no sense to me.

std::optional has the potential to eliminate many of the null-pointer uses.

Re: NULL: The worst mistake of computer science? (2015)

#86

NULL in 'relational' databases in particular is a disaster. Or at least according to the notorious Fabian Pascal. http://www.dbdebunk.com/2017/04/null-value-is-contradiction-... Codd never proposed it in his original relational model. For good reason.

I'm afraid current relational database have little common with the Codd's ideas.

Re: NULL: The worst mistake of computer science? (2015)

#87
NULL is certainly a mistake, but even more of a mistake is not allowing distinct states in variables.

NULL is just another case of a state of a variable. Other states are 1, 15, 0xffffffff, etc.

That mainstream languages don't handle this is the worst mistake of the computer industry.

Re: NULL: The worst mistake of computer science? (2015)

#88
post #27

NULL is a convenient way to map singularities in your model of the problem. I have on a few occasions tried to write NULL-less code, and it adds a good bit of work. - model all possible states for a value - determine appropriate default actions for all types - meaningful place-holder values It's a good exercise, and I think more code should be written this way, but - as an Engineer I'm trying to model just enough of…

> I have on a few occasions tried to write NULL-less code, and it adds a good bit of work. Really depends on the language. On Java / C#, it's hard to avoid null-checking a lot of stuff. In C++ you will never encounter a null std::string outside of code written by indian students learning on Turbo C++ 3.5. So you don't need to check for anything: if it's a value, it exists.

Strings are an easy case. Default initialisation to "" (empty string). You'll still encounter NULL when modelling other domains however.

Re: NULL: The worst mistake of computer science? (2015)

#89
post #31
post #27

NULL is a convenient way to map singularities in your model of the problem. I have on a few occasions tried to write NULL-less code, and it adds a good bit of work. - model all possible states for a value - determine appropriate default actions for all types - meaningful place-holder values It's a good exercise, and I think more code should be written this way, but - as an Engineer I'm trying to model just enough of…

Have you ever dealt with the Maybe(Haskell)/Option(F#) types? If not, then you don't understand what's wrong with NULL and how to easily avoid it without much work.

I see these as a more sophisticated way of dealing with NULL. It allows me to define alternative default behaviour beyond just throwing an undeclared exception.

They are still NULLs however under the hood and I still need to do the work of defining what I want to happen when they occur. It's just neater.

Re: NULL: The worst mistake of computer science? (2015)

#90

NULL in 'relational' databases in particular is a disaster. Or at least according to the notorious Fabian Pascal. http://www.dbdebunk.com/2017/04/null-value-is-contradiction-... Codd never proposed it in his original relational model. For good reason.

Disagree that it is a disaster. Nullability is explicit in the column type, so it doesn't have the "billion dollar mistake".

Furthermore you need to represent missing values somehow if you perform a left join.

Post reply on HN