A CppCon talk by Daniel Lemire and Francisco Geiman Thiesen covering how C++26 compile-time reflection was used in the simdjson library to achieve automatic, boilerplate-free JSON serialization and deserialization. The talk demonstrates that manually writing serialization code for every struct field is error-prone and tedious, and shows how reflection allows a single `to_json`/`from_json` call to handle arbitrary user-defined types and STL containers. Three key serialization optimizations are analyzed via ablation study: consteval field-name precomputation (the biggest win, doubling throughput to 3.6 GB/s), SIMD-accelerated string escaping, and fast integer serialization. The result outperforms Rust's serde (~2 GB/s) and is 14x faster than nlohmann/json on an Apple M3 Max. Compile-time overhead of enabling reflection is only ~6%. The talk also covers C++ concepts used to generically handle containers, customization points via tag_invoke, and the learning curve of the experimental Clang P2996 reflection branch.

1h 8m watch time
1 Comment

Sort: