A few words from Agical

The story behind Rusty Aquarium

Or; “Why I chose to use Rust and Macroquad to develop a data visualization application”

I've had the idea of using a virtual fish tank as data visualization for longer than I can remember. So it’s not entirely clear how I came up with it. But I've always thought static graphs are quite boring to look at. A fish tank screensaver on the other hand. It’s a lot more calming.

False starts

There were multiple false starts trying to implement this. Once I downloaded the source code for a fish tank screensaver in C to modify it. But I couldn't even get it to compile with a modern C compiler.

Another time, I tried doing it with the Unity game engine, which I’d been interested in trying.

But I’m not a big fan of working with an IDE. Nor clicking around in a complicated interface. Nor interested in learning to code in C#. Also, most of the tutorials seemed to be in video form, and I prefer to read instead.

So, I dismissed Unity.

Rusty Aquarium

When we received two BIG TVs that we could use to show analytics data at a client site, I decided it was time to pick up the Aquarium idea again. Working with analytics is much more fun when the result might be beautiful.

The reason I settled for the Rust programming language was mainly because I've been interested in trying it out for a while. I had read a book about it, but never really coded anything with it. When a colleague sent a link to an interview with Fedor Logachev, the author of the game library Macroquad, it seemed like a good fit.

Macroquad looked like it was easy to use. Another benefit was the ability to compile it into WebAssembly. So it can be used in a web page.

Macroquad game library

Macroquad is as simple as it is easy. It is a game library for Rust that can cross-compile to several platforms, as well as WebAssembly.

Getting started with Macroquad was easy, as there are many examples, and the code is easy to understand.

The first version was a ball bouncing around on the screen, which was based on one of the examples. Adding a fish texture and a background was really simple and made it look more like a fish tank.

Setting it up to compile to WebAssembly was just as easy. It’s just a matter of adding the `wasm32-unknown-unknown` Rust build target and compiling it. The compiled WebAssembly file can then be loaded in an HTML page together with a small javascript library.

Getting something simple up and running so quickly was inspiring. I had a simple fish tank with random movement up and running on the web within minutes. As Macroquad is a game library, I spent some time on the graphics, and implementing a shader, before starting work on reading input data to control the fishes.

Finally released

After all this time, it’s very satisfying to finally see the simulated aquarium on the wall everyday at work. Having colleagues looking at it and asking what the different fishes actually mean. It's also fun to hear about others setting up aquariums at their offices.