2 ms·
> take, for instance, the inevitable "stop the world" issue during garbage collection. ... Rust is safe indeed but, unfortunately, far from fast. By the moment
by wyldfire 10y ago
> take, for instance, the inevitable "stop the world" issue during garbage collection. ... Rust is safe indeed but, unfortunately, far from fast. By the moment of writing this article, it is comparable to Java, Go, and Haskell regarding performance
...and then he goes on to show a boxplot graph of (likely) CPU-bound benchmarks. C++ pays a penalty (~1.7x?) and so does Rust (~2.5x).
Well, who cares about CPU?! Yes, okay, lots of you. But if you really care, you rewrite that inner loop of your C++ system in C. And if you really, really, care, you rewrite that inner loop in assembly (or corresponding intrinsics). So, hey, here's what I care about: latency! Many systems designed in C/C++ are thus because until recently it was just about the only game in town for predictable low latencies (refer to the "stop the world GC" paragraph above).
Also, there's no other language out there offering both memory safety and the ability to do things like I/O and system control with memory-mapped registers.
Linking your rust code against C libraries and executables is not-super-painful. So phase-in of rust code is easier than other languages described.
> On the one hand, it's not bad to make programmers ponder if their variables are stored in the stack or heap and if they can or cannot be handled by several threads at a time.
Indeed! All the C/C++ static checkers in the world can only hint "Hey this might not be safe, but WTF I have no idea..." only to be declared [FALSE_POSITIVE, IGNORE].
BTW authors of static checkers (like the translators at PVS-Studio) have a vested interest in unsafe languages like C/C++.
- deleted 10y ago[deleted]
- bvinc 10y agoThe benchmarks are from The Computer Language Benchmarks Game. I used to think this was a good way to compare programming language performance. But if you look into the results in detail, it's really not that simple. If you look at rust vs C, you'll see many cases where rust is on par with C, or beats C. When you start comparing WHY some rust version of a program is twice as slow as the C version, usually what you'll find is that someone has not spent the same amount of effort optimizing that program. Or in some cases, you'll see the C program using SIMD instructions, which you could do in rust, but it isn't stabilized yet. What you won't find, is some intrinsic reason that the safety of rust is causing it to be slower than C. To just look at the benchmark totals and make that assumption would be wrong, and that's exactly what the author did.
- steveklabnik 10y agoAlso, that screenshot is from a long, long time ago.