4 ms·
Rust can, somewhat is already and ultimately will beat C on performance, due to way better guarantees on pointer non-aliasing. See eg. http://stackoverflow.com/
by dpc_pw 10y ago
Rust can, somewhat is already and ultimately will beat C on performance, due to way better guarantees on pointer non-aliasing. See eg. http://stackoverflow.com/questions/146159/is-fortran-faster-than-c#146186 http://stackoverflow.com/questions/146159/is-fortran-faster-...
Other than that Rust has way better zero-cost abstractions, so in practice allows writing faster code, as in C there are sanity limits after which you give up and write slower, but easier to manage code, as macro processor sucks, and type system is trying to stab you in the back at every step.
Good example is `qsort`: http://www.tutorialspoint.com/c_standard_library/c_function_qsort.htm http://www.tutorialspoint.com/c_standard_library/c_function_...
- Bromskloss 10y agoWhat are we looking for in the qsort example? Is there a Rust equivalent we should compare to?
- dbaupp 10y agoThe C code is forced to use a function pointer and hence do dynamic virtual calls for each comparison, while Rust and C++ can use generics/templates to get static dispatch (and hence inlining, constant folding etc.). You can see C vs. C++ in http://www.martin-ueding.de/en/programming/qsort/index.html http://www.martin-ueding.de/en/programming/qsort/index.html , and Rust is likely to be similar to C++.
- nwmcsween 10y agoLTO will allow qsort to be inlined, etc.