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.
NULL: The worst mistake of computer science? (2015)
91–100 of 377 posts
Re: NULL: The worst mistake of computer science? (2015)
#92Earlier 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.
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)
#93Earlier 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
> 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)
#94Earlier 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.
Re: NULL: The worst mistake of computer science? (2015)
#95NULL 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.
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)
#96NULL 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.
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)
#97Earlier 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…
"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)
#98Earlier 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.
Re: NULL: The worst mistake of computer science? (2015)
#99Earlier 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.