Below post has started from me thinking about Rust on a weekend, and then expanded a bit. I was merely trying to understand whether C/C++ will die eventually and be replaced with something like Rust.
First of all, Rust is great, good performance, interesting language, more accessible than C.
However, thinking more about it - forces developer to start from clean slate.
There is no interop with C++. There is with C, meaning that you can wrap C++ in C calls, make a dynamic library and only then call it from Rust. Wrapping is not always a good idea, as C is unsafe and C++ is safe, plus you will have to translate some rich C++ data structures into C, meaning performance overhead. Also this prevents overall program compiler optimisation, meaning again performance loss. Also you will have to wrap C interface from Rust, again another performance loss.
System programming close to metal and OS is primarily done in C, so Rust is a very weird citizen there. Like Linux and Windows is all C, and according to various sources there is no vision to use Rust.
The promised safety is really arguable. Usually you will hear arguments that Rust is safer than C++. But that’s just not true for Modern C++. It could be true when comparing Rust to the state of C++ maybe 20 years ago.
Scala is another example, as it builds on JVM, can use any native Java library, and can be compiled to use from classic Java as well! Same with Kotlin. And the wast amount of platforms JVM runs on.
Python is… well, still good. Most of Python libraries are actually written in C++ with python wrapping on top. Python is old and well developed. It even runs on JVM.
Golang is just golang, it does not claim to be a replacement for anything, bit fits well into the area of writing small simple utilities for command line where others would be too heavy. Some do write more complicated code, for instance Docker is done in Go, however it is not common. You would not write anything performance critical in Go either, mostly due to unpredictable garbage collection issues. And it’s not powerful enough to scale to really complex code. Remember that Docker is essentially an orchestrator gluing together different parts of OS to make it more accessible to mortals. It does not actually run when container runs.
C# is a weird beast. It builds on top of Java principles, but doesn’t run on JVM. It’s really way ahead of Java in terms of features and productivity, but used to only compile for Windows. Today cross platform support is great, but it may be too late for the party. It may end up like Windows Phone, it’s hard to tell. I hope not. Btw Windows Phone was way more superior than iOS and Android, but that didn’t matter at the end. It was just really late to the party.
Where does Rust leave us? I’m really confused, but it seems nowhere. Yes ecosystem is growing and there is just a lot of good stuff. But always almost enough, not completely enough. Sure if you are building software that is a utility or web server it’s ok to use, but not something really deep, no way to reuse rock solid code that worked for decades already. You’ll have to create some weird workarounds or write stuff that existed for decades from scratch. Scratch that.
Rust is not supported on as many platforms as C/C++ is. Meaning embedded and IoT is not fully accessible.
Tooling is just not there. There’s no cool IDEs like Visual Studio (which btw works perfect for Linux programming) or CLion or Eclipse. We have some half baked support in IDEA, Vs code and some others. But no really cool tooling C++ has grown to.
Do I hate Rust? Oh no, not at all. I think it’s a beautiful language. Very clear, with no legacy like C++.
Is it superior to C++? No, I don’t think so. Everything Rust does C++ does, if you use more or less recent C++ version. Even 10 year old C++ will do. But, the problem with C++ is novice programmers - the language is just so rich, it’s much easier to escape out of the sage box and do something stupid. But that’s just language evolution, eventually Rust will be there too as history shows.
Would I choose Rust for my next project? It depends. If I need to interface with OS or use third party C/C++ libraries than no. I would probably use it for command line utils or self sufficient cross platform network utilities. But then why won’t I just stick with C++ if I already use it? So far only as a learning exercise.
Well, I think I’ll stick with C++, but I’m open for criticism.
To contact me, send an email anytime or leave a comment below.