Rust Rewrite
Published:
As I tend to do from time to time, I have recently rewritten this site in technologies that currently interest me. It is now written in Rust on the server side.
Why Rust?
First of all this site could be static, and was for a long time. Long before JAM stack popularity. But overall I'm a little tired of static site development.
So why did I choose Rust in particular? I started learning Rust in 2020 as something to do. I initially wanted to learn how to use WebAssembly, so Rust was a natural choice. By 2021 I started to feel comfortable doing certain things. I was having a lot of fun with Rust. At the same time I started growing tired of static sites, I started to think I wanted to rewrite my blog to use a Rust web framework.
Actix
I compared as many frameworks as I could find, and ultimately chose Actix. Apart from middleware which is a little beyond my current understanding, Actix's API is really versatile and easy to learn. The best place to look for help has been their examples repo. They also have a Discord.
Cargo dependencies
Some of the more important Cargo dependencies that I am using, besides Actix:
- Askama
- For Jinja-like templates. The only downside to Askama for me is that changing a template means recompiling the project, but it's a tradeoff.
- SWC
- For compiling JavaScript. It is basically a Rust Babel. It does aim to be many other things as well, but I am just using it to compile some JavaScript.
- Parcel CSS
- For compiling CSS. It is basically like Postcss in Rust. It was actually released when I had most of the server written already. Originally I was using a Sass implementation in Rust, but I had forgotten how sometimes Sass syntax conflicts with vanilla CSS, so I welcomed Parcel's arrival. It allows me to do nesting and forget about prefixes. The only downside here is its alpha, so it sometimes breaks. Committing my lock file has been a life saver.
More to come
Any how there is more I could write about this rewrite, and I will certainly be writing more about Rust in the future. Until then here it is.