4 ms·
Rusty rust? I don't think there is such a specific thing and certainly disagree that all idiomatic rust is somehow slower by default. You can write rust like
by Arch-TK 1y ago
Rusty rust?
I don't think there is such a specific thing and certainly disagree that all idiomatic rust is somehow slower by default.
You can write rust like you might write a higher level language and then that can end up slower but if you write idiomatic low level rust, the performance is much harder to compare with C. There are things which will be faster in C and things which will be faster in Rust but broadly things will be extremely similar in performance.
I write bare metal embedded rust a lot these days and there are quite complex concepts you can represent in rust which make your code a lot safer without a performance hit.
- pclmulqdq 1y agoIdiomatic "low level" rust clocks in at about 10-50% slower than hand-coded C every time I try it. It is also about 10x easier to write the Rust code. Unsafe is just required a lot of the time. Sometimes it's code size or struct size just being larger to express a similar concept. To get back your performance you have to do things that are un-idiomatic (but you have to do in C anyway).
- Arch-TK 1y agoShow examples please.
- simonask 1y agoThat is an unbelievable claim. 1. Rust structs are generally smaller due to layout optimization. 2. A 10-50% difference is well within the “are you measuring debug builds?” territory. I’m curious what code you are writing that requires unsafe all the time? I do a lot of low-level optimization, and unsafe is barely ever actually needed.
- pclmulqdq 1y agoIt sounds like you work with people who don't really know C. Understanding how to pack a struct is a pretty basic skill. Write an optimized database or network stack without unsafe for me. https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust-gcc.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- simonask 1y agoI did not say “never”, I said “barely ever”. I’m not really sure what your point is by linking the benchmarks game. I mean, it’s a fun activity, but this is saying nothing about C vs. Rust. It may or may not be saying something about GCC vs. LLVM.
- pclmulqdq 1y agoI also did not say "always," I said "every time I try it." The benchmarks game is a public example of this, with well-optimized implementations in all languages. Why can't people just take the win of "10% slower, 10x easier"?
- igouy 1y agoRust versus C clang :-) https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/rust.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- tialaramex 1y ago[dead]
- dminik 1y agoIt takes some hubris to post "rust is consistently 10% slower than C" take and back it up with a page which shows a result 6:4 in Rusts favor.
- pclmulqdq 1y agoI said "every time I try it" and I said "idiomatic Rust." The fast rust implementations are consistently starred there, indicating use of hand SIMD or unsafe or others. If you read them, they are not very idiomatic. Also note that 3 of 4 comparisons in favor of Rust are marked "contentious" for using different algorithms with different limitations - they are not equivalents. The last one is k-nucleotide, which is a very algorithmically heavy problem where nobody has given optimized C and Rust has won at producing a decently optimized thing quickly. Note that the fastest C++ implementation handily beats Rust on that one, also.