I Rewrote It In Rust
TL;DR: I rewrote my blog server in rust.
A couple of years ago, I wrote this site as a small C++ program. However, I've
been writing more Rust than C++ lately, so I rewrote the site to be a small
Rust program instead.
Why have I been writing Rust instead of C++?
- Better libraries for web stuff / other things I tend to write. For example,
I was able to use a jinja2-like templating library, while I wasn't able to
- It's more practical / reasonable to use at $DAYJOB. My coworkers are much
Python than manual-memory-management languages. The strong enforced typing,
good error messages, and memory safety will make it more comfortable to use
Rust where we need high performance.
- It has better ergonomics & defaults than C++ in many ways (often because
it's simply a newer language with the benefit of hindsight). For example, I
prefer the "variables are immutable" and "items get moved rather than
copied" defaults that Rust has.
- The trait system is kinda awesome. I wish they hadn't completely given up
on inheritance (there are still cases where it can be a useful tool, after
all), but otherwise the trait system feels much more composable and
extendable than a pure class-based OO system.
- Macros: while they aren't as nice or as easy to write as Common Lisp macros,
they still enable many useful things (just look at the awesomeness of the
- More explicit control flow. Exceptions / error conditions in Rust are still
easy to propogate up the stack compared to C++ exceptions, but it's much
easier for a developer to see the possible control-flow paths the program
could take under an error condition. I don't completely love this setup
(dealing with error types can get annoying), I think the control-flow
benefits outweigh my dislikes.
- Probably others
Of course, C++ is still more ergonomic in some ways, Rust is still missing a
lot of useful features, and Rust does force some extra ceremony and boilerplate
on the developer (dealing with interior mutability, etc). However, at least for
the small pieces of software I write at home, I think Rust is coming out ahead
more often than not.