Once upon a time, in a
galaxy... time far far away, there was a desire to
write a blog site generator. I have no idea why I actaully wanted to do this;
perhaps I was inspired by some well known Rust programmers' blogs to write my
own posts. Even then, I'm still probably not going to run into problems as fun
or interesting as others I've seen. Regardless, it was a new project idea,
and we all know how much programmers love to start something new.
The baseline requirements I had in mind for this blog generator were:
- Has links like
- Reads the posts from
- Is solarized dark, because it's my favorite color scheme
It seemed simple enough, so I chose Python for my initial implementation. In my opinion, Python is a good language choice for small programs, prototyping, or learning programming. When it comes time to put a large codebase into production, I would hope it's a statically-typed, non-garbage-collected, compiled language. Luckily for me, I don't (yet) really have anyone who depends on my software or server other than myself and Benjamin, nor do I have any large codebases.
The resulting script met my requirements, but only just. Not to mention the
single 77 line file was nigh unreadable. It gave bizarre messages in the browser
if given URLs for posts that don't exist, it couldn't serve anything other than
files written in markdown whose names ended with
.md, and it didn't cache
anything. It was stupid, but it worked, but it was still stupid.
Six months or so went by since writing the Python script when I first started learning Rust. I had heard of this language several times at this point, but the way the syntax worked threw me off and kept me generally disinterested in the language for a long time. What finally got me to learn the language was when Benjamin showed me how tagged enums work in Rust as oppossed to C while I was working on libmatrix-client (which, appropriately, is now unmaintained).
Fast forward a year to today, where I was explaining to a friend how to install and launch Minecraft modpacks through the regular launcher for the umpteenth time when I had four ideas, in this order:
- I should make a video on how to do this
- I should rewrite CMPDL in Rust, except make it also put the pack in the correct place, install the correct version of Forge, and add it to the configurations list in the launcher automatically
- I should write a text tutorial on how to do this manually for now
- I just remembered the horrible python script, I should rewrite that in Rust
I decided that videos are hard (couldn't get OBS to capture the Minecraft launcher for some reason) and string processing isn't fun (it's just not). So I wrote the text tutorial and a new blog webserver.
Back on topic: the new webserver is, in my opinion, only marginally better than the Python version. This shoddiness was somewhat intentional though, I just wanted it rewritten in Rust as fast as possible with the intent to improve on it later. Especially since never using Rocket (the inspiration for the title of this post) or Maud before, getting it to feature parity (and then some) with slightly higher quality code in only about 5 hours was satisfying. Thanks to those crates for incredibly simple and flexible APIs and comprehensive documentation!
The experience on the browser side is now a lot better: things 404 correctly,
the pages are set up marginally nicer, and it's capable of serving any kind of
file (but still only processes markdown ending in
.md into HTML). The backend
and code itself could still use some work though: it doesn't do any caching,
there's lots of
.unwrap(), it's lacking in logging, has lots of silent
failures (fine for browsers, not fine for people wondering why their post or
image won't load), isn't as organized/documented/idiomatic as it could be, and
I'd say I'm pretty happy with the results for now, and I definitely have my work cut out for me. Benjamin mentioned wanting to try benchmarking the new blog generator against the old one, which I think would be a fun experiment. I have a feeling that the Python version will turn out to be faster, at least until the new one gets caching. I'll make sure to write another post on the results of the testing, if we get around to it. For now, thanks for reading!