Here are the 4 most prevalent themes from the discussion.
1. The Question is Ill-Defined
A recurring theme is that a generic speed comparison between languages is meaningless without defining specific contexts, such as the compiler, the type of code, and the metrics for "fast" (development time vs. execution time).
"the question is malformed, you need to first state what the boundaries are before you can make any conclusions." β steveklabnik
"I think that there are so many variables that it is difficult to draw generalized conclusions." β senko
2. Aliasing and Optimization Opportunities
Many users debated whether Rust's stricter aliasing rules (which are similar to C++'s but enforced by the type system) provide a tangible performance advantage over C.
"Rust should have even more opportunities of this due to restrictions it has for writable references." β Karliss
"I believe this advantage is currently mostly theoretical, as the code ultimately gets compiled with LLVM which does not fully utilize all the additional optimization opportunities." β Tuna-Fish
3. Ease of Parallelism and Correctness
Several comments highlighted that Rust's safety guarantees make it much easier to write parallelized code correctly, potentially leading to faster execution in practice compared to C where concurrency is often avoided due to complexity and risk.
"Mozilla tried to parallelize Firefoxβs style layout twice in C++, and both times the project failed. The multithreading was too tricky to get right." β classified
"In Rust, whether you use threads or not, all globals must be thread-safe, and the borrow checker requires memory access to be shared XOR mutable... In C, the cost/benefit analysis is different." β pornel
4. Compile-Time Abstractions vs. Runtime Overhead
The discussion touched on how language features influence performance. Rust's generics (monomorphization) allow for zero-cost abstractions and inlining, whereas C often relies on function pointers (like qsort) which can inhibit optimization.
"In Rust and C++, the standard library sorting functions are templated on the comparison function. This means it's much easier for the compiler to specialize the sorting function, inline the comparisons and optimize around it." β OskarS
"Rust would not have achieved C speeds if it did not carefully pick abstractions that were amenable to optimization." β kibwen