Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by martinko on Sunday September 04, 2016 @05:27PM
(#12426797)
Meh, in what language does ('Null'==Null) evaluate to true?
[ Parent
| on HN ]
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by banthar on Sunday September 04, 2016 @05:55PM
(#12426907)
I'm guessing this mostly happens during serialization to and from strings.
One programmer does String.valueOf(x) instead of x.toString() to prevent NullPointerExceptions.
This works pretty well until the next guy does x == null || x.equals("null") because "null"s pop up in UI.
At this point this is irreversible as nobody can tell what is null and what is "null".
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by dagw on Sunday September 04, 2016 @05:33PM
(#12426826)
It doesn't have to be at the language level. It's not unreasonable to assume that someone, somewhere in the mists of time decided that the string "NULL" was a reasonable choice for representing missing data in some input data and things kind of snowballed from there.
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by gtf21 on Sunday September 04, 2016 @05:38PM
(#12426851)
I've seen this in code I've reviewed before, where people will check for `== "empty"` instead of just using types like `null` which were designed for this (in javascript).
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by kqr on Monday September 05, 2016 @01:04AM
(#12428224)
A practise that may come from some shell scripting languages where `[ $x == "" ]` is an invalid command because empty strings aren't strings.
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by _kst_ on Monday September 05, 2016 @04:24AM
(#12428893)
That may be true in older shells, but in modern shells [ $x == "" ] is valid, and "" is a single token whose value is the empty string. But I've seen old code that does things like
if [ x$x == "x" ] ; then ...
apparently because it was necessary at one time.
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by kqr on Saturday September 17, 2016 @02:23PM
(#12521692)
It depends on what you mean by "older" shells. More modern shells tend to support this properly, but the baseline for most shell scripts is /bin/sh which is not guaranteed to be modern – it is often a new release of Sh.
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by astrodust on Monday September 05, 2016 @07:32AM
(#12429548)
Anyone who's done even a trivial amount of programming in the shell knows to do: [ "$x" == "" ]
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by kqr on Saturday September 17, 2016 @02:24PM
(#12521697)
That does not help, as far as POSIX is concerned.
$ [ "$x" == "" ]
sh: 2: [: unexpected operator
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by Normal_gaussian on Sunday September 04, 2016 @05:28PM
(#12426801)
Normally through coercion, and where the idea of a missing field hasn't been considered by a parser.
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by iopq on Sunday September 04, 2016 @07:44PM
(#12427275)
Until something gets stored as CSV at some point where there's no straight-forward way to store Null.
Re:Hello, I’m Mr. Null. My Name Makes Me Invisible to Computers
by Falling3 on Sunday September 04, 2016 @10:21PM
(#12427741)
An empty field?