Episode 91: Kevlin Henney on C++

Topics covered
Popular Clips
Episode Highlights
Template Power
Template metaprogramming in C++ offers powerful compile-time capabilities, allowing developers to optimize performance and memory usage. explains that templates enable the expression of complex ideas and relationships between types at compile time, which is a significant advantage over runtime reflection found in other languages 1. However, he notes that the language was not originally designed for this purpose, leading to some complexity and ingenuity required to make it work effectively 2.
The template system is actually Turing complete. You can perform calculations in it, allowing you to do things at compile time that give you no runtime overhead.
---
Despite its challenges, template metaprogramming has practical applications, such as injecting behavior into base classes, as seen in frameworks like Microsoft's ATL 3.
Modern Idioms
Contemporary idioms in C++ have evolved to simplify programming practices and enhance expressiveness. highlights that modern idioms focus on solving problems rather than just using language features, leading to more elegant and efficient code 4. The canonical class form, once a staple, is now seen as less essential, with newer idioms offering simpler ways to express relationships between operators and operations 5.
The idiom landscape has definitely shifted. You see some surprisingly short and elegant pieces of code that years ago people would have expressed in ten times the size.
---
This shift reflects a broader emphasis on value-based programming and encapsulation, reducing the need for manual memory management and outdated idioms 6.
Design Patterns
C++'s embrace of design patterns has significant implications for development and code maintenance. observes that the understanding of design patterns in the C++ community has plateaued, with many developers still adhering to the patterns outlined in the Gang of Four book 7. However, he notes that C++'s template facilities and operator overloading allow for the creation of domain-specific languages, offering a more flexible approach to design 8.
The current growth in the idea of domain-specific languages, and also in particular embedded or internal domain-specific languages, where we create a sort of mini language within a language, actually goes back decades.
---
This flexibility is exemplified by libraries like Boost, which leverage templates to express complex programming concepts without runtime overhead 2.
Related Episodes


Episode 159: C++0X with Scott Meyers
Answers 383 questions

Episode 97: Interview Anders Hejlsberg
Answers 383 questions

Episode 96: Interview Krzysztof Czarnecki
Answers 383 questions

Episode 462: Felienne on the Programmers Brain
Answers 383 questions

Episode 57: Compile-Time Metaprogramming
Answers 383 questions

SE Radio 617: Frances Buontempo on Modern C++
Answers 383 questions

Episode 36: Interview Guy Steele
Answers 383 questions

Episode 142: Sustainable Architecture with Kevlin Henney and Klaus Marquardt
Answers 383 questions
Episode 494: Robert Seacord on Avoiding Defects in C Programming
Answers 383 questions

Episode 126: Jetbrains MPS with Konstantin Solomatov
Answers 383 questions

SE-Radio Episode 251: Martin Klose on Code Retreats
Answers 383 questions

Episode 403: Karl Hughes on Speaking at Tech Conferences
Answers 383 questions

Episode 38: Interview James Noble
Answers 383 questions













