| ▲ | LoganDark an hour ago | ||||||||||||||||
Zig comptime feels easier and more effective in practice. I've had some fun const evaluating some stuff in Rust, but I needed to use a bunch of annoying imperative hacks because so much of the functional stuff wasn't supported in const context back then. It's probably a bit better these days. For one of my crates I needed to have a build script make a bunch of lookup tables as separate files for me to `include_bytes!` because at the time I couldn't generate a bunch of floating point conversions in const. | |||||||||||||||||
| ▲ | tialaramex 20 minutes ago | parent | next [-] | ||||||||||||||||
Certainly every new Rust release tends to have either new things which were stabilized as const on day one, or things which already existed but now have stable const. The biggest constraint today on Rust's constant evaluation compared to where you'd expect is that trait implementations can't ever be constant, this obviously means you can't call SomeTrait::function in your constant, even if you can see the implementation of SomeTrait::function and if it were not a trait it'd obviously be constant -- but it also means sugar like Rust's for loop, which de-sugars into trait invocations, can never be constant today. I think we can expect that to get fixed in the relatively near future, but I'd have said that last year too so what do I know. If you have C++ experience you'd probably want a lot more. C++ is allowed to allocate inside constant evaluation, and I believe in C++ 26 it's now even allowed to persist the allocation to runtime rather than being required to always clean up during compilation, so that's a much bigger set of crazy things you can do at compile time. | |||||||||||||||||
| |||||||||||||||||
| ▲ | vlovich123 38 minutes ago | parent | prev [-] | ||||||||||||||||
There’s a few comptime crates out there. Crabtime is iirc the most mature and popular | |||||||||||||||||
| |||||||||||||||||