Skip to content
HHackerTube.videoSurprise me

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

CppCon 2017: Herb Sutter “Meta: Thoughts on generative C++” on HackerTube: recommended by 2 Hacker News commenters across 2 separate months, 2017–2020.

CppCon

talk · advanced · dated

Open on YouTube

At CppCon 2017 Herb Sutter presents his work on evolving C++ through compile-time code generation, including metaclasses and reflection. The aim is to make the language both more powerful and simpler by letting programmers express intent directly.

Why Hacker News recommends it

Praised as the best talk of CppCon 2017 and the key introduction to metaclasses and generative C++.

people recommended it
2
separate months
2
strong recommendations
2
discussed on HN
2017–2020
“Herb Sutter's talk about it is by far the best talk I've seen from from CppCon17.”
— slavik81, Oct 2017, in “C++17 Is Here: Interview with Herb Sutter”

What HN commenters said

4 Hacker News comments link this video. Each one links back to its thread.

xaedesJan 2018Strongly recommends

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

in “Outperforming LAPACK with C++ metaprogramming” · View on HN

slavik81Oct 2017Strongly recommends

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

in “C++17 Is Here: Interview with Herb Sutter” · View on HN

tylerhouDec 2020Cites it

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. ▶ this video

in “Is the preprocessor still needed in C++? (2017)” · View on HN

tylerhouDec 2020Cites it

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 [de]serialization. I also have to hope that my library supports all the field definitions I need. 2. Write macros to define each field in each structure. These macros perform some arcane magicks that somehow create the necessary [de]serialization functions. These macros are difficult to write and maintain (or I find a library). 3. Manually define the methods myself. This is tedious, hard to maintain, and error prone. What if I could write some code in C++ which could read the structure and generate the appropriate serialization code? Something like (syntax hypothetical): Serializable(Class) { std::string serialize() { std::string output; for (auto member : Class.members()) { // loop unrolled at compile time if (member.type == int) { output.append(std::format("{:10}"), member.get()) } else if (member.type == std::string) { ...

in “Is the preprocessor still needed in C++? (2017)” · View on HN

Topics & tags

C, C++, Rust, Go & systems languagesProgramming language designc++herb suttermetaclassesreflectioncode generationcppcon