For tagged unions, the difference is in memory layout. A real tagged union type would eliminate indirection and allow more code to be type stable.
For instance,
mutable struct NotTypeStable
o::Union{Some{Int}, Nothing}
end
function not_type_stable()
o = returns_option()
if isnothing(o)
0
else
1
end
end
versus: enum Option{T}
Some(T)
None
end
mutable struct TypeStable
o::Option{Int}
end
function type_stable()
o = returns_option()
match o
Some(_) => 1
None => 0
end
end
Both of these features aren't strictly necessary, but they act as a compliment to Julia's existing dynamic mechanisms (multiple dispatch & Union types)