Dvir Yitzchaki · linkedin.com

Introduction

Recently I attended the CppCon C++ conference in Aurora, Colorado, USA. This is the main C++ conference which has been held annually since 2014 (going online during covid), starting at Bellevue, Washington and moving to a bigger venue in Aurora in 2019.

The magnificent venue (Photos take by me unless noted)

The main program runs for 5 days, Monday to Friday, and there are workshops pre and post the conference. Every day is fully packed, starting as early as 8 am and ending at 10 pm. This year there were seven dedicated topic tracks: Back to Basics, Embedded, the Robotics, Scientific Computing, Software Design, Tooling, and a (new addition this year) GameDev track. However, as the conference chair Jon Kalb wrote to all the attendees, “CppCon can be overwhelming and will exhaust you if your plan is to attend everything. By design we have more than can humanly be done. Pace yourself, prioritize, and set reasonable expectations.”

The conference started Sunday evening with registration and a reception with drinks, food and even a magician. More entertainment was supplied during the conference by a live band playing between talks (check them out at jimbasnightmusic.com).

Day 1

Peering forward — C++’s next decade - Herb Sutter

The conference started with a Keynote by the head of the C++ standard committee and renowned author, Herb Sutter. The talk focused on two subjects which look to dominate the C++ development in the following years: safety and reflection.

There were several reports from parts of the US government (e.g. NIST and NSA) that called for moving away from C++ towards safer programming languages like Rust. Those reports made large waves across the C++ community and there are several attempts to make C++ safer currently in progress. This is not an entirely new direction for C++, as features like smart pointers which prevent many memory errors were already part of the 2011 standard. The next standard, C++26, will include a change that makes reading uninitialized variables a defined behavior which will be easier to detect by static and dynamic analyzers. Longer term, there is a proposal to add safety profiles which will limit the code to use only safe constructs, but this feature is still in its early stages.

Reflection, which is the ability to programmatically query other parts of the code (like getting the name and type of all members of a class) and generate more code based on that, is looking on track to be included in C++26 (at least the querying part). This was the most popular topic in this year’s conference with many of the talks focusing on it and others mentioning it in one way or another. Herb shared an example of writing a command line parser using reflection which is already working in compiler explorer.

Herb is also implementing his own C++ successor language called Cpp2 which he calls a “typescript for C++” because it compiles down to C++ the same way that typescript is compiled to javascript, enabling gradual migration of existing code and easy interoperability with the ecosystem. Herb showed how his new language already incorporates some of the safety features.

The talk is already available in YouTube.

Unit Testing - Dave Steffen

This was part of the Back-to-Basics track. Those sessions target junior developers but there is always something new to learn, especially for an important subject like testing.

Dave thesis is that a good test is like a science experiment: it starts with a falsifiable hypothesis (that the code works as intended) and should be repeatable (by you), replicable (by others), accurate (no false positives), precise (informative), etc.

The most important thing, though, is to write tests, which not all developers always do unfortunately. Those tests can always be improved later.

Common Package Specification (CPS) in practice: A full round-trip implementation in Conan C++ package manager - Diego Rodrigez Losada

Diego is one of the founders of the Conan package manager. In this talk he shared the progress of a project to have a common package specification (CPS, docs) that will enable different package managers and build systems to interoperate and consume packages regardless of their source.

Diego showed how to use CPS right now with Conan and CMake and what are the problems with the current specification.

The Most Important Design Guideline is Testability - Jody Hagins

Another talk about the importance of tests. Most of the talk was dedicated to the “Knight Capital Disaster” (wikipedia) where a trading company lost 440 million dollars in less than an hour due to a software bug and how proper testing could prevent that in multiple ways.

I was a bit disappointed with this talk, to be honest, because there was not much design content despite the title and the fact it was part of the Software Design track.

Work Contracts – Rethinking Task Based Concurrency and Parallelism for Low Latency C++ - Michael Maniscalco

I held many hopes from this talk as it seemed relevant to my work on Roku OS which has a lot of concurrency and task queues. The presenter shared his novel project of replacing multi-producer multi-consumer task queues with a lock free tree like structure of tasks which he calls “work contracts”, thereby reducing contention on the queue entry and exit nodes.

Photo by Chris Ryan

The benchmarks shared during the presentation look impressive, but looking at the project in github, shows it is only published recently and does not contain any documentation or tests, so it remains to be seen if this indeed works in production.

Safety and Security Panel - Michael Wong • Andreas Weis • Gabriel Dos Reis • Herb Sutter • Lisa Lippincott • Timur Doumler

The first day closed with this panel of senior members of the C++ standard committee discussing the hot issue of writing safe and secure code in C++. As is customary in such panels, the crowd was invited to “grill” the panel and there were many interesting questions (including one from yours truly about adopting Rust’s borrow checker to C++) and I highly recommend watching this when it goes online.

Day 2

C++ Exceptions for Smaller Firmware - Khalil Estell

The second keynote of the conference was one of the best presentations I saw recently. For years it was a common opinion that C++ exceptions do not feet embedded or low latency applications because of the time and space overhead they add and indeed that is often the case with current implementations. Khalil had this belief too and taught his students to use other error reporting options like std::expected but they kept avoiding it claiming it is too complicated and bloats their code with error checking.

That prompted Khalil to start investigating what is it that makes exceptions heavy and found out he can reduce around 90% of the overhead by removing unneeded info like RTTI and using a pre-allocated buffer instead of allocating exception data on every throw to the point exceptions take less space than the alternatives and are much faster than current implementations.

A must watch, in my opinion, and luckily already available on YouTube.

More C++ oddments - Ben Deane

This was an “open content” session, held during lunch break. These talks are not part of the main program which anyone can present if there is a free slot, however they are not recorded. Ben is one of my favorite presenters and in this session, he showed some cool things you can do with recent language features which one should not generally use in production code today but might become useful in the future.

Shared Libraries and Where to Find Them - Luis Caro Campos

Another presenter from the Conan package manager team, Luis gave a thorough description of how to properly link shared libraries at build and run time, across Linux, MacOS and Linux.

Photo by Tyler Weaver

There were some useful tips in this session, like setting LD_DEBUG=libs environment variable to get the Linux library loader to emit information about the libraries it loads.

Compile-time Validation - Alon Wolf

An Israeli colleague, Alon presented his library Mitzi (named after his late cat), that tries to bring safety to C++ as a library instead of a language feature, thus enabling writing safer code using today’s toolchains instead of waiting for the language to catch up.

Although impressive, it does require writing the code in a completely separate way than how C++ is usually written, which makes me wonder about using it in production.

Day 3

Building Cppcheck - What We Learned from 17 Years of Development - Daniel Marjamäki

Daniel is the person behind the Cppcheck static analyzer and in this session, he talked about the development process, starting as a hobby project and turning into a full-time job as a company with enterprise customers.

A couple of take outs for me are that it’s OK to have bad design decisions occasionally, if you are flexible enough to revert them and that one should not insist on educating one’s users but listen to their opinions more.

It would be great to also learn about the implementation of the analyzer and the trade-offs it makes to have acceptable runtimes and reduce false diagnostics, but that was left for another presentation.

Embracing an Adversarial Mindset for C++ Security - Amanda Rousseau

The keynote of the day returned to the safety and security subject. Amanda is a security researcher from Microsoft and showed how to think about security when designing software and identify attack surfaces. She also shared a few tools, some of them specific to the Microsoft ecosystem, that can help detect and mitigate vulnerabilities.

This talk is also already on YouTube and I recommend watching it.

Designing a Slimmer Vector of Variants - Christopher Fretz

Christopher showed how he managed to significantly reduce the memory overhead of using a vector of variants which is a common pattern used for holding different objects in a container without memory allocations and virtual functions.

The presenter implemented his own container and showed the different iterations his design went through, the trade offs he had to make and the open problems his solution still has.

I really enjoyed this talk because it showed a practical and down to earth software engineering which is applicable to anyone regardless if they have the specific problem this solution solved.

The Beman Project: Bringing Standard Libraries to the Next Level - David Sankel

David presented this new project, named after Boost co-founder Beman Dawes, to implement standard library proposals in order to gain experience before setting them in stone, hopefully avoiding issues like the bad performance of std::regex that makes it unusable on performance sensitive programs.

Photo by Sakshi Verma

The project, which can be found on GitHub, is led by distinguished boost contributors but David stressed that anyone could contribute libraries and they offer support for implementers.

Reflection Is Not Contemplation - Andrei Alexandrescu

Back to reflection, Andrei’s talk focused on the code generation part. He shared the design of the current leading proposal to generate code using reflection, P3157 , and how it will enable writing regular C++ code with better error reporting as opposed to other proposals.

Andrei is one the best presenters in the C++ (and D) world and this talk didn’t disappoint. Be sure to catch it when it goes online.

Lightning talks

The day closed with a dozen or so 5-minute talks hosted by Phil Nash, the creator of the popular Catch2 framework and a funny person in general. Unlike other conferences I’ve been to the talks were more serious and less “light” with some being just advertisements in disguise, which was quite disappointing.

Day 4

Performance engineering - being friendly to your hardware - Ignas Bagdonas

This talk stressed the fact that to gain performance one should know their hardware deeply. Ignas gave an overview of modern PC hardware, how it executes our code and what to focus on when improving run times.

When Nanoseconds Matter: Ultrafast Trading Systems in C++ - David Gross

This keynote showed lessons learned from the presenter’s work in low-latency trading. My key take aways were to avoid node based containers (like std:map) if possible, that understanding the data your program processes is crucial for optimization and that hand tailored algorithms are key to achieve performance.

As the other keynotes, this talk is also available in YouTube already.

Sender Patterns to Wrangle Concurrency in Embedded Devices - Michael Caisse

Another big feature that is expected to land in C++26 is executors AKA senders/receivers which should be the foundation of asynchronous programming in C++ including the long-awaited networking support. Michael shared the library he and his Intel colleagues developed, called “C++ Bare Metal Senders and Receivers” (github) which targets embedded devices by having no memory allocations and no exceptions (maybe that will change after Kalil Estell’s keynote).

An interesting part of the talk was devoted to how their library improves the debug story, which is infamously hard with asynchronous code, by writing a python script which integrates with gdb to visualize the call graph and state of all the senders in a system.

What’s new for Visual Studio Code: Performance, GitHub Copilot, and CMake Enhancements - Alexandra Kemper & Sinem Akinci

As an avid VSCode user, I was looking forward to this talk but unfortunately almost half of it was devoted to the hot topic of the day, i.e. AI and copilot, which is nice but not very C++ specific and another big portion to CMake which is irrelevant to anyone not using this build system.

It was nice seeing some performance improvements though and copilot can indeed boost productivity.

Monadic Operations in Modern C++: A Practical Approach - Vitaly Fanaskov

C++23 added std::expected and with it an interface called monadic operations (e.g. and_then() and or_else () functions) which supports more functional style of error checking. This session started with a more holistic overview of functional programming and its best practices followed by a description of the std::expected and std::optional monadic interface and how to use it effectively.

Some key take aways I took from the presentation are that when introducing functional programming to your code, start changing functions implementation, then function API, then possibly drop classes entirely and that for better readability, one should prefer functions to lambdas, even named lambdas.

Day 5

Template-less Meta-programming - Kris Jusiak

The last day of the conference started with a bang as Kris, which is a prolific meta-programming guru, introduced his meta-programming library simply title MP (github).

This library enables doing meta-programming without (too much) template hackery which is simpler to use, compiles faster and is easier to debug compared to traditional methods.

A highly recommended talk for anyone interested in meta-programming.

Implementing Reflection using the new C++20 Tooling Opportunity: Modules - Maiko Steeman

Yet another reflection talk, Maiko showed how we can have reflection using today’s compilers (assuming our code uses C++20 modules) by parsing the binary module interfaces generated by the compiler when building modules and generating C++ code that can be used to query type information similarly to how a standard reflection library would work.

I wonder if C++20 modules is mature enough to use this technique or it is better to wait for standard reflection. The tool is available in github and currently only supports the Microsoft compiler.

Tools Every C++ Developer Should Know - Jason Turner

Another lunch-time open content talk from a renowned C++ guru (C++ Weekly, cppcast) trying to cover all the tools that can help us write better software like compiler warnings, static and dynamic sanitizers and test frameworks.

Despite being at the last day over lunch time the room was packed with attendees with some standing at the back or sitting on the stage side and the presenter was amusing as always.

Ranges++: Are Output Range Adaptors the Next Iteration of C++ Ranges? - Daisy Hollman

As someone who gave a couple of talks about ranges before I couldn’t miss this talk, given by the current chair of the ranges study group inside the C++ standard committee. Surprisingly, the talk was about the disadvantages of standard ranges (like those Nico Josuttis talked in length about) and how a different model (push based and not pull based) could overcome them.

One significant pitfall of Daisy’s library (github) is that it only processes one element of a range at a time and so is not capable of whole range algorithms like reverse.

This is C++ - Jon Kalb

Jon is the man behind CppCon and a passionate speaker (I highly recommended his podcast cpp.chat which is sadly not active recently). In his talk he defended the design decisions taken by C++, like having undefined behavior as part of the language, despite being criticized as unsafe as the main purpose and strength of C++ is to have uncompromised performance.

Jon gave numerous examples of how attempts to change the language for safety reasons will actually hurt C++ and amusingly made the crowed shout “This is C++” whenever that slide showed up.

Gazing Beyond Reflection for C++26 - Daveed Vandevoorde

Inevitably, the conference ended with the last keynote about reflection. David is one of the main contributors to the standard reflection proposals and implemented most of it himself as part of the EDG compiler. Their implementation is available in compiler explorer for anyone wanting to play with it already (the ubiquitous enum-to-string for example).

This was a summary of all the reflection presentations throughout the conference, including the query and generation parts, but also included more farfetched proposals like reflecting user-defined attributes, for example to omit certain fields from serialization or customizing object dump (example).       

The talk is already available on YouTube.

Outro

I want to thank Roku for allowing me to attend the conference. Unlike previous conferences I attended, I didn’t give a presentation this time which enabled me to focus on learning and enjoy a more relaxed week. I got to know a few new friends and some new ideas I’m eager to try as part of my work.

I will end with a photo of all the attendees. I should be somewhere in the back, 10 points if you can spot me. See you next year.

Read the original on linkedin.com ↗