4 ms·
In my experience Rust typically makes it a little bit harder to write the most efficient algo actually.
by crubier 7mo ago
In my experience Rust typically makes it a little bit harder to write the most efficient algo actually.
- catlifeonmars 7mo agoThat’s usually ok bc in most code your N is small and compiler optimizations dominate.
- Defletter 7mo agoWould you be willing to give an example of this?
- lukeweston1234 7mo agoNot OP, but one example where it is a bit harder to do something in Rust that in C, C++, Zig, etc. is mutability on disjoint slices of an array. Rust offers a few utilities, like chunks_by, split_at, etc. but for certain data structures and algorithms it can be a bit annoying. It's also worth noting that unsafe Rust != C, and you are still battling these rules. With enough experience you gain an understanding of these patterns and it goes away, and you also have these realy solid tools like Miri for finding undefined behavior, but it can be a bit of a hastle.
- catlifeonmars 7mo agoHas no one written a python! macro for this use case?
- foldr 7mo agoMutating tree structures tends to be a fiddle (especially if you want parent pointers).