Runtime Polymorphism: Back to the Basics
summary
Explores concrete designs for runtime polymorphism beyond inheritance, implemented in the Dyno library, with policy-driven storage: heap-based remote storage, in-object small buffer optimization, always-local fixed buffer, non-owning view, and shared pointers with copy-on-write shared storage. Shows heap allocations dominate cost in microbenchmarks so SBO or local storage often removes allocations; one layout reduces pointer hops and sometimes enables unexpected inlining that outperforms classic vtable dispatch. Proposes reflection/metaclass hooks to generate vtables and simplify safe, efficient type erasure.
AI-written summary · about
chapters (14)
- 0:00Introduction and motivation
- 1:30When runtime polymorphism is needed
- 4:21Problems with inheritance
- 14:50Conceptual interface without inheritance
- 18:29Fat pointer approach to runtime polymorphism
- 27:11Small buffer optimization for storage
- 39:12Local storage without heap allocation
- 49:20Non-owning storage with string_view-like semantics
- 59:25Shared remote storage and copy-on-write
- 1:05:39V-table inlining and optimization
- 1:18:34Unexpected inlining benefits from pointer hops
- 1:21:42Lessons learned and practical advice
- 1:26:26Future with reflection and metaclasses
- 1:33:12Summary and conclusion
related talks
01h 08mRuntime Polymorphism: Back to the Basics
49mPolymorphism != Virtual: Easy, Flexible Runtime Polymorphism Without Inheritance
01h 23mRethink Polymorphism in C++
01h 00mDynamic Polymorphism with Metaclasses and Code Injection
01h 00mBack to Basics: Object-Oriented Programming
55mBreaking Dependencies: Type Erasure - The Implementation Details
01h 31mWhen Abstractions Fix Too Much - Towards Flexible Library Design
55mHow to "OO" in C++
