Union vs sum types
1 points by nrposner
1 points by nrposner
Honestly, this feels like an effort to artificially put things on the same footing for comparison, given that, depending on how you look at the argument, either you're comparing compile-time types and runtime types and "You don't unwrap and re-wrap because it's not wrapped in the first place" is flawed because runtime types are never not wrapped or you're arguing for "the advantages of unsafety" on the Julia side and you're effectively comparing Rust's enum and Rust's union.
I can't think of any other options for how to achieve the "types as sets of values" paradigm ascribed to Julia. It's necessary to know how to deal with the different in-memory representations associated with different types and you either hang that information off the type (enum as an extension of C-style int vs. float vs. etc. ...which requires storing how to interpret ambiguous bit patterns somewhere) or you hang that information off the call site (Rust's union as an extension of assembly-style ADD vs. FADD vs. etc. where you design your code so bit patterns can never be ambiguous)
...and there isn't really anything novel about an entry-level comparison of the pros and cons of runtime vs. compile-time type systems in general. We've been going wild for runtime typing and other "heavy runtime" things since the 90s and that's why Rust was so novel.
I think a few things could be clarified. The article doesn't clearly distinguish between semantics and implementation. It also doesn't distinguish between C-style (untagged) unions and TypeScript/Julia unions (or what OCaml calls "polymorphic variants").