Hacker News new | ask | show | jobs
by crubier 90 days ago
In my experience Rust typically makes it a little bit harder to write the most efficient algo actually.
2 comments

That’s usually ok bc in most code your N is small and compiler optimizations dominate.
Would you be willing to give an example of this?
Not 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.

Has no one written a python! macro for this use case?
Mutating tree structures tends to be a fiddle (especially if you want parent pointers).