Live data from Hacker News

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

lucidchart.com

91–100 of 377 posts

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

#91
post #47

Earlier quoted context omitted.

I wonder why this gets downvoted - seems pretty reasonable to me...

It's a rather odd argument and it falls apart as soon as you ask about 0 Kelvin.

Except when you take into account that 0 Kelvin actually is theoretically "nothing" with regards to temperature. It's not a floating point, it's an absolute.

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

#92
post #33

Earlier quoted context omitted.

> What exactly do you dislike about this? Or what do you even do about it? A handful of solutions already exist: - Use a higher-level language - Java

> Or what do you even do about it? All you need is a list of what width each type is. > A handful of solutions already exist: - Use a higher-level language - Java It doesn't require being "higher level". If anything it pushes code to a slightly lower level.

> All you need is a list of what width each type is.

This is exactly the kind of minutiae that GP was bemoaning.

> If anything it pushes code to a slightly lower level

Yeah by way of higher-level abstractions ...

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

#93

Earlier quoted context omitted.

> it falls apart as soon as you ask about 0 Kelvin Huh? The whole point of Kelvins is that their zero point is an actual 0 value. That's why Kelvins are a unit and °C aren't. Q: An object's temperature is 20°C. The object's temperature increases by 10%. What is the new temperature of the object? A: 49°C.

> That's why Kelvins are a unit and °C aren't Could I ask that you update Wikipedia with your discovery? Sadly the page appears to be erroneously using the word "unit" all over the place! https://en.wikipedia.org/wiki/Celsius Also, NIST might benefit from your guidance: https://physics.nist.gov/cuu/Units/kelvin.html

It's already there, if you know enough to recognize it:

> The degree Celsius (°C) can refer to a specific temperature on the Celsius scale or a unit to indicate a difference between two temperatures

In other words, you can add a quantity of °C to a temperature value and you'll get another temperature value. But you can't measure a temperature in °C.

Compare how, for example, the python datetime library uses a datetime type and a timedelta type. A datetime plus a timedelta is a datetime. datetimes refer to points in time, and timedeltas don't.

°C measures a temperature delta, but not a temperature.

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

#94

Earlier quoted context omitted.

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.

If my pointer already supports NULL, why would I put std::optional on top of it? I was saying I don't need a null for anything but a pointer.

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

#95

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.

null is often used in relational databases to be semantically equivalent to "info missing". I get that this use of null isn't ideal.

However there are quite a lot of cases where it is semantically equivalent to "not applicable"; while some of these cases can be avoided with a restructure, some can't, and in either case I don't see a compelling argument to do so.

e.g. a parent_id column that is null for top-level objects in a hierarchy. Restructuring the database to avoid this seems like moving to an unintuitive paradigm in pursuit of rule-following for its own sake.

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

#96
post #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.

Most languages do. Java will always initialise a non-initialised value to NULL for instance (EDIT or 0 or false for primitives).

It's simply a reality of how computers operate that when you allocate a piece of memory (a variable) it will have something in it that you'll need to clear or initialise.

In this respect, NULL is doing you a favour.

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

#97

Earlier quoted context omitted.

> That's why Kelvins are a unit and °C aren't Could I ask that you update Wikipedia with your discovery? Sadly the page appears to be erroneously using the word "unit" all over the place! https://en.wikipedia.org/wiki/Celsius Also, NIST might benefit from your guidance: https://physics.nist.gov/cuu/Units/kelvin.html

It's already there, if you know enough to recognize it: > The degree Celsius (°C) can refer to a specific temperature on the Celsius scale or a unit to indicate a difference between two temperatures In other words, you can add a quantity of °C to a temperature value and you'll get another temperature value. But you can't measure a temperature in °C. Compare how, for example, the python datetime library uses a datetim…

> It's already there, if you know enough to recognize it

"As an SI derived unit", "or a unit to indicate", "the unit was called"

Three mentions of it being a unit in the first paragraph, alone. I understand the point being made; the conclusion that "celsius is not a unit" is bogus, however, by any common definition, including NIST's.

In a now-deleted comment, you linked to a Wikipedia page on Dimensional Analysis, which includes the sentence "to convert from units of Fahrenheit to units of Celsius".

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

#98

Earlier quoted context omitted.

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

If my pointer already supports NULL, why would I put std::optional on top of it? I was saying I don't need a null for anything but a pointer.

Mainly to avoid scenarios where a pointer is used instead of a value type only because the author wishes to express that it is optional.

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

#99

Earlier quoted context omitted.

I find Maybe a bad idea. It forces me to write denormalized code when I know that something is not NULL. It's not possible to specify this knowledge as a data structure since data structures are static but context is dynamic. I much prefer the simple NULL sentinel that blows up like an assertion when I made a mistake. That said, there's not very often a need for NULL at all if you structure the code correctly.

> I much prefer the simple NULL sentinel that blows up like an assertion when I made a mistake. Haskell, for instance, has the 'fromJust :: Maybe A -> A' function that allows you to do just that. It unpacks the Maybe typed value and throws a runtime error if it fails.

Yes. Most Haskellers will sneer at it, while personally I think it's the right thing to do because it conveys the programmer's ideas about invariants. But syntactically an explicit unwrapping function is still a lot of noise. Simple null pointers as we have in C, with an unmapped segment at address zero so that it throws a segmentation fault, are much better.
Post reply on HN