2017 LLVM Developers’ Meeting: “Implementing Swift Generics ”
Why Hacker News recommends it
Recommended as the clearest explanation of how Swift generics compile and how that differs from other languages.
What it is
Swift compiler engineers explain how Swift implements generics using dictionary-passing with reified type metadata. They compare it with Java-style uniform representation and C++ or Rust monomorphization.
Recommended by 2 HN commenters across 2 different months, 2017 to 2026.
What Hacker News said
Recommends Veedrac · 2017-12 · on “Type Erasure in Swift”
If you're interested, there's a very nice talk on how Swift's generics compile. It's different to Rust in some key ways. [this video]
Recommends favorited · 2022-10 · on “Compiling Swift Generics [pdf]”
Swift's generics have some unique properties at module boundaries to allow for a stable ABI while enabling library evolution. To get additional background, you might be interested in this[0] conference talk (the paper's author is one of the co-presenters). Also, this post[1] by a Rust and Swift compiler engineer talks about what Swift does differently than other languages, and the tradeoffs that are involved. [0] [this video] [1] [LINK]
Cites favorited · 2022-11 · on “Swift Project in 2023”
The Swift story around ABI stability and library evolution is pretty unique. Relatedly, its approach to generics doesn't fall into either of the 2 traditional paths (either box everything like Java and C#, or template instantiation like C++ or Rust). [LINK] [this video]
Cites mananaysiempre · 2026-04 · on “A tail-call interpreter in (nightly) Rust”
> It doesn't make sense to me that an embedded VM/interpreter could ever outperform direct code. You're adding a layer of abstraction and indirection, so how is it possible that a more indirect solution can have better performance? It is funny, but (like I’ve already mentioned[1] a few months ago) for serialization(-adjacent) formats in particular the preferential position of bytecode interpreters has been rediscovered again and again. The earliest example I know about is Microsoft’s MIDL, which started off generating C code for NDR un/marshalling but very soon (ca. 1995) switched to bytecode programs (which Microsoft for some reason called “format strings”; these days there’s also typelib m