HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

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

CppCon2 HN recommenders · recommended in 2 months, 2017-2020
YouTube
105K views · 9 years ago · talk · dated

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.

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

C, C++, Rust, Go & systems languagesProgramming language design#c++#herbsutter#metaclasses#reflection#codegeneration#cppcon

4 comments from Hacker News

@tylerhou2020 · in “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 [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) { ...

CitesView on HN
@tylerhou2020 · in “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. ▶ this video

CitesView on HN
@xaedes2018 · in “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. ▶ this video

Strongly recommendsView on HN
@slavik812017 · in “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++" - ▶ this video

Strongly recommendsView on HN
Can C++ be 10x Simpler & Safer?  - Herb Sutter - CppCon 20221:54:00

Can C++ be 10x Simpler & Safer? - Herb Sutter - CppCon 2022

CppCon
277K views • 3 years ago
CppCon 2015: Herb Sutter "Writing Good C++14... By Default"1:29:06

CppCon 2015: Herb Sutter "Writing Good C++14... By Default"

CppCon
193K views • 11 years ago
CppCon 2014: Herb Sutter "Back to the Basics! Essentials of Modern C++ Style"1:40:27

CppCon 2014: Herb Sutter "Back to the Basics! Essentials of Modern C++ Style"

CppCon
323K views • 12 years ago
De-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable - Herb Sutter  CppCon 20191:33:12

De-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable - Herb Sutter CppCon 2019

CppCon
90K views • 7 years ago
CppCon 2016: Herb Sutter “Leak-Freedom in C++... By Default.”1:39:25

CppCon 2016: Herb Sutter “Leak-Freedom in C++... By Default.”

CppCon
149K views • 10 years ago
CppCon 2018: Hana Dusíková “Compile Time Regular Expressions”54:48

CppCon 2018: Hana Dusíková “Compile Time Regular Expressions”

CppCon
14K views • 8 years ago
CppCon 2015: Sean Parent "Better Code: Data Structures"1:04:00

CppCon 2015: Sean Parent "Better Code: Data Structures"

CppCon
106K views • 11 years ago
2013 Keynote: Chandler Carruth: Optimizing the Emergent Structures of C++1:33:02

2013 Keynote: Chandler Carruth: Optimizing the Emergent Structures of C++

CppNow
34K views • 13 years ago
C++ and Beyond 2012: Herb Sutter - atomic Weapons 1 of 21:21:13

C++ and Beyond 2012: Herb Sutter - atomic Weapons 1 of 2

alexsmail
71K views • 9 years ago
CppCon 2015: Chandler Carruth "Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!"1:29:54

CppCon 2015: Chandler Carruth "Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!"

CppCon
188K views • 11 years ago
CppCon 2017: Titus Winters “C++ as a "Live at Head" Language”1:31:14

CppCon 2017: Titus Winters “C++ as a "Live at Head" Language”

CppCon
53K views • 9 years ago
CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”1:19:52

CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”

CppCon
264K views • 10 years ago
CppCon 2018: Nicolai Josuttis “The Nightmare of Initialization in C++”59:58

CppCon 2018: Nicolai Josuttis “The Nightmare of Initialization in C++”

CppCon
79K views • 8 years ago
CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior..."57:39

CppCon 2016: Chandler Carruth “Garbage In, Garbage Out: Arguing about Undefined Behavior..."

CppCon
94K views • 10 years ago
CppCon 2017: Matt Godbolt “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”1:15:46

CppCon 2017: Matt Godbolt “What Has My Compiler Done for Me Lately? Unbolting the Compiler's Lid”

CppCon
178K views • 9 years ago
CppCon 2016: Dan Saks “extern c: Talking to C Programmers about C++”1:36:27

CppCon 2016: Dan Saks “extern c: Talking to C Programmers about C++”

CppCon
175K views • 10 years ago
CppCon 2019: Matt Godbolt “Path Tracing Three Ways: A Study of C++ Style”55:42

CppCon 2019: Matt Godbolt “Path Tracing Three Ways: A Study of C++ Style”

CppCon
77K views • 7 years ago
C++ and Beyond 2012: Herb Sutter - atomic Weapons 2 of 21:32:33

C++ and Beyond 2012: Herb Sutter - atomic Weapons 2 of 2

alexsmail
29K views • 9 years ago
CppCon 2018: G. Nishanov “Nano-coroutines to the Rescue! (Using Coroutines TS, of Course)”1:04:26

CppCon 2018: G. Nishanov “Nano-coroutines to the Rescue! (Using Coroutines TS, of Course)”

CppCon
40K views • 8 years ago
CppCon 2017: Juan Pedro Bolivar Puente “Postmodern immutable data structures”1:06:00

CppCon 2017: Juan Pedro Bolivar Puente “Postmodern immutable data structures”

CppCon
31K views • 9 years ago