Great fit for Rust
Great fit for Rust
Posted Feb 12, 2025 19:32 UTC (Wed) by jmalcolm (subscriber, #8876)Parent article: Rewriting essential Linux packages in Rust
The author states that GNU utils already have sufficient security but also points out that they continue to evolve. The fact remains that it is so easy to accidentally write insecure code in C is still an issue. Rust is not perfect but tends to result in more secure code by default. I am sure we have all seen the "70% of vulnerabilities stem from memory allocation" stories from Microsoft, Google, and others.
Writing code in C that takes advantage of multiple cores is also tricky and makes the security problem worse. Rust again makes this a lot easier and offers greater assurance that code that builds is also correct. For this reason alone, I would expect performance to be quite a bit better for many kinds of tools.
Pulling from so many crates certainly creates packaging challenges but it also distributes the innovation. Tools in Rust are going to benefit from improvements in the overall ecosystem. Tools in C tend to be more fully stand-alone and only improve when you improve them.
Cross-platform consistency also appears to be a strength of the Rust ecosystem. The article mentions that it is easier to implement cross-platform behaviour (even complex behaivour). It has been my experience that the behaviour itself is more consistent as well.
My biggest concern is that these kinds of low-level tools in Rust complicate the bootstrap problem. In order to build these tools from source, I need to have built Rust first which also means building LLVM. I also need to have built any of the crates that they depend on and of course other parts of the toolchain like Cargo. And of course Rust and LLVM are not even available on some of the systems that you might want utilities like this to be available for. GCC certainly wins there. That said, if GCC gets its own Rust front-end, this problem will go away. Perhaps this addresses most of my point here actually as, if you can build GCC, I guess you can build the Rust front-end too.
Not that the bootstrap situation is perfect in C GNU land. The author of Chimera Linux explains his choice of using the BSD userland in his distro instead of GNU largely because of the chicken-and-egg nature of things like the GNU coreutils and util-linux.
One thing that was not touched on is executable size. I wonder how the Rust and C versions compare.
