I am a bit lost on the many ways to represent the “empty” concept in Julia…
What is the difference between Null
(from Nulls.jl), NA
(From DataFrames), #NULL
from NullableArrays, Nullable
container (from base), nothing
(in base) and the empty string ""
?
Things are in transition at the moment.
Nullable{T}
can be returned by a method that may or may not return a value. This is useful for type stable code, but can be cumbersome occasionally. Eg a parser can return a Nullable{Int}()
if it could not parse something as an integer.
NA
is a value that indicates “missing data”. This works, but it is hard to optimize. Null
is the next round in the design of missing value handling.
It is somewhat confusing, as developers are trying to find the solution which is both fast and convenient.
#NULL
is just the way Nullable()
(i.e. a null Nullable
) is printed in some contexts. nothing
is the value returned by code blocks and functions which do not return anything, and it’s also used in some places to signal the absence of a value (in a type-unstable way). The empty string is, well, just a string with no characters.
Hopefully Nullable
and NA
will go away before Julia 1.0. There will remain null
(of type Null
) and nothing
(of type Void
), the main difference being that null
propagates silently (e.g. 1 + null === null
), just like NA
did in DataArrays (and in R, like SQL’s NULL
). These are sometimes referred to respectively as the data scientist’s null (null
) and software engineer’s null (nothing
).
For more details, see this issue.
If null
propagates silently and nothing
does not, e.g. 1+nothing
is an error, doesn’t that make null
for data scientists and nothing
for software engineers, not vice versa?
Right! I added these after writing the sentence for clarity, and of course I got the order wrong. Fixed.
For those reading this thread in post Julia 1-0, what at the end remained is:
-
nothing
as the software engineer’s null (most operations using it will emit run time errors) -
missing
as the data scientist’s null (propagates silently)
I revive this thread to post a nice BBC video about the history of the concept of zero: