A Critical Look at Modern C++: Exploring Design, Architecture, and the Hype Around 'Silver Bullet' Solutions
0:00:02 Introduction and the Shape Example: Claus introduces a software design discussion using a simple "draw shapes" example to illustrate design choices and their impact.
0:01:24 Large Scale Design: He emphasizes the example's applicability to large projects (10 million lines of code, 100+ developers) to highlight the importance of scalability and maintainability.
0:01:48 Initial Solution (Gang of Four Style): A traditional object-oriented approach using inheritance, virtual functions, and the Strategy pattern is presented, decoupling shape classes from graphics libraries.
0:06:39 Architectural Boundary: The concept of an architectural boundary is introduced to separate high-level abstractions from low-level implementation details.
0:07:18 Critique of the Initial Solution: Despite using some modern C++ features (unique pointers, move semantics), the design is criticized for being outdated (1994-style) and not representative of modern best practices.
0:08:39 The Problem with 'Gang of Four' Style: This design style is identified as common (90% of projects) but problematic, leading to discussions about its limitations.
0:09:58 Industry Trend Against OOP: Various talks and articles are cited that critique object-oriented programming and advocate for alternative approaches (functional programming, data-oriented design).
0:12:59 Refactoring with std::variant: A new solution is proposed using std::variant to replace inheritance and virtual functions, aiming for a more "modern" approach.
0:14:16 Benefits of the std::variant Approach: The benefits are outlined: no inheritance, no pointers, simpler code, easier lifetime management, and potential performance improvements.
0:17:59 Performance Comparison: Benchmarks suggest that the std::variant version is faster than the traditional object-oriented approach.
0:21:57 The Problem with std::variant and Templates: The std::variant solution is critiqued for its poor architectural properties, tight coupling, and potential to lead to a "10-million-lines header-only template library."
0:28:08std::variant is Not a Silver Bullet: It's emphasized that std::variant is not a universal replacement for virtual functions and has its own trade-offs.
0:29:17 Comparing std::variant and Virtual Functions: A detailed comparison highlights their opposing properties regarding type sets and operations, emphasizing their different architectural roles.
0:30:17 Importance of Design: The speaker argues that design and architecture are more crucial to project success than specific language features.
0:31:37 Progressive C++: The concept of "Progressive C++" is introduced as a philosophy for modern C++ development, focusing on values, composition, and a blend of programming paradigms.
0:36:38 Type Erasure as a Solution: A type erasure technique is presented as a way to achieve polymorphism without the drawbacks of traditional inheritance or the tight coupling of std::variant.
0:42:44 Benefits of Type Erasure: Easier to use, simpler surrounding code, and potentially better performance due to optimizations like Small Buffer Optimization (SBO).
0:46:28 Comparison to the Initial Solution: The type erasure solution is shown to be architecturally similar to the initial object-oriented approach but with improved code structure and maintainability.
0:47:22 Performance of Type Erasure: Benchmarks indicate that the type erasure approach has comparable performance to the traditional object-oriented design, with potential for further optimization.
0:49:14 Choosing the Right Solution: The importance of considering both functional (variant-based) and object-oriented (type erasure) approaches based on specific project needs is emphasized.
0:51:28 Future of C++ (Reflection): The potential impact of reflection in C++26 is discussed, with a warning against viewing it as a silver bullet.
0:53:24 Conclusion: The talk concludes by reiterating that there's no single best solution and that understanding the trade-offs of different design choices is crucial for software development.