4 ms·
Long but great article. Echoes my own track record with Rust. I've been rewriting a project in Rust. The original is a 20+ years C project (not created by me).
by whatever_dude 6y ago
Long but great article. Echoes my own track record with Rust.
I've been rewriting a project in Rust. The original is a 20+ years C project (not created by me). Rewriting it in Rust has been a delight. So many surprises, discoveries, learnings.
I've first converted the codebase using C2Rust (surprisingly efficient). The code compiles and runs correctly. While Rust has been nagging me nonstop when I try to do things the original C way, and I still have a lot of weird flags on the code, once I rewrite some piece of code in idiomatic Rust, I end up with a much better design than before. Gone are weird linked lists, crazy custom hashmaps, strings regurgitated in memory, "buffers" holding any manner of data anywhere in memory. Instead, the new code is more efficient, more understandable, and of course safer - even if more restrictive!
I've found at least two major hidden bugs on the original codebase doing so too.
Rust certainly has a learning curve. It's not C/C++ nor Java/C#/JavaScript. But I'm more and more convinced it's the right way to do things in what's currently the C/C++ space.
- blub 6y agoSurprisingly thin endorsement. The central argument seems to be that one has gotten rid of custom data structures and raw buffers, but these are typical for C and of course any language with higher abstraction power and a standard library will have them in there. In this sense you could have switched from C to almost anything else and have gotten similar benefits. Finding bugs and improving the design is typical for refactoring and redesign projects.
- whatever_dude 6y agoThe point here is using types that are still fast and memory efficient without having to resort to brittle pointer magic full of gotchas. You still have raw buffers, and they're still efficient, but you just don't have to do malloc or memcpy all over the place to make them work the way you want. The way I see it, much of Rust, and this project specifically, is not about moving to a higher abstraction... It's about moving to the right abstraction. Yes, I could have switched to just about anything else, and end up with an even higher level code. But that would defeat the purpose of keeping it small, fast, and memory conscious.