Episode

Proxy: Next Generation Polymorphism

with Mingxin Wang

Modern C++ demands a rethinking of polymorphism that moves beyond the constraints of classical inheritance while preserving performance and safety. In this talk, I will introduce Proxy - an open-source header-only C++20 library for non-intrusive polymorphism designed and refined by Microsoft. Proxy leverages pointer-based lifetime management to offer a GC-like capability without incurring the overhead of a garbage collector. The library's design is a response to long-standing challenges in traditional polymorphic code. It provides an alternative to inheritance by allowing any expression, be it member functions, free functions, operators, or conversions, to participate in a unified abstraction. Developed with portability, efficiency, and ease-of-use in mind, Proxy is engineered as a freestanding solution that works consistently across platforms-from embedded systems to operating systems, where it has been deployed in production since 2022.

Key points of discussion will include:

  • Non-Intrusive Abstraction: How Proxy eliminates the need for inheritance, making polymorphic interfaces simpler yet powerful
  • Lifetime Management: The innovative approach to managing object lifetimes, which offers performance competitive with hand-crafted solutions while avoiding common pitfalls
  • Flexibility and Performance: Detailed considerations on balancing API accessibility and efficient resource handling in a modern C++ ecosystem
  • Real-World Impact: Lessons learned from using Proxy in a large-scale, production environment, and a comparison with alternative polymorphic programming techniques.

Join me for an in-depth exploration of Proxy's design decisions, practical applications, and potential future directions that reimagine polymorphism for the next generation of C++ development.

Developer
Expression
GitHub
C++

Have feedback? Submit an issue here.