Rewriting my mobile game in Rust targeting WASM


What about Rust?

WASM and the idea

  • I get to learn Rust. This is a mid-sized project that will probably push me enough to explore a good part of the language and its features.
  • Translating C++ into Rust would probably give me insights on what exactly is different between these languages. By understanding changes forced by Rust, I would probably even become a better C++ programmer by getting a clearer picture of some of its pitfalls.
  • I get my game back!
  • And by targeting browsers this time the game will last… forever? I bet someone thought this when they were building Flash games back in the day! haha. Still the HTML5 APIs seem pretty solid and in much better shape than Flash ever was, so betting that they’re here to stay for a long while seems reasonable.
  • I also get to bypass the app stores and don’t have to deal with their annoyances. They can’t kick me out anymore! 😉 (to be fair, it wasn’t their fault that the SDK I used disappeared)

What I wanted/expected from my Rust code

  • No unsafe code allowed, unless absolutely necessary (i.e. if I had to use some other library function marked as unsafe, which didn’t happen). I wanted to understand what could be done within the safety boundaries and what would need to change because of them.
  • Minimize as much as possible changes to the API of my ad-hoc game engine and to the structure of the game code as well. This would probably help me make the code translation faster, but the main reason to do it was actually to stress the limits of what can be done with Rust. For example, Rust is not an OOP language (it doesn’t have the concepts of classes or inheritance), so I wanted to know how much trouble I would get into by trying to replicate a framework that relies a lot on OOP (like the UI framework of my ad-hoc engine).
  • Be ergonomic and expressive. This meant that even if I had already solved a specific problem, I might come back to refactor it to try to push a bit to make the code less verbose, or to use a different design pattern that would make that code simpler to read/write (even if that meant sacrificing a bit of performance).

Getting Started

Writing some Rust code

Rust Drawbacks

Ah iOS Safari…




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Luca Mattos Moller

Luca Mattos Moller

I'm a Computer Engineer interested in all sorts of stuff. Check out my personal website at