The world must be rewritten in Rust
In hashbang Matrix room, there was a discussion and then…
I’m not using that software, it’s not written in Rust and therefore it hasn’t got memory safety.
It was then that I wrote 3-4 paragraphs in chat. I’m writing the same paragraphs here, with a little better wording and formatting.
C/C++ doesn’t mean memory unsafe
Writing a memory safe program using C/C++ is entirely possible. But rather, it requires a lot of time, effort and care. Rust aims to make it impossible for the programmer to make these errors, rather than the programmer manually watching for them. In C/C++, your program will compile and when the time comes, it’ll either SEGFAULT or have strange behaviors. However, there are so many codebases in C/C++ which are so old. They have matured and memory problems rarely happen in them. Examples are nginx, neovim, vim, apache and the Lua VM, among others.
Turning C/C++ codebase into Rust, in one night will be harmful
If a new software is to be written, writing it in Rust or Go might be a good idea to avoid such these problems. However, converting a multi decade old codebase into Rust in one night won’t be god. It’ll most likely cause more harm than good. You can, however, slowly replace each component of the program with Rust. Then after some time, you could minimize SLOCs in C/C++.
Another matter, is performance. Many C/C++ codebases has been highly optimized during years. Even if you could quickly and harmlessly turn them into Rust, you’ll start from Day 0 for optimization. And you’ll have to walk the same way you did for your C/C++ code.
We need programmers who really understand Rust
Having professional Rust programmers who understand Rust matters a lot. Not just for Rust but for any technology. I’ve heard in the embedded space, there are so many libraries or drivers written in Rust by C/C++ developers. Most of them don’t have practical value. They are terribly written Rust code, written by people who doesn’t really understand Rust. So you better go with C/C++ in many embedded projects.
Rust is not the best choice for everything
Last but not the least, Rust is not the de facto standard choice for all and everything. When there is a hype, you must realize what portion of it is real, and what portions are just deceiving emotions of people.
Edits
Edit 0
One of the folks in the same Matrix room said he hates when people oversimplify Rust’s advantage to just “memory safety”. I really agree. Rust’s type system is very advanced. C hasn’t got much of a type system. Some call C as just “portable assembly”. I haven’t got much experience with C++ type system. It is for sure much better than C. Yet much simpler than Rust.
Rust’s advanced type system means there is a worse learning curve. And the compiler and/or static analyzer has to do a lot. But it could also mean for many complex codebases, it is a better fit.
