Re:Ask HN: Why is Rust faster than C++ for calculating the s...
by compressedgas on Saturday April 01, 2023 @04:12AM
(#35398317)
Rust ran the loop at compile time.
[ Parent
| on HN ]
Re:Ask HN: Why is Rust faster than C++ for calculating the s...
by anandnair on Saturday April 01, 2023 @04:28AM
(#35398416)
Enabled compiler optimization for g++ and then the execution time went down to 0.00025, which made it slightly faster than Rust :)
Re:Ask HN: Why is Rust faster than C++ for calculating the s...
by lowcoderev on Saturday April 01, 2023 @04:15AM
(#35398329)
Is that a feature specific to Rust? Can you please share any references to their official docs citing this?
Re:Ask HN: Why is Rust faster than C++ for calculating the s...
by throwawaylinux on Saturday April 01, 2023 @04:18AM
(#35398347)
It's a feature of optimizing compilers for decades. OP just didn't compile the C++ code with optimizations enabled.