Rust vs C/C++ Performance
The cluster discusses performance comparisons between Rust and C/C++, focusing on compiler optimizations enabled by Rust's aliasing rules and memory safety guarantees, debates on whether Rust matches or exceeds C/C++ speeds, and specific code examples.
Activity Over Time
Top Contributors
Keywords
Sample Comments
Thanks for trying this out! It's the same with Rust: https://godbolt.org/z/89z9rEz9a
The rust compiler provide huge guaranties no other provide, like for memory safety. This has a performance impact.
When is C++ higher-performance than Rust?
What features of Rust let you write faster code than C/C++/Fortran?
That just means the compiler needs more work around generating optimal code. Rust has some similar idioms and does much better, with the difference between "C-like" Rust and idiomatic Rust usually being small to nonexistent. With Rust you can still sometimes hit edge cases though where the compiler spits out slow code for some idiom that should be zero cost.
Can you say more on this? What is Rust doing differently here that simplifies things?
I think the rust compiler kind of does this: https://mobile.twitter.com/hmemcpy/status/115189096847766732...
If you don't write it in Rust, it's compiler won't optimize anything, will it?
Can you name particular areas in which C allows you to get the performance that Rust does not? Be specific.
No, it’s saying that you can do clever memory optimizations that the Rust compiler won’t let you do.