Quick prototyping and ergonomics in Rust projects
I was recently asked a question that many other (game) developers using Rust must have gotten too:
How do you feel about the criticism leveled against Rust game development that you can’t quickly prototype new ideas or changes?
I’m a bit conflicted about it, because I heard it so many times and I both agree and disagree with it. I think the criticism is valid, but you get so much out of Rust that there’s a legitimate trade to consider.
Here, I will consider major aspects that I consider relevant after two years and three major Rust games, and give you a better idea of whether Rust is the right choice for you.
Speed of prototyping
I don’t think you’ll ever be as cracked as you would be with plain JavaScript/Python/Lua, duck-typed scripting languages, because the compiler will simply not let you through until you write code that is guaranteed to not break in certain ways.
But, that’s… exactly the same as any other compiled language? I don’t think Rust’s curve is so steep. In fact, it does so much heavy lifting for you and provides good standard library primitives, and many consider it better than Java/C++ in agility.
Learning curve
Although the curve is not steep, that doesn’t mean you get to just start writing complex projects using unfamiliar libraries immediately.
It took me around a year of doing a bunch of leetcode (two Advent of Codes) to get familiar with how to write Rust comfortably, then another year messing around with prototypes to understand the ecosystem, followed by a year on my first commercial launch.
Throughout this process I had to get comfortable with the borrow checker, static typing, stack vs heap, generics, packaging, and the ecosystem. There’s a lot to learn, but none of the steps are particularly esoteric.
The usual advice, that you should probably use the tools you’re most familiar with, is important to consider. If you’re thinking about getting into Rust, make sure it makes sense for you and that you have the time to sink.
Safety and guardrails
Being in a compiled land means that I can implement certain features with a lot more trust than I would be able to in scripted languages. If I change the function signature of something, the compiler will whip me until I fix every single reference. If I try to write a bad loop that would allow me to incorrectly manipulate the contents of a list, then I will know about it immediately.
This makes it very handy for when I want to fundamentally change how some data is stored or optimize how an algorithm is structured, because once I compile again, I know that I’m going to be testing a crash/bug-less (except for impl failures but that’s always your fault) build. It also ensures that I have less ways to write broken game logic too.
The Trade
Ultimately, the trade you’re considering is one where you’re probably giving up a fast exploration at the beginning and exchanging it for a much better experience later down the road. Thus, it’s a very valid strategy to prototype elsewhere (pen and paper, JavaScript/Lua, Visual Basic…) and bring your fleshed-out ideas to Rust.
I think this is a valid trade, it’s up to the user to take it.
My fundamental experience has been that as your application gets more complex, you avoid many common crash scenarios, and refactoring to build mechanics later down the road becomes so much more convenient compared to what you’d have to do in a scripted language. This, to me, is the biggest selling point of Rust.
P.S. Lower-level ergonomics
I am not talking much about lower level ergonomics like how useful/intuitive borrowing is, or being able to manage memory more effectively because if you were to use, say, Bevy or Godot bindings, you would not deal with a lot of the stuff that I chose to deal with for my game. The specific ‘stack’ you’re going for is going to have a big influence on what your development process looks like, and the kinds of challenges you’re going to face.
Moreover, a Lua programmer using LOVE2D probably wouldn’t be able to make 75% of the optimizations I can write because I use Rust. I need to make those optimizations for the specific kind of game I’m building, and especially now that I’m doing a mobile port I genuinely see the benefits.