How to write a Game Boy emulator – Part 5: Rewriting gammaboy in Go
This post is part of a blog series about writing a Game Boy emulator.
I initially wrote gammaboy in Rust, but I decided to rewrite it in Go. Why Go and why not Rust?
Rust was blazing fast. I have no complaints about its speed. The Go rewrite is about twice slower (1s vs 0.5s). It's slower, but likely plenty fast for our purposes.
Rust is closer to the metal, which allows more room for optimization: you know if every variable is stack or heap allocated, you can inline functions, you have no garbage collector to worry about.
So why choose a slower, farther-from-the-metal language?
My major complaint with Rust is that it sucks the joy out of programming. I passed all my time trying to convince the borrow checker that what I was doing was correct, more than I was actually programming. Why use Rust if I secretly wanted to stick unsafe
s everywhere?
Go is a language that has grown on me. It's simple, it has a nice standard library, it's somewhat close to the metal for a garbage collected language, and it's still performant. There are many things that I don't like about it, but it's a nice language overall. It has become my go-to programming language.
The Go rewrite is mostly the same as the Rust version. I cleaned up a couple things here and there, but that's it.