3 ms·
> I'm certain my code is not as performant If you don’t need maximum-possible performance, though, why use Rust/C/C++ at all? Wouldn’t a better choice be Go/Ja
by pansa2 6y ago
> I'm certain my code is not as performant
If you don’t need maximum-possible performance, though, why use Rust/C/C++ at all? Wouldn’t a better choice be Go/Java/C#?
- GrayShade 6y agoBecause even slow Rust code might have better performance or memory usage characteristics than idiomatic code in these languages. Or because it still protects you from race conditions. Or because you like cargo more than, say, maven. Or because you want to learn the language.
- hu3 6y agoI was recently surprised that idiomatic Go can be faster than idiomatic Rust: https://news.ycombinator.com/item?id=26463967 https://news.ycombinator.com/item?id=26463967
- GrayShade 6y agoI haven't read that article yet, but I wouldn't really call the simple Rust version idiomatic. Stdin::lines() incurs a string allocation for each line (fixing this takes three lines of source code), which can be quite significant. And garbage-collected languages will have faster allocation, so I'm not too surprised. Of course, I know who the author of that code is. I just wanted to point out that it's not such a trivial comparison to make.
- littlestymaar 6y agoRe-usability is a important feature: if you write a Rust library you can reuse it from most runtime-based language with “native modules” (or whatever they are called in the said language), exactly like a C library.
- edflsafoiewq 6y agoJava and C# typically require a VM, and not everyone thinks Go is "easier to write" than Rust.
- pjmlp 6y agoThey can also be compiled to native code and as such it is a plain language runtime, just like Go.
- afavour 6y agoIt’s all a matter of opinion but I actually find Rust a wonderful language to write in, given the right circumstances. Which usually means “without having to deal with lifetimes”. I tried Go, I wanted generics and errors. I like C#, but not the ecosystem that comes along with it. And so on. So for me personally, Rust is a a valid choice even when performance isn’t a first concern.