Skip to content
0:00 / 0:00

#c++#metaclasses#reflection

CppCon 2017: Herb Sutter “Meta: Thoughts on generative C++”

CppCon

189K subscribers • 103 videos on Hallway • Conference channel

YouTube
  • Recommended by 4 people: 2 on Hacker News, 1 on Lobsters and 1 curated list.
  • A classic. People kept recommending it from 2017 to 2024.
  • Presented by Herb Sutter
  • Linked in the descriptionCppCon/CppCon2017

Advanced. Deep dive for people who know the field.

104K views9 years ago4 recommendations

Programming languagesSystems programmingC++Language design and type systemsCompilers and interpreters

Herb Sutter presents a proposal for compile-time code generation and metaclasses in C++ to make the language simpler and more powerful.

CppCon.org — Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2017 — Two years ago, I started to focus on exploring ways that we might evolve the C++ language itself to make C++ programming both more powerful and simpler. The only way to accomplish both of those goals at the same time is by adding abstractions that let programmers directly express their intent—to elevate comments and documentation to testable code, and elevate coding patterns and idioms into compiler-checkable declarations. The work came up with several potential candidate features where judiciously adding some power to the language could simplify code dramatically, while staying true to C++'s core values of efficient abstraction, closeness to hardware, and the zero-overhead principle. The first two potential candidate features from that work to be further developed and proposed for ISO C++ are the <=> unified comparison operator (minor) and what I've provisionally called "metaclasses" as a way to generatively write C++ types (major). This talk is about the latter, and includes design motivation, current progress, and some live online compiler demos using the prototype Clang-based compiler built by Andrew Sutton and hosted at godbolt.org. — Herb Sutter - Software architect, Microsoft Herb chairs the ISO C++ committee and is the primary author or co-author of a number of Standard C++ features, including nullptr, enum class, parallel algorithms, C++17 structured bindings, and the in-progress unified <=> comparison operator. — Videos Filmed & Edited by Bash Films: BashFilms.com Work at Hudson River Trading (HRT): tinyurl.com/safxfctf --- Videos Filmed & Edited by Bash Films: BashFilms.com

Why it's here

4 people recommend this

What people say. Recommended as an outstanding CppCon talk explaining the potential of compile-time reflection and metaclasses in C++.

slavik81on Hacker News • Recommends

On “C++17 Is Here: Interview with Herb Sutter”

Herb Sutter's talk about it is by far the best talk I've seen from from CppCon17. "Meta: Thoughts on generative C++" - link to this video

xaedeson Hacker News • Recommends

On “Outperforming LAPACK with C++ metaprogramming”

The talk about the reflection proposal was amazing. Meta classes are also very cool. We can only hope it comes fast. link to this video

programming-talkscurated list on GitHubRecommends

Under “C++”

Meta: Thoughts on generative C++ 01:47:44 by **Herb Sutter** (2017)

Corbinon Lobsters • Recommends

Meta: Thoughts on generative C++ (2017)

u/oilshellin r/ProgrammingLanguages • Mentions

On “ZL Language: a C compatible and C++ like programming language with Scheme-like macros”

…spell.net/ And it turns out the author of aspell has also written this significant programming language! It's about 10 years old but the metaprogramming angle seems interesting. I think people like Herb Sutter and still talking about this type of metaprogramming C++, greatly simplifying the language (if it didn't have to support the legacy!) : link to this video I've been playing with constexpr and kind of amused how it has been built into its own programming language over C++ 11, 14, 17, and 20. The rules for when you can use constexpr are constantly being relaxed and constantly confusing. https://github.com/oilshell/oil/wiki/Metaprogramming…

tylerhouon Hacker News • Mentions

On “Is the preprocessor still needed in C++? (2017)”

A few years ago Herb Sutter proposed Python-like metaclasses in C++ through compile-time code generation. Not sure if anything has been proposed for general use. link to this video

tylerhouon Hacker News • Mentions

On “Is the preprocessor still needed in C++? (2017)”

To a degree, but templates and constexpr don't support a bunch of features like compile-time field enumeration and introspection + code generation. For example, let's say I have a bunch of structs: struct GeoCoordinate { int lat, long; }; struct GeoArea { std::vector<GeoCoordinate> perimeter; }; struct Place { std::string name; std::string contact_number; GeoArea area; }; Now I need to serialize these structs into a format to be sent over the wire. Currently, I have a few choices: 1. Use an off-the-shelf library like protobuf (disclaimer: I work for Google). Then I have to convert my code to a protobuf definition and rely on its code generator to perform deserialization. I also have to hop…