Julien Jorge's Personal Website

Notes on "Contemporary C++ in Action"

Wed Dec 21, 2022

I recently watched “Contemporary C++ in Action” by Daniela Engert, recorded at Meeting C++ 2022. This post is a summary of the notes I took while watching.

This was a nice talk with some great examples of the most trending features from the recent years.

First of all I appreciate the use of the term “contemporary C++” where most communications would have used “modern C++”, the latter having lost its meaning with every iteration of the standard since 11 IMHO.

So the idea is to implement a non-trivial program using everything available in C++ up to 23, and some third-party libraries (namely SDL, asio, libav). The program has two parts: a server scanning a directory for animated GIFs and sending the frames to the clients, and a client listening to a server and displaying the received frames.

The host goes into every step, explaining the code in detail, which is great. Amongst the used C++ features there are many ranges, generators, coroutines, and executors. If this is your kind of stuff, I think you will like this talk. There is also a c_resource wrapper type that picked my curiosity, to turn C-libraries’ structures (with factory functions and destruction functions) into C++ value types.

There are also a few slides about modules in the end. The program is actually implemented using modules. Then the author compares the compilation times when using an include directive of the whole standard library versus an import of the whole standard library. The former took 2 seconds while the latter took 15 ms.!

The talk concludes with a demo of the program.

While the content of the talk is great, it describes a way to program that I find very inefficient in terms of communicating the intent to other developers.

First of all I wonder if those advocating for the almost always auto style actually read code from other developers, and by that I mean code not based on their own. It is easy to follow a code path in a program written by self or derived from such, but when you pick a random code and the outline you get on a first read is “there is a thing returning something which is then stored as something else and processed into a thing. Also: thing.” then there is a problem with the coding style.

I personally got lost in the coroutines parts. I see the idea, I think I understand the basic concepts, yet I am still not excited. Why should I use coroutines here? What are the alternatives? What are the benefits? How is it a good idea to jump out of the loop, lose context, and do stuff in the caller?

Still not convinced by the ranges library too. All I see is just another way to write algorithms, not necessarily better, just different.

In the end, I would recommend to watch this talk to get an idea of the bleeding-edge features available in C++ up to the next iteration of the standard. This is a great talk at its core.