Hacker News new | ask | show | jobs
by 0x000000E2 1868 days ago
I've heard the anecdote many times that the idiomatic way of writing Rust tends to also be performant. I've spent some time fiddling with C code to reuse buffers and avoid copies, make loops amenable to auto vectorization. Many times my first try in Rust will still be faster. In C reusing memory over and over is dangerous and confusing. In Rust it's the default because you use borrowing and transfer ownership.

My guess is that little time was spent optimizing the C++ and Rust codebase, and Rust performs better because the code doesn't do copies.