Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

Rust already does better than C for some benchmarks. See: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...


sort by: page size:


Rust has been shown to outperform C in some cases and in most be on par.

This isn't scientific: http://benchmarksgame.alioth.debian.org/u64q/rust.html


There are a few numerical computing benchmarks for which Rust is sometimes faster than C: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

This is by no means scientific, but it’s a fun benchmark, there’s some debate about the fastest Rust options submitted (ie I believe there were faster than C versions that were rejected).

C: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Clang (for common llvm backend between rust and c): https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

C++: https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Rust is pretty much on par with both C and C++.


Definitely, and Rust isn't the only language that can be faster than C. All benchmarks are rigged in some way :)

C and Rust have been trading blows on the language benchmark games for a while now which dictates the algorithm used. From my experience, it's relatively easy to accidentally write fast Rust, but incredibly hard to write fast C.

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...


This is awesome! Except for a couple of benchmarks, Rust seems comparable to C and C++ in speed. I wonder if something could be done for those outlying benchmarks (of course).

There are actually cases where Rust is faster than C already, one of the reasons being the compiler emitting better code thanks to mutable aliasing being forbidden.

http://benchmarksgame.alioth.debian.org/u64q/rust.html


The benchmarks you linked are interesting. Rust is #1, right before C: http://benchmarksgame.alioth.debian.org/u32/performance.php?... Maybe Rust will finally be a real competitor to C.

I love Rust. Especially for emudev and embedded development (fields I would traditionally use C or C++). However, it still performs worse than C++ in most cases [1].

[1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/...


That's super cool!

What I'd really like to see is benchmarks that compare the rust version to C.


It’s also not as fast as C/C++ in all cases, only in some.

http://benchmarksgame.alioth.debian.org/u64q/rust.html


Yes, Rust has the potential to be faster than C, or even C++. But the compilers' implementations of such optimizations are far too buggy to turn on.

I didn't claim that rust would be faster than C (not that it can't be) in that situation. I would expect very similar performance.

I'm not feeling very well unfortunately, not really in the mood to code.



The rust they write for those benchmarks looks like this:

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

Just as safe and fast as C++, but with more work done to micro optimize.


Also, current benchmarks show Rust to be about ~3x slower than C, making it more comparable to Go or Java.

Regarding performance, the opposite side of your question is as relevant, how many optimization opportunities would have been skipped because the C API is too hard to guarantee correct usage [1]? Rust has already surpassed C on the benchmark game, can that be used as data points?

[1]: http://dtrace.org/blogs/bmc/2018/09/28/the-relative-performa...


Nearly? Rust is already faster than C in quite a few scenarios and benchmarks. The other comment also said Rust is faster when C is compiled through clang.
next

Legal | privacy