4 ms·
I found Golang to be a gateway drug to Rust for me. If you want strong control and very unforgiving type system with even more unforgiving memory lifetime mana
by pdimitar 2y ago
I found Golang to be a gateway drug to Rust for me.
If you want strong control and very unforgiving type system with even more unforgiving memory lifetime management so you know your program can get even faster than corresponding C/C++ programs, then Rust is a no-brainer.
But I did not pick it for the speed, though that's a very welcome bonus. I picked it for the strong static typing system mostly. And I like having the choice to super-optimize my program in terms of memory and speed when I need to.
Modelling your data transformations with enums (sum types) and Result/Option was eye-opening and improved my programming skills in all other languages I am using.
- throwaway2037 2y ago> you know your program can get even faster than corresponding C/C++ programs I have seen this argument a few times here are HN. To be clear, I interpret your phrase that Rust "will eventually" be faster than C or C++. (If I read wrong, please correct.) However, I have never seen any compelling evidence that demonstrates equivalent Rust code is faster than C or C++ code. Some lightly Googling tells me that their speeds are roughly equivalent (within 1-2%).
- pdimitar 2y agoAs mentioned, I didn't go to Rust for the performance alone so I didn't track the articles that tried to prove the claim. The stated logic was that due to having more info to work with the toolchain could optimize away, quite aggressively so, many things, to the point of the code becoming lighter-weight than C. Whether that's true or not, I make no claims. Not a compiler developer. And yeah I'd be quite content with 1-2% margin compared to C as well.
- om8 2y agoHere is an example of Rust implementation being faster than C. https://trifectatech.org/blog/zlib-rs-is-faster-than-c/ https://trifectatech.org/blog/zlib-rs-is-faster-than-c/
- Night_Thastus 2y agoDiscussions on HN of that post at the time more or less debunked the title's claim, from what I recall.
- pdimitar 2y agoYeah that was the one. I too left it unconvinced that Rust can get measurably faster than C, for what it's worth. But as said in another comment, even being 1-2% around the same ballpark is a huge win already and it would be enough for me.
- throwaway2037 2y agoHat tip! Here is the original HN discussion: https://news.ycombinator.com/item?id=43381512 https://news.ycombinator.com/item?id=43381512 Another thing about that library, like so many "Rust wins" that we are seeing: There is loads of unsafe code.