Nominal Types in WebAssembly

WebAssembly flirts with named types; fans cheer, purists cry 'stop reinventing Java'

TLDR: WebAssembly is adopting “named” data types using a throw/catch trick to keep values unforgeable, and devs are split. Supporters call it necessary maturity for safer modules; critics say it betrays the “portable assembly” promise and drifts toward Java-style complexity.

WebAssembly just got a little… fancier. A new write-up shows how “nominal types” (think: name‑brand data you can’t fake) are landing in Wasm using a quirky throw/catch trick, and the crowd immediately split into camps. One commenter laughed that field access feels like “shaking the struct and seeing what falls out,” and honestly, same. Another newcomer was stunned to discover the code looks like S‑expressions, not the assembly they imagined—cue curiosity and mild whiplash.

Then the gloves came off. The purists stormed in: “Wasn’t this supposed to be portable assembly?” One outraged voice demanded to know why a low-level runtime needs fancy types at all. On the other side, a Wasm insider chimed in: yes, they actually want nominal types—and type imports—to make modules safer and more usable across boundaries. Cue a nerdy sub‑debate over whether you can fake “named” types with a single recursive group versus the blog’s cheeky exception-based approach. Translation: security vs simplicity, with receipts.

Of course, the meme lords delivered: “Wasm is a toddler reinventing Java” got big laughs, complete with prophecies of checked exceptions and enterprise beans. Love it or loathe it, the mood is clear: WebAssembly is growing up, getting stricter about identity, and the community is loudly asking whether that’s evolution—or betrayal.

Key Points

  • Wasm historically used structural type equality; identical struct definitions in a module are equivalent.
  • Recursive type groups (rec) enable self/mutual recursion and are the unit of structural type equivalence, approximating nominal typing within a module.
  • Rec-based nominality fails across modules because isorecursive type equality allows forging equivalent rec groups.
  • A nominal typing proposal has been incorporated into the Wasm standard, introducing tag-based nominal types.
  • Nominal values are constructed and handled via exception-like mechanisms (throw, try_table, catch_*), typed as exn, with fields accessed through catch handlers rather than struct.get.

Hottest takes

"I would actually like to add nominal types to Wasm" — tlively
"What business is it for WebAssembly to know about complex types?" — kjksf
"like watching a toddler slowly reinvent java" — elophanto_agent
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.