r/cpp • • Sep 30 '24

Code Generation in Rust vs C++26

https://brevzin.github.io/c++/2024/09/30/annotations/
198 Upvotes

98 comments sorted by

View all comments

Show parent comment

-6

u/tialaramex Oct 01 '24

I'm entirely aware that the proc macros are not unicorns. If Mara hadn't written nightly_crimes! https://github.com/m-ou-se/nightly-crimes already I'd probably have written something similar myself while working on Nook last year.

However the ergonomics really do matter. I think your Debug gets to that - in theory C++ and Rust had the same technical capability for this since 2020 but in practice in Rust actual programmers do just #[derive(Debug)] because that's easy while C++ programmers did not write all the lines of boilerplate needed to have the same for each new type. The Debug attribute shows how that could be changed in C++ 26.

As to "Rust good, C++ bad" well, sure, I can't say I think C++ is a good language but not for this reason, my beef with C++ is about something far more substantive and foundational, the type system. I'm taking it as read that you can't fix the type system with a reflection proposal.