Rust For A Rusty Game Developer — Part I
Rust is my first foray into a systems programming language since highschool and even then I never went in past my toes. This is the introduction of a series of posts I’ll make as I document my experience of learning Rust.
The Aspiring Game Developer
Why a Systems Programming Language?
Over the last 4-5 years, I have become obsessed with speed and
performance. How did I become this way? By living in a rural
town in the middle of nowhere Saskatchewan for 4 years. When I
got there I didn’t have any cell reception and the WiFi was
horrible and though it did improve during my time there, I
became keenly aware of the frustrations of living with a
sub-sub-par Internet connection. This experience has been
guiding for me as I dive deeper into programming. I want to
build products that everyone, anywhere can access — no matter
what difficulties may befall them. That brings me to what I’ve
noticed. A theme in a lot of software these days is a lack of
performance. Much of modern software is web-based in some way
and that's really great if you are a web developer or need to
ship software to as many targets as possible, but please stop
using so much memory. Yes, I’m looking at you Electron 👀.
Anyway, I’d like to learn a systems programming language so I
can build more efficient software.
Why Not C++?
When I was deciding to into a deeper programming language, I first jumped to C++ because I had some familarity with it and it is so popular. It was hard to feel like I was getting anywhere after a week though. I had become accustomed to the ecosystems that I knew from Node and PHP, but there seemed to be no such thing for C++. I realized that the language was pre-Internet and it didn’t have the opportunity for a centralized ecosystem to catch on — by the time the Internet came around everyone had developed their own ways of managing dependencies. Attempting to learn C++ was a lonely experience. I needed something that had a thriving ecosystem if I was going to catch any sort of momentum in my learning.
I had heard of Rust through following Yoshua Wuyts on Twitter. I had discovered him through being a fly on the wall in the communities that surrounded Tachyons and functional CSS. Since I trusted his fascination with performance, I became interested in Rust and it was the first language that came to mind when I started feeling lonely learning C++. Rust was very much the opposite of what I found with C++: the community is thriving, there are plenty of official, well maintained resources for learning the language, the ecosystem is well established — despite being a relatively young language — and the tooling is fantastic. While Rust can feel like a decently steep learning curve, the community and ecosystem cushion that, make it easy to gain momentum when learning.
Resources I’ve Found Helpful
The following are some resources I’ve found helpful as I’ve learnt Rust. Let it be a guide to the Rust ecosystem if you’re brand new.
I began reading The Rust Programming Language in August. Though, as I read, I did find it difficult to figure out what I could use Rust for that wasn’t too far fetched for a beginner (i.e. making a game), the book did include some great exercises which helped me get the underlying theories and values which are core to Rust as a language. The final project in the book was a multi-threaded web server and it was my motivation to finish reading 😂. Overall, I would recommend the book to anyone wanting to begin with Rust. Sure you might want something that is more practical and has less theory, but if you take the time to read the book, you’ll understand why Rust is the way it is. After reading the book, I discovered Rust By Example which satisfies the desire for a resource that is more practical and straightforward; a great reference to keep while programming in Rust.
Docs.rs is amazing. They have done such a good job of centralizing all of the documentation, information, and links regarding any crate you pick up.
So far, the most immediate need that I’ve discovered that I can use Rust for is commandline-interfaces. I have more than a few Bash scripts lying around which I’ve been wanting to refactor and I’ve begun using Rust for that. So far I’ve been using StructOpt as a library for building quick little CLIs for everyday tasks.
This blog project in itself has been a fun chance to learn Rust. I chose Zola as the static site generator and it's been a pretty smooth experience so far. It's able to deploy to Netlify which is always great. As a little fun project I built a CLI for scaffolding new posts, which should serve me as I continue to blog. I've found Tera — a Jinja inspired templating language to be a great asset for that type of project.
I think as a big goal, I’d love to build a 2d platformer. I’ve always loved 2d games and that's much of what I built when I used to make games.
Coming Soon — Part II