3 ms·
TLDR: You've tried to exclude something like 90% of all the systems programming problem domains & then said Rust (a systems programming language) is the wrong t
by vlovich123 5y ago
TLDR: You've tried to exclude something like 90% of all the systems programming problem domains & then said Rust (a systems programming language) is the wrong tool. Yes, but you're kind of missing the forest for the trees.
You've got MSFT, Facebook, & Google all investing heavily into Rust as a replacement for C/C++. It's still early days. Rust's sweet spot for being the best tool is anything that's currently written in C/C++. If you're writing Python, Java, or C# code, then Rust is probably not the language for you (albeit Rust is getting deployed in all these places where perf is needed because it offers the performance of C/C++ with the safety of more managed languages).
At no point will it be "replace everything in Rust" (at least not in the immediate term). It'll be more like "write this component with a thin API in Rust" or "with codebases that have a C++ runtime, work out a way for the peripheries to be written in Rust".
I'll give you an example. We used the venerable addr2line (or even llvm-symbolizer) to symbolicate addresses for an executable. We used it by spinning up a process for each address to symbolicate (which is dumb, but whatever). By writing a wrapper over Gimli-rs/addr2line-rs, we were able to improve our symbolication time 1000x & reduce our memory footprint 3x. The memory footprint improvement is because Gimli is 0-copy. 100x of that speedup is because Gimli's 0-copy is also just faster at parsing the DWARF data. The next 10x is because we only parsed the DWARF once & then used that precomputed information for all addresses. The fact that that Rust tool was correctly engineered as a library + frontend meant this was relatively easy, cheap & painless to integrate into our existing C++ codebase (using the cxx crate).
Like all things, Rust is a tool. Knowing how to find the right tool for the job & deploying it well is 99% of the job. Personally, I've found the Rust libraries I've come across for systems programming to be higher quality than the equivalent C/C++ libraries because the field is green, the userbase is extremely passionate, enthusiastic & early adopteree (i.e. more technically adept), & Rust makes certain kinds of optimizations easier than they were before (so naturally people want to play around with them). Additionally, because these are all rewrites, 90% of the time the improvement is just applying more modern state of the art knowledge to existing APIs/algorithms (e.g. doing 0-copy for symbolication is a "no-brainer" but it's hard to do safely in C++).