Web Servers in Rust


People, including me, really like writing Rust, so Rust has escaped and set up shop in domains more in the realm of application programming than systems programming. This does have some rough edges and pain points. Here are some articles around recommendations on how to use Rust in the main context I have used it in, which is web servers.

Local Async Executors and Why They Should be the Default by Maciej

I started using Rust in the context of web servers before async/await, which is pretty wild to think about. (Shout out to early versions of Rocket!) To avoid wrapping data in Arcs so that work can be stolen across threads, using local async executors is an option.

Some useful types for database-using Rust web apps by Andreas Fuchs

This article provides some cool methods to get new vs saved in the database versions of types. Though I haven’t figured out a way to get it to work with Diesel, though…

Rust web frameworks have subpar error reporting by Luca Palmieri

Some goals with error reporting and how the two most popular web servers in Rust fall short of them.

When “letting it crash” is not enough by Bernard Kolobara

Adjacently related to Rust, but maybe a nice utility technology to write web servers in a fault-tolerant way.

A Mirror for Rust: Compile-Time Reflection Report by ThePhD

Historical record of the way the world could have been. Initially not super related to web servers, but this could have reduced compile time and dependencies by moving a lot of Serde’s functionality into the compiler.


A quick Gleam interlude

Though I really enjoy writing Rust, its heavy machinery (and all of its other heaviness) isn’t always necessary for what I’m doing. I’ve used F# before, and, while I enjoyed it, there were a couple of warts that would have been nice to avoid. Gleam seems to be focused on being small and quick to pick up, and I’ve enjoyed it so far!

All you need is data and functions by Kayla

I’ve been playing around with Gleam for Advent of Code (hopefully more on that later), and I’m interested in playing around with it for writing web servers too. I wanted to hold onto this article for why traits/interfaces aren’t really required.

Introducing use expressions! by Louis Pilfold

A pattern that I’m seeing in both Rust and Gleam is a happy marriage of both imperative and functional patterns. Rust’s iterators are as efficient as imperative loops while feeling like functional patterns, and Gleam’s introduction of use expressions are implemented in terms of functional patterns but read as imperative code through some nice syntactic sugar.