Existentialize your Generics
summary
Claims that existentialization factors method tables out of object headers to give dynamic dispatch without boxing, implemented via type-class-style witnesses and any shape / existential containers in Scala/Swift/C++. Paper provides a compiler transformation, a runtime witness layout, and microbenchmarks showing overheads comparable to monomorphization in C++/Swift and similar performance on HotSpot. Also describes partial existentialization to tune the monomorphization/erasure trade-off and how witnesses carry size/layout info for allocation and reflection.
AI-written summary · about
chapters (10)
- 0:00Generics introduction
- 1:05Traditional generic approaches
- 3:55Memory trade-offs in generics
- 7:24Type classes vs subtyping
- 10:52Type classes dispatch
- 13:19Existentialization for generics
- 16:11Sequences with type classes
- 20:47Partial existentialization trade-offs
- 22:10Existentialization benefits
- 23:15Performance and conclusion
related talks
14mThe Simple Essence of Monomorphization
38mExistential Types — Make OOP Great Again!
15mThe Simple Essence of Overloading: Making ad-hoc polymorphism more algebraic with(…)
21mPolymorphic Typestate for Session Types
42mPolymorphic Function Types in Scala 3
21mSeamless Scope-Safe Metaprogramming Through Polymorphic Subtype Inference (Short Paper)
01h 00mDynamic Polymorphism with Metaclasses and Code Injection
23mBetter Defunctionalization through Lambda Set Specialization
