Interactive C++ Assembly Explorer
gcc.godbolt.org
gcc.godbolt.org
Rust, Go, and D language explorers are https://<lang>.godbolt.org, e.g. https://rust.godbolt.org/ and so on
If you're not adding a flag like `-C opt-level=3` to the compiler invocation this is literally true. (For one, Rust's unoptimised code does more work than C's, e.g. arithmetic operations are checked for overflow in debug mode, which is the default when optimisations are off, but is disabled when optimisations are on.)
With optimisations on, Rust seems to do a better job, e.g. the loop in the max_array example is vectorised and unrolled by Rust, but not by gcc or clang.
> I just don't see how it can be claimed that Rust can be nearly as
> fast as C when executing the Rust assembly code requires so many
> times more instructions to be executed!
Well, beyond what others have said here, with performance, it depends on the exact details. For example, our regex library has gotten some upgrades recently, and so on the benchmark game: * http://benchmarksgame.alioth.debian.org/u64q/performance.php?test=regexdna
* http://benchmarksgame.alioth.debian.org/u32/performance.php?test=regexdna
* http://benchmarksgame.alioth.debian.org/u32q/performance.php?test=regexdna
* http://benchmarksgame.alioth.debian.org/u64/performance.php?test=regexdna
We're currently the fastest in two of them, and second place in two of them, once to C. But in many of the other benchmarks, we're slower.At best, a claim like "Rust is as nearly as fast as C" can only be said for broad categories of things. The devil is in the details.