In my previous post I explained how I ported Cute Chess to Qt 6. This meant reading and writing C++ after a brief hiatus. Based on this experience I’ve started to consider switching away from C++.
At the same time I’ve been wanting to learn Rust. My initial learning failed miserably — I relied too much on examples rather than focusing on the basics. This time I took a different approach and started to learn the language like a beginner would with the Rust book. I was able to create something non-trivial: a Brainfuck interpreter partly inspired by a similar project I used to learn Lua.
I decided not to put the project to crates.io because I feel that the service is too closely integrated with GitHub. I prefer using SourceHut for my projects.
There’s a lot to like about Rust compared to C++. Let’s start with code
formatting. In December 2020, I decided to create
configuration for Cute Chess. As I explained in the post, despite there being
some 100 configuration options, it was not possible to create a formatting
configuration that matches our current coding style. Compare this to Rust,
where a consistent coding style is
Rust has a native build system. There is no need to guess which of the dozen available build system the developer picked and what steps are required to to build the project. It’s also unlikely that Rust’s build system is going to be deprecated some day.
The last feature that I’ve used multiple times is the Rust compiler’s ability to explain errors:
rustc --explain E0502
This gives a verbose description of an error with a code example.
Immutability by default and borrow checker would have had come handy when we started to design the concurrency features of Cute Chess. I’m still not confident that our code base is void of data races.
What I fear for the future of Rust is feature, scope and complexity creep. Will you need to select a “subset” of the Rust language when starting a new project? For Cute Chess, we decided not to use exceptions. Now, almost 15 years later, I think we picked the wrong subset.
I think Chris Siebenmann summarized my feelings about Rust in his Rust is a wave of the future post:
Rust is a wave of the future because a lot of people are fond of it and they are writing more and more things in Rust, and some of these things are things that matter to plenty of people.