[MUC++] Eduardo Madrid - Type Erasure exhibits Emergent Behavior
Channel: MUCplusplus
Date: 26/09/2022

Emergent behavior is when a system is complex enough that its behavior is not chaotic yet exhibits very interesting and unpredictable behavior.
C++ itself exhibits “emergent behavior”:
Templates were invented to avoid macros or copy&pasting, a type-safe replacement and ended up becoming their own programming language. Then there is the richness of C++’s type system (overloads, template specializations), which gave rise to a “Turing complete” meta language; and the invention of the Generic Programming Paradigm. Things that were never intended or even predicted in the original design of these features!
This presentation is about performance, modeling powers and programming techniques that arose much further from anything I had anticipated from Type Erasure when I began implementing the zoo framework. I've been intimidated about documenting my own work because I know there are concepts beyond my depth: I have been in the strange situation of having made a tool that allowed me to apply it to unanticipated uses, successfully, touching tantalizingly powerful ideas that I could not fully comprehend.
Klaus Iglberger gave us a conceptualization and vocabulary to talk about Type Erasure, promoted it to its own Design Pattern, in last years' CPPCon “Breaking Dependencies: Type Erasure, a Design Analysis”. This clarity made me realize Type Erasure accomplishes contradictory objectives: semantic binding (this means substitutability as in the Liskov Substitution Principle) *without* source code coupling.
The delicate balance between opposite tendencies is the fundamental requisite of truly interesting behavior —emergent behavior—, this presentation attempts to illustrate this point.