Dru Erridge

A Year with Rust Game Dev

This is the result of one year with the Rust programming language.  A friend and I worked on weekends with the goal of building a game.  This video represents our journey and thoughts after 100+ hours with the language.

Wins:
We didn’t have a single app crash until Week 22.  Wow.  It also came the first time we ever tried to use an unsafe block (we quickly removed it).

When it compiled, it just worked.  There were so few instances (maths aside) where the game ran and didn’t do what we wanted it to that I can’t even think of a single time.

Rustup is amazing.  Every time we touched it our minds were blown and our problems were seemlessly solved, it takes an axe to all my problems with the Ruby Gems ecosystem, but like, a really shiny, light-weight axe.  Which takes us to Cargo build & package manager, a killer app for a systems programming language.  Getting the graphics rendering in one morning and CSV parsing in another felt like working in Node/NPM – except vastly cleaner.  Small hiccups with ears and the openal DLLs, but that comes with the territory.

Difficulties:
There were 8 / 24 weeks where we made no visible forward progress (week numbers for which there isn’t a gif).  To me this, is an indication of the true difficulty of transitioning mentally from  C++ to Rust.  Most of that time was spent fighting the borrow checker, attempting and failing to generalize bits of code, or trying to apply patterns that simply don’t work in Rust.  Every time we went in to “refactor” to improve the readability of our code, we also got pummeled into submission by the compiler and/or sent down a rabbit hole.

Additionally, the kind of generalized code we’re used to writing in games often just wasn’t possible in safe Rust (there is no unsafe code in the game yet), sometimes intentionally, and sometimes due to missing features like upcasting a boxed trait (described in a stack overflow question and in a github issue.  Missing this really, really hurts).  The overall mental shift has been considerable for us.

Software Used:
We worked off of stable rust and coded in VS Code with the Rust plugin connected to Racer.  We built on top of the Piston game engine, and using ncollide for collision & math, as well as ears for sound.

Background:
We pair programmed for ~3 hours each week, and only worked about half the weekends in the year (life got in the way).  We’ve both been professional software engineers for a couple years with plenty of experience in C++ as well as higher level c-like languages.  We both work in the games industry and have built a dozen or more small-medium games (usually, with an engine, but not always).

Future Work:
We’re hoping this year to begin making videos and streaming our bumbling endeavors to finish this game and perhaps begin building a new game from scratch (our original goal).  These exercises are purely academic/fun and for our own learning.  You can add us on Twitter if you’d like to follow our progress.  I’m also personally looking to get involved more with the Rust community out here (LA) and hopefully find a mentor that can help me start thinking in Rust and it’s idiomatic patterns.

You can find our (awful) code here:
https://github.com/GamesFromRust/piston_shooty

Leave a Reply