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.

➡️ Stable 0.7x Programming Languages
3,382
Comments
16
Years Active
5
Top Authors
#9302
Topic ID

Activity Over Time

2011
1
2012
3
2013
30
2014
95
2015
120
2016
224
2017
245
2018
181
2019
256
2020
283
2021
400
2022
396
2023
354
2024
287
2025
450
2026
57

Keywords

e.g doc.rust TCO lang.org twitter.com NRVO Write.html FORTRAN ABI LLVM rust compiler copy blah aliasing memory blah blah llvm performance heap

Sample Comments

Cyph0n Dec 28, 2023 View on HN

Thanks for trying this out! It's the same with Rust: https://godbolt.org/z/89z9rEz9a

sametmax Feb 16, 2018 View on HN

The rust compiler provide huge guaranties no other provide, like for memory safety. This has a performance impact.

umanwizard Mar 31, 2022 View on HN

When is C++ higher-performance than Rust?

1980phipsi Apr 25, 2024 View on HN

What features of Rust let you write faster code than C/C++/Fortran?

api Sep 1, 2021 View on HN

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.

millstone Feb 22, 2021 View on HN

Can you say more on this? What is Rust doing differently here that simplifies things?

jabbany Aug 20, 2022 View on HN

I think the rust compiler kind of does this: https://mobile.twitter.com/hmemcpy/status/115189096847766732...

tcfhgj Feb 12, 2025 View on HN

If you don't write it in Rust, it's compiler won't optimize anything, will it?

pcwalton Mar 22, 2016 View on HN

Can you name particular areas in which C allows you to get the performance that Rust does not? Be specific.

coddle-hark Nov 9, 2020 View on HN

No, it’s saying that you can do clever memory optimizations that the Rust compiler won’t let you do.