From time to time, I write small programs to fulfill a need, or just because I have some ideas I want to experiment with. I used to fire my text editor and my C++ compiler to code such programs. But lately, I've been playing with the Rust programming language, and I think it became my favorite language at home.
Of course, the main list of features found on Rust's home page is a source of motivation when you are looking at programming languages that fall in the same category than C and C++: memory safety, explicit ownership... including some radical features like the move semantic, i.e. a variable is moved by default instead of being copied, or the fact variables are read-only by default. I would love having "const" by default in C++.
But lately, what made me reconsider my default programming language at home was the Rust ecosystem, something I feel is lacking with C++. With Rust, you don't only get a compiler, you also get:
I wanted to run on Linux an old program I wrote on Windows in C++ with my own framework. But instead of adapting the existing C++ code, the reasons I just listed made me decide to rewrite the program from scratch. The program is a tool to fix subtitle files. Sometimes subtitle files are not well formatted, or some small mistakes can be found that would easily be fixed automatically.
In addition, I found other several design decisions that pleased me: easy and incentive unit testing, low dependency (you can in fact write an OS with Rust), or some syntactic sugar. For example, I've always been bothered by nearly-useless parenthesis around some C++ statements:
if( value == 42 ) { plop(); } // That's C++, {} are optional for single line operations if value == 42 { plop(); } // That's Rust, {} are mandatory, but you don't need parenthesis
I could go on about that language. I am still learning and there are still plenty of features I need to play with. Do I sound enthusiastic ? ;) I have to find some counter points:
const char*
and std::string
in C++; in Rust you have str
and String
. Rust will hardly replace languages in domains where C and C++ are already not suitable.One last word. You want to try Rust without installing anything? You can write Rust online! Go to the Rust Playground were you are greeted with a "hello world" program. Click Run to build and run the porgram. That's a fantastic initiative to learn and to exchange code snippets.