Although type instability is currently very bad for performance in Julia, I believe there is work going on already to improve that greatly for certain cases (such as when the type can be inferred to be a union of a small number of types, such as Union{MyType, Void}).
Currently, one can manually optimize code in those cases, i.e. checking to see if the value isa(x, Void)
As other people have stated, there are many cases where one can’t know the type in advance, for example, a value read from a JSON or XML file.
1 Like