Back Original

Building a Multiplayer Game of Life with Rust + Datastar

Last week I built and published a multiplayer Game of Life with Rust + Datastar. You can play it on my Labs Server.

In this post we'll walk through a bit about how it works.

What is it?

A multiplayer Game of Life hosted on my Labs Server.

Why build it?

I've been a longtime fan of Hypermedia Systems with tools like HTMX and Datastar. Like seriously I wrote several posts about building with these tools in this paradigm:

So of course I saw Anders Murphy's Game of Life in Clojure and wanted to build my own using my current favorite stack - high-level Rust.

How it's built

Game of Life stack: Rust and Axum backend connected to an HTML and Datastar frontend

Game of Life broadcast: a shared board renders the latest HTML snapshot and streams it to multiple Datastar browsers

The system basically works like this:

Is this efficient?

Not particularly. But it's also not that inefficient for my purposes - a small demo expected to be used by < 10 ppl at a time.

So yeah a bit heavy to run a game like this but it's reasonable on basically any system built this millenium. If this ever does get wide usage may move to a small canvas drawn version and just send down game state deltas but we likely won't hit that.

Plus I'm running my machines on Hetzner so outbound bandwidth is pretty cheap so I don't mind too much. You can compare hosting options with CloudCompare.

Next

So that's my multiplayer game of life with Rust + Datastar.

If you're curious about building high-level webapps with Rust, I've got a few posts onthe subject and I built CloudSeed to make spinning up a simple scalable fullstack webapp in Rust super easy.

If you liked this post you might also like: