Events

C++Now 2022 Trip Report

From May 1 to May 6, 2022, I attended the C++Now conference in Aspen, Colorado. This was my third time speaking at C++Now (I also attended in 2016 and 2019), and in my opinion it was the best edition of C++Now so far!

Aspen view

This conference is truly different. It is much smaller than other international C++ conferences. Even pre-pandemic, it was capped to a maximum of 160 attendees, and this year, there was only about half that number, probably due to COVID-related travel hesitancy. As always, there was a good mix of well-known C++ experts and first-timers, and the intimate size of the event provided a unique opportunity for the latter to rub shoulders with the former.

The other thing that makes C++Now truly different is the location. The conference is hosted at the Aspen Center for Physics, with lodging at the adjacent Aspen Meadows Resort. It’s situated in a serene mountain landscape in the middle of the Rocky Mountains, surrounded by snowy peaks, a roaring river, and lots of aspen trees with the characteristic “eyes” from which the nearby resort town got its name. In winter, Aspen is a ski resort for the wealthy, and in summer it is a popular hiking destination. During C++Now, however, in between those seasons, it is mostly abandoned. The Bauhaus-inspired architecture and the many abstract art sculptures scattered around create a strange and otherworldly vibe. The surrounding nature is truly stunning, so this year, I brought along my running shoes and enjoyed some nice runs along the Rio Grande Trail throughout the week.

As always, C++Now kicked off on Sunday evening with an informal reception at the resort bar. The official opening followed on Monday morning with Dave Abrahams’ keynote, A Future of Value Semantics and Generic Programming. After taking a long hiatus from C++ and doing a lot of work on Swift, Dave is now back in the C++ world. He delivered an insightful talk about how generic programming is not template metaprogramming and what value semantics actually means, along with covering important concepts like regularity, independence, object and value representations, and how Swift does this differently from C++. I found it particularly interesting that Swift has no copy constructors, copies can never throw (essentially, all Swift types are trivially copyable), and an out-of-memory error is considered non-recoverable. I also found out that Swift is on Godbolt!

The other talk on Monday that stuck with me was Fedor Pikus’ talk about undefined behavior and how it is related to performance. I really appreciated how he talked us through some assembly output and helped us understand what the compiler does. Apart from the usual UB cases (integer overflow, etc.) he showed many other interesting things: how 32-bit unsigned math is slow on 64-bit systems, how global variables impede a lot of optimizations while const enables them, examples of time travel optimizations, and more. Even before this talk, I had read Fedor’s book, The Art of Writing Efficient Programs, and watched several of his other talks – they are very relevant to some of the work I have done on low-latency and lock-free programming. It was really nice to finally meet him in person, and I definitely had a lot of questions. This is what C++Now is really great for – you get a lot of face time with experts for in-depth technical discussions in between the sessions.

In the afternoon, I gave my own talk about how to implement a lock-free atomic shared_ptr, an updated version of the talk I gave last month at ACCU 2022. Here’s another thing that makes C++Now different from all other C++ conferences: speakers get properly grilled by the audience. There are lots of questions, interruptions, and mid-talk discussions. Fortunately, I was already familiar with this so I knew what to expect. I really appreciate this less formal setup, because I usually learn a lot from these discussions, and my talks benefit greatly from the insights of the experts in the audience. The first talk at C++Now can be quite intimidating for that reason, but no matter how heated the technical debates get, everyone is always very polite and friendly.

Tuesday was another day full of great talks. My day started with Lisa Lippincott’s talk, Principia Mathematica: The Foundations of Arithmetic in C++. This one was refreshingly different. In 90 minutes, she not only developed a complete mathematical framework describing integer math in C++, but she also developed her own dialect of C++ (slightly expanded from the standard C++ language) that is powerful enough to express mathematical proofs.

Afterwards, I went to Bill Hoffman’s talk about how CMake is implementing C++20 modules. Given that JetBrains is a C++ tool vendor, we want to support C++20 modules, and CMake is CLion’s default project model, this was obviously a very relevant topic for me. Bill is actually the CTO of Kitware, the company that makes CMake, so it was really great to learn how it all works under the hood directly from the source. The key piece of tech is the JSON-based format for describing dependencies of source files, currently already supported by both MSVC (released) and GCC (on a branch). This allows CMake to query the compiler for the module dependency graph that it needs to figure out how and in what order to compile the modularized C++ source files, instead of doing it themselves (which requires parsing C++).

Finally, I went to David Sankel’s talk, Rust Features that I want in C++. For me, this was the talk of the conference. David started by talking about features like Rust enums, language variants, the very powerful pattern matching facilities, and how work on pattern matching proposals in C++ appears to have stalled. Then, he showed some examples of Rust’s powerful metaprogramming and Rust libraries, like Rocket, built on top of that, which are amazing and unthinkable in today’s C++! My favorite part was when David talked about how Rust was designed around inclusivity and beginner-friendly ergonomics from the start, how those ideas are a core part of the Rust culture, and how it shows in practice through clear and helpful error messages, beginner-friendly APIs, and so on. This sounds very much like a world I’d like to live in! I’m not ready yet to throw in the towel on C++ and switch to Rust (although it is tempting!), but I hope that we can learn from the Rust community and make the C++ experience more inclusive and approachable.

On Wednesday I woke up to find everything covered in snow. One feature of C++Now is that the weather never gets boring – one day you can have a snowstorm so severe that planes cannot land and are forced to turn around, and the next day it’s sunny and baking hot. The conference is set up so that the talks happen indoors, but a lot of the socializing happens outdoors, so it’s important to remember the saying, “There’s no such thing as bad weather – only bad clothes!”

Snow view

Fortunately, I was prepared and I enjoyed another wonderful conference day. I chose to attend another talk about integer arithmetics, this time by Andreas Weis, who went into a lot of detail on how it is actually implemented in hardware. Interestingly, it turns out that with today’s 2’s complement machines, signed integer overflow doesn’t necessarily need to be UB because it is well-defined on the hardware level, but compilers treat it as UB because the optimizations it enables are very dear to us.

After that, I went to a really interesting talk by Michael Caisse about implementing message handling on embedded platforms in modern C++ using a very elegant, declarative approach. This was followed by a session led by Bret Brown and Daniel Ruoso, Searching for Convergence in C++ Package Management. The lack of a universally accepted build system and package manager is one of the biggest pain points of the C++ community, and despite many very smart people trying to solve this problem, we are still not there yet. I wouldn’t say that the approach presented in this session constituted any particular breakthrough (their approach is, at least initially, focused on Linux and pkg-config and therefore not relevant for large parts of the community), but the discussion was certainly very interesting. This issue is especially difficult because build systems and package managers are completely outside of the scope of the ISO C++ standard, which only defines the core language and the standard library, so it’s not even clear what the right platform is to discuss these things. The standard committee has a study group for tooling (SG15), but it is not clear to me yet what exactly this group can do beyond perhaps giving some recommendations.

Besides all of the talks, there was a lot more going on. There were two evening sessions with informal 5-minute lightning talks moderated by Michael Caisse that were full of highly entertaining contributions. There were the hands-on “Library In a Week” coding sessions every morning, led by standard library veterans Marshall Clow and Jeff Garland. We also had sessions regarding conference planning for C++Now 2023, further developing the conference format and organization. Of course, there are all the conversations in between, usually called the “Hallway track”, although here it would be more accurate to call it the “meadows-surrounded-by-snowy-mountains track”. As always, I had many CLion users asking me things. This time, I had conversations about C++ modules, various cool features of the CLion debugger, and CLion’s disassembly view. Unfortunately, it currently only works in situations where the source code is unavailable, but if you’d like that to change you can upvote the appropriate ticket!

On Thursday, Phil Nash did a double session (3 hours in total!) on C++ Coroutines From Scratch. He took an approach I haven’t seen before: he started by talking us through a relatively large real-world C++ example, which he then re-wrote using coroutines. The plumbing and implicit compiler magic that happens to make coroutines work was then explained along the way. I really enjoyed this session. Phil’s material and the technical discussions that happened during the session certainly helped me fill in some remaining blanks about how C++20 coroutines work. At the same time, I do not think that someone who has never heard about C++20 coroutines before would have grasped them from this talk alone, and that’s true for every other coroutine talk I have heard so far. There is something about them that makes the learning curve especially steep. If you want to get into C++20 coroutines by watching talks, I recommend watching multiple talks approaching it from different angles. Start with Adi Shavit’s Generators, Coroutines and Other Brain Unrolling Sweetness and the coroutines section of my own How C++20 Changes The Way We Write Code for a high-level introduction, then watch Pavel Novikov’s Understanding Coroutines by Example to dive deeper, and finish off with Andreas Weis’ coroutines talk from ACCU 2022 and this talk by Phil Nash (we’re waiting for videos of those to be released!) to see more use cases. After having seen all these coroutine introduction talks, I feel very tempted to prepare a more in-depth coroutine tutorial myself!

The other session I visited on Thursday was Sean Parent’s Exception Handling the Other Way Around, which was full of good stuff: a nice refresher on preconditions, postconditions, and invariants, a very interesting definition of “safe” code, a discussion on contracts, and useful guidelines on how to write code that is exception-safe by default.

Friday was a short day for me. In the morning, I attended a talk by Eduardo Madrid, where I learned about cache-friendly binary search, Robin Hood hashmaps, the SWAR trick, and lots of other techniques to squeeze maximum performance out of associative data structures. And then there was Sean Baxter’s closing keynote about Circle and how it makes metaprogramming much better and more elegant… except that sadly, I had to miss the whole keynote, because there was a C++ committee teleconference going on at the same time. Three of my own proposals (P1774, P1839, and P2582) had to go through a round of Core wording review that I could not postpone, as the deadline to get wording for any new features into the C++23 working draft is only two months away.

Friday afternoon was quiet as always, with no talks happening. People went for a hike in the mountains, a workout in the gym, or simply to relax in the sun. I went for a 10-mile run along the Roaring Fork River, followed by a visit to the Aspen Meadows Resort’s heated outdoor pool, my favorite place in Aspen for enjoying a view of the stunning snowy mountain peaks. Unsurprisingly, I was not the only C++Now attendee who opted for the pool, so the conversations about C++, CLion, the Universe, and Everything continued there.

And then it was already time to say goodbye and go home. As always, C++Now was such a great experience that I was sad to leave. I hope to be back next year! I strongly recommend attending this special conference at least once to anyone interested in modern C++. It is a truly unique experience.

image description