Events

CppCon 2021 trip report

Hello everyone, my name is Timur Doumler (@timur_audio on Twitter), and I have just joined JetBrains as Developer Advocate for C++ tools, including the CLion IDE. I have actually worked at JetBrains as a software engineer in the past, working on CLion’s C++ parser. Apart from that, I have been active as a C++ developer on various projects in the audio and music technology industry (most recently, I co-founded the startup Cradle), as a conference speaker, and as an active member of the ISO C++ standard committee. I am very excited to be re-joining the JetBrains team, and I’m looking forward to engaging with the C++ community in this new and exciting role!

CppCon 2021 was my first in-person conference since the pre-pandemic C++ Siberia in February 2020. After such a long time without any face-to-face meetings, it was a very memorable and rewarding experience. Due to the current US travel restrictions, sadly, the rest of the team could not make it, so for the first time in ages there was no JetBrains booth. I had to jump through quite a few hoops myself to be able to travel to the US, but it was most certainly worth it!

The actual conference experience was not significantly impacted by the Covid pandemic, apart from the fact that only about 260 attendees were on site. In the end, it felt like a good size: it was big enough to be an engaging conference with four tracks of high-quality on-site content, and at the same time small enough that you could get to talk to everyone who was there (a hopeless endeavor at a “normal” CppCon with over 1500 attendees). A few attendees were wearing face masks, and the seats were a bit more spaced out (which I enjoyed because you didn’t have to squeeze past dozens of people in order to find a seat), but other than that it felt very much like a normal C++ conference. After 1.5 years of online-only events, I cannot even begin to describe how great it felt to mingle with real people again!

CppCon lecture

I should mention that CppCon 2021 was a hybrid conference with an online component as well (which in fact had both more speakers and more attendees than the on-site event). However, I did not have a chance to engage with the online bits, as the on-site event was pretty intense, so I won’t comment on them here.

Watch the keynote recordings

Day one

The conference opened with a motivating keynote from Bjarne Stroustrup about the ongoing evolution of the C++ language, followed by a very interesting talk by Jason Turner called “Your new mental model of constexpr”. Jason argued that we should be moving more and more code from runtime to compile time by constexpr-ifying all our functions, and gave examples of code that you can successfully move to compile time even if it seems impractical or impossible at first glance. Performance is not the only benefit here. The interesting thing is that by running your constexpr-ified code at compile time, you eliminate undefined behavior: the code is running inside the compiler, which effectively acts as a C++ interpreter. Everything that, at runtime, would result in undefined behavior (say, accessing a dangling reference) will be caught by this “interpreter” and emitted as compile errors. Jason’s talk took a hilarious turn when he revealed in the middle of the talk that the slide presentation he was showing was itself a binary generated from constexpr-ified C++ code at compile time, and running inside a Commodore 64 emulator.

In the afternoon, I attended David Stone’s talk “Implementing static_vector”. A static_vector is a vector-like container with a capacity fixed at compile time, which holds all its data on the stack inside the object itself. This eliminates the need for dynamic memory allocations and is also very cache-friendly, making this data structure ideal for low-latency applications such as video games, audio processing, and high-frequency trading. While this data structure is widely used, it is surprisingly difficult to implement correctly without violating the object lifetime rules of the C++ standard. These are common problems with such library facilities, and are encountered even when implementing std::vector itself. Because of this, David’s talk will be useful to many developers implementing generic libraries in modern C++.

Day one concluded with the traditional C++ Committee Fireside Chat panel, this year featuring Bjarne Stroustrup, Lisa Lippincott, Gabriel Dos Reis, David Stone, Michael Wong, and Inbal Levi, with Herb Sutter moderating. Many interesting questions were asked. One of the most interesting discussions revolved around the ongoing work on C++23, the next standard, which is quickly approaching its feature freeze date. Compared with the large scope of C++20, C++23 is going to be a smaller bugfix release, and is mainly targeted at completing C++20 with things like standard library support for coroutines and modules, rather than introducing large new language features. The panellists talked a lot about how difficult it is for the committee to adjust to having to work remotely via telecons, as opposed to week-long face-to-face meetings, and how having to work remotely significantly hinders our ability to standardize larger, more complex features. As a C++ committee member myself, I couldn’t agree more with that assessment. I can’t wait until the committee can meet in person again, although this will happen in July 2022 at the earliest, after the feature freeze date of C++23, meaning that all C++23 features will have been developed entirely remotely.

Day two

Tuesday’s plenary session was a talk by Herb Sutter, presenting the way he imagines pattern matching to be added to C++ and how it fits into his larger vision for making the C++ language easier to learn and safer to use. His proposed pattern matching syntax (P2392) uses the new keywords is and as. While it’s too early to know whether or not the C++ committee will approve such syntax (the original pattern matching proposal P1371 does not use it), pattern matching is in my opinion the most exciting and useful new core language feature currently working its way through the C++ committee, and Herb’s solution is certainly very elegant and carefully designed. Even if we end up with a different syntax for pattern matching, I still highly recommend watching this talk: there are a lot of lessons to be learned about language design in general. Plus, Sean Baxter, the author of the Circle compiler (which implements Herb’s proposal) makes a cameo appearance and shows just what his C++ frontend can do.

Other talks I attended today include David Stone’s “Faster, Easier and Simpler Vectors”, building from his earlier talk “Implementic static_vector” and generalising to other interesting variants of std::vector-like data structures, and Ben Deane’s “Composable C++: Principles and Patterns”, a talk with some interesting thoughts about API design in general and the eternal tension between object-oriented and functional programming.

But the most engaging part of today was the so-called “hallway track”, that is, ad-hoc conversations with other attendees in between sessions. It was obvious that everyone on site really enjoyed mingling and socializing after such a long period of being stuck in our homes. I ended up having quite a few conversations about CLion, since I was effectively a walking one-person JetBrains booth: from positive feedback and bug reports from existing users, to curious questions about the latest features, all the way to very specific questions such as whether there is a CLion plugin that lets you view image data during debugging (turns out there is).

Day three

I started my Wednesday with a presentation by Matt Kulukindis from Google, who went into the guts of TCMalloc (Google’s customized implementation of C’s malloc() and C++’s operator new for faster multithreaded memory allocations) in order to replace some of the locking algorithms in there with a lock-free multi-producer multi-consumer queue. Having worked on audio and music production software for many years, where lock-free queues are a ubiquitous and crucial data structure, I was curious how the folks at Google approach such problems. I certainly learned a few new tricks, including how to measure performance of such a queue and how to find race conditions using tooling.

However, the highlight of the day was the talk “‘Deducing this‘ Patterns” by Ben Deane. This was one of my favorite talks of the entire conference (surpassed only by Daisy Hollman’s talk, see below) and I recommend it to everyone who plans to use C++23 after it comes out. “Deducing this” is a new language feature that has already been approved for C++23 by the committee. It is basically a syntax for specifying or deducing the value category (whether it’s an lvalue or rvalue, const, a reference, rvalue reference, etc.) and the full type of the this object that a member-function is invoked on. While I was already familiar with the syntax of “Deducing this“ and had a rough understanding of how the feature works mechanically (we had many discussions on this feature on the C++ committee), I had no idea how many interesting new design patterns this feature enables. The bit I was already aware of is that we can get rid of a lot of duplicated code as we don’t have to implement different flavours (const&, &&, etc.) of the same member function, but we can express it as a template instead. However, I also learned that CRTP (the Curiously Recurring Template Pattern) is now basically obsolete, as “Deducing this“ enables a much easier way to express the same thing. And if that wasn’t enough, we can now finally spell recursive lambdas in C++ (which isn’t even difficult). This is the hallmark of a great new language feature: it solves multiple seemingly unrelated problems at once, and at the end we don’t know how we ever lived without it. This feature alone should be enough reason to get really excited about C++23!

In the evening, I attended the MLOC (Million Lines of Code) Group Community Party, which was another great opportunity to socialize, grab some drinks, and talk about C++ with everyone who made it to CppCon in person.

Day four

Thursday was full of well-known C++ speakers who all made it to CppCon in person. The morning started with a presentation by Andrei Alexandrescu about variant types, of course delivered in his inimitable presentation style. It was followed by a plenary session by Michael Caisse, who reminded us to inspire and be inspired, and told us the story of his career and some interesting glimpses from the life of an embedded developer. Finally, I watched John Lakos talk about using noexcept operators and specifiers safely, promote his new book “Large-Scale C++ Volume I”, and pull off the impossible feat of talking three times as fast as all the other speakers while still delivering a talk that I could follow and that I quite enjoyed.

After the talks, I went to the Meet the Presenters Banquet, which was amazing as usual, followed by a very entertaining lightning talk session where I learned what C++ object lifetime rules have to do with quantum dynamics, and how to use emojis in your C++ code, among other things. I also delivered a lightning talk myself – my first one in over two years! – which I had spontaneously agreed to give and prepared just a few hours prior, showing some code snippets about how C++20 made initialization even more confusing than before.

Day five

On the morning of the last day of CppCon 2021, I presented my own new talk, “Real-time programming with the C++ standard library”. I gave an overview of which parts of the standard library are useable in low-latency and real-time contexts, which are better avoided because they might try to do things like allocating memory or acquiring a lock, and how to squint at the standard in a way that allows you to figure out which category a given standard utility belongs to. The great thing about talking on Friday is that you have the whole week to ask experts on-site questions about the material while preparing it, and the great thing about CppCon (even in pandemic times) is that many of the relevant proposal authors, standard library implementers, and compiler engineers are right there and usually happy to help with figuring things out!

Having delivered my own talk, I went to see Walter E. Brown’s “Correctly Calculating min, max, and More: What Can Go Wrong?” (turns out, a lot! I highly recommend this talk). This was followed by my personal favorite talk of the whole conference: Daisy Hollman’s “What You Can Learn from Being Too Cute”. Her examples of using modern C++ features in creative and surprising ways were as fascinating as they were entertaining, and through her mind-blowing C++ tricks I learned a lot about the language that I didn’t know previously. Did you know that you can throw an exception from inside a local static initializer in order to ensure that a certain function is only called exactly N times during the lifetime of a C++ program? No? Then this talk is for you. Among other things, Daisy also discovered a gaping hole in a C++20 feature that I have authored, CTAD for aggregate types: it turns out that the mechanism that makes CTAD work with aggregate types falls apart completely in the presence of designated initializers, a new syntax for aggregate initialization that was also adopted in C++20. I’m now working on a defect report. Thank you, Daisy!

While I was still pondering on everything I had seen in Daisy’s talk, I went to listen to Jeff Garland give a very useful overview over all the standard library features that are currently slated for inclusion in C++23. And then it was already time for the closing keynote by Sean Parent. I am not going to spoil too much about that one, except that I did know std::move doesn’t move, and std::remove doesn’t remove, but I was completely unprepared for the revelation that std::find doesn’t find.

CppCon rooms

In the end, CppCon 2021 was one of the most enjoyable and memorable C++ conference experiences of my career so far. I would like to congratulate the organizers and give them a huge thank you for all their work. Against all odds, and notwithstanding a global pandemic and international travel bans, they have pulled off something amazing.

Hopefully, next year the JetBrains team will be back at CppCon in full strength!

Watch the keynote recordings

image description