Jump Trading dev wants a new C++ feature in an area Rust has the edge
Rust and C++ each have distinct areas where one beats the other; the former is seen as much safer, while the latter is often seen as faster. There are plenty of characteristics that are up for grabs, however, and one Jump Trading developer is proposing a new feature for C++ to compete with Rust on autonomous code generation.
Click here to follow our new WhatsApp channel, and get instant news updates straight to your phone 📱
Barry Revzin, a 10-year alum of the high-frequency trading firm and member of the C++ standards committee, is proposing that C++ introduce reflection, "a really transformative language feature", in C++26. Essentially, this is a collection of features that allows code to look back on itself, so that it can adapt and rewrite its code with greater understanding.
C++ does have some code generation facilities - C macros - but Revzin calls them "very poor and primitive." He says implementing them effectively can be convoluted and requires "true wizardry." In contrast, he finds Rust's declarative and procedural macros a more "mature" alternative, but Rust also currently lacks introspective facilities.
The closest thing Rust has to introspection is its 'derive' macro. This "takes a token stream of the struct that it annotates and [returns] a token stream of code to inject after the input." It sidesteps introspection but has a limited number of use cases.
The benefits of automated code generation are all about saving time and energy for coders. In many cases, the code automated is "not especially complicated", but it saves coders writing excessive lines for what could otherwise be done in "not even one full line of code."
You can click here to see P2996, a 23,000-word proposal breaking down how reflection can be implemented, co-authored by Revzin.
Have a confidential story, tip, or comment you’d like to share? Contact: Telegram: @AlexMcMurray, WhatsApp: (+1 269 237 3950). Click here to fill in our anonymous form, or email editortips@efinancialcareers.com.
Bear with us if you leave a comment at the bottom of this article: all our comments are moderated by human beings. Sometimes these humans might be asleep, or away from their desks, so it may take a while for your comment to appear. Eventually it will – unless it’s offensive or libelous (in which case it won’t.)