3 ms·
Rust is beyond even current C++ with respect to compile time code.
by banachtarski 7y ago
Rust is beyond even current C++ with respect to compile time code.
- comex 7y agoSort of. Rust procedural macros are powerful, but they’re basically glorified code generation: they take a list of tokens as input and return a list of tokens as output. They don’t have access to type information. For that you need to use a combination of the trait system and `const fn`, to which the C++ equivalent is templates and `constexpr`. But C++ `constexpr` is currently way ahead of Rust `const fn` in functionality. And while Rust’s trait system tends to be nicer than C++’s templates for most purposes, it’s not as good at performing arbitrary computations. Overall, when I use either language I find myself badly missing features from the other. I look forward to seeing both close the gap…