What's the difference between Null, NA, #NULL, nothing, ""


#1

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 "" ?


#2

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.


#3

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


#4

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?


#5

Right! I added these after writing the sentence for clarity, and of course I got the order wrong. Fixed.