Skip to content
Tech News
← Back to articles

The hidden compile-time cost of C++26 reflection

read original get Code Generation → more articles

I am very excited about C++26 reflection.

I am also obsessed by having my code compile as quickly as possible. Fast compilation times are extremely valuable to keep iteration times low, productivity and motivation high, and to quickly see the impact of your changes.

With time and experience, I’ve realized that C++ can be an extremely fast-to-compile language. Language features like templates are not the issue – the Standard Library is.

My fork of SFML uses almost no Standard Library at all, and I can recompile the entire thing from scratch in ~4.3s. That’s around ~900 TUs, including external dependencies, tests, and examples. Incremental builds are, for all intents and purposes, instantaneous. I love it.

I would love to live in a world where C++26 reflection is purely a lightweight language feature, however that ship has sailed (thank you, Jonathan Müller, for trying).

In this article, I’ll try to provide some early expectations about the compile-time impact of C++26 reflection.

let’s measure!

I found a nice Docker image containing GCC 16, the first version that supports reflection, and got to work. To get reasonably stable measurements, I used the hyperfine command-line benchmarking tool.

These are my specs:

CPU: 13th Gen Intel Core i9-13900K

... continue reading