The switch from C++ to Rust must’ve been quite beneficial if it was deemed necessary delay release to switch. So, can someone explain exactly what the ACTUAL benefits of the rust programming language are compared to C++? I was reading some that were saying that rust isn’t all that in terms of efficiency, but this is the first project I know of that was rewritten in Rust from scratch from C++, which would make it like a proof-of-superiority. To be more specific, does rust for example, eliminate try catch blocks and other error-handling code? What is the specific mechanism through which the devs were allowed to reap a significant decrease in codebase size? I mean if this works out, you guys have basically proven that its easier and safer/more secure to write certain projects in Rust than in C++, the most dominant high level programming language (outside of the scripting languages). THAT ALONE is a major, big deal. I mean, there aren’t many projects that can say, “wrote a killerapp in a killerlanguage”. Rust would become the killer language of C++, Java, and perhaps a few others.
This probably doesn’t answer your question, but it will give a little magnitude to what the swap did for the project:
There are probably lots of other little updates and comments on the forum that mention one improvement or another, but I too would be interested in hearing the review from the developers themselves.
I remember Mr Irvine saying it really helped free them from having to deal with fixing errors or something all the time, so they could spend more time actually working on the core issues.
IDK much more than that small regurgitation tho lol
Rust prohibits code that creates a massive portion of programming errors and potential bugs.
If you try to do something dangerous or naughty it just refuses to compile.
That’s great, that makes sense.
So it was possible that the C++ code base might have went off in lots of crazy, unproductive directions at times, increasing the code amount,
While rust doesn’t allow that.
Explains the code reduction quite well
Also RUST is more suited for protocol programming. With less code needed, it also becomes better to debug.
…and much easier to read. It’s (almost) as readable as Python IMO. I remember @dirvine said that it would be useless to release the SAFE Network as FOSS if no one could comprehend the codebase!
As a side note a factor of readability is the sheer lines of code. I remember that when they chose to refactor in Rust, they were around 1 million lines of C++ code. (~196 thousand IIRC) Right now they’re probably at about 15-20 thousand (probably; as the last verified count that I read about was ~2 months ago at 11 thousand)
I’ve mentioned before that I was at FOSSCON this year when Eric S. Raymond gave an AMA, and I remember him saying that he was “very interested in seeing how the Rust language evolves” and that he “was cautiously optimistic that this could be the C++ replacement that we so very desperately need”. Specifically that Rust “implemented rational rules and restrictions for code security especially when it came to memory security without creating artificial limitations”. Big words from a big name in the FOSS space.
ownership and borrowing, there are elements that own data and they lend access to them, and access to the elements is controlled by algorithms.
Rust keeps the developer accountable with very simple borrowing and ownership rules and also provides a set of tools to deal with this amazing memory managing system.
Thanks for the replies guys. I’m still not sure exactly how Rust was able to allow for the removal of 10s of thousands of lines of code so I’m bumping it to the top in case someone who worked on it can be more detailed. I’m a developer and I’m trying to wrap my head around this idea, it literally blows my mind. I’ve refactored my own (poorly-written) code from time to time, and while I’ve been able to go from say, 3000 lines to 2500 or s.t. like that, a reduction of this magnitude strikes me, as a developer, as sheer madness! In the good way of course. Its unfathomable to me that Rust allowed the core team to tighten up that much and it really is an advertisement for learning Rust.
In C & C++ it can take many lines to do a set of calculations and 5x as many lines for error checking and recovery. At times the language requires a lot of code just to do simple error check & recovery. Thinking in terms of protocol programming which is 10% direct protocol and 90% error checking/recovery (approx %ages)
Whereas RUST is designed to incorporate a lot of the error checking and recovery into the language itself. This way the code writer can do the calcs and do error recovery in a concise way. Now its more like >>25% direct protocol and rest error checking/recovery
There are also additional elements of the language that allow processing of objects in a more efficient way requiring less code to do so.
In essence the language has built in many things that one had to write in C & C++, that help a systems level programmer unlike typical higher level programming languages.
I see, that’s what I thought, especially about the error checking. I guess I really need to learn rust to see this for myself.
Thanks for that!
You might want to read this thread