Picking Technology

Picking Technology.gif

Starting from zero poses a unique challenge. We can strike out in any direction, and try any technique or technology. This can be dangerous. Unguided by experience, we are free to invest in techniques or technologies that will not ultimately prove helpful. Conveniently, in these enlightened days, experience is easily consulted. By identifying some of the biggest choices to be made in starting a game project and seeking out guidance, we can research a reasonable path to start out on. This post will talk about why I’ve chosen Rust, how the development environment and rendering technology were chosen, and walk through the initial installation of that environment.

Why Rust

Learning the Rust language is a core element of why I am working on this project. I’d like to briefly talk about what brought me to Rust in the first place. In my post Finding Zero I mention the two programming languages that I have worked a lot in, Mathematica and Haskell. Whilst there are lots of benefits to each, in application these languages are both limited in speed and deployment. These aren’t hard limitations, but rather aspects that come less naturally. In looking to expand my skills, I need a new language that is inherently fast and deployable. The potential speed of Rust brought it to my attention. Looking into Rust, it has two further properties I find very attractive.

Firstly, the language has an intelligent memory usage design, forcing the programmer to write code in ways that are safer with respect to causing errors, and faster with respect to execution times. Coming from the perspective of Haskell, a pure functional language with similarly memory safe design, I understand the benefit of the safety. Having programmed in a highly functional way, this safety does not even impose much of a constraint on the style I am used to. As a transition from a functional perspective, Rust appears to be as safe, even more flexible, and provide potentially greater efficiency.

The second appeal, perhaps counter intuitively, is the infancy of the Rust ecosystem. In the context of a more established language like C++, when looking for a technology solution there are a large number of options, each with the attributes of suitability, quality, and currency. This means that a relevant, well designed solution you find to a problem may not be current. For example, it may have been replaced by something else, it may have gone out of date, or it might have been abandoned. I find these kinds of problems particularly frustrating. In contrast, the Rust ecosystem is smaller and younger, and so has a reduced currency risk. The trade off for this is that we will often need to design our own solutions to Rust problems.

Choosing a development environment

In an effort to grow, rather than working with just Notepad++ and the Windows command line, I’ve forced myself to use a real Rust development environment. I am particularly wary of this, with much of my past enthusiasm fizzled out by my inability to configure the ins and outs of arcane Visual Studio dependency systems. For a review of my options I googled up Tremaine Eto’s medium.com article What is the best IDE for developing in Rust? My take away from this was that lots of people stick to what they know, with Rust support for Vim, Emacs, Sublime, etcetera. I suspect lots of these depend on that preexisting knowledge, and that from zero, I should choose between InteiliJ and Visual Studio Code (VSC). Based entirely on the Reddit feedback listed in the linked article, I chose VSC, estimating that it would generate less hassle.

Choosing 2D technology

Haven spoken on Monday about my inspirations within 2D games, it makes sense to target a particular technology to provide 2D rendering. I’ll give a brief overview of why this is important. You and I likely have different computers, perhaps with processors and graphics cards made by different companies, for a game to open on both computers, it needs to know how to talk to lots of different types of hardware. Luckily, as the people who sell all this fancy hardware would like it to work, there’s incentive for technology to exist that can talk to all sorts of hardware. This means to make a program that makes proper use of graphics hardware I must select a graphics application programming interface. These APIs span a range of complexities. On the one end, you do everything yourself, which requires a lot of time and expertise. At the other end everything is done for you, which is less flexible and comes with more overhead.

Having made cursory attempts to make games before, I know that I won’t be able to do everything myself. Whilst it’s entirely possible to learn the necessary skills, it would be very difficult to do this in tandem with the morphing requirements of a game project. This rules out working at the lowest levels straight away, such as with OpenGL or Vulkan. Luckily as the Rust ecosystem is relatively shallow, the higher level tools are easily surveyed. I found Simon Heath’s page A Guide to Rust Graphics Libraries to provide good summaries. I’m explicitly looking for a graphics technology, and not a game engine, as I’d like to start as close to zero as practically possible for flexibility. Uncertain as to the exact line between the game engines and the graphics APIs, I consulted the Discord server Game Development in Rust. Their suggestion was for wgpu, as the lowest level safe interface for Rust as of today, built on top of all of the underlying low level systems.

Step by step setup

I found the setup of Visual Studio Code on my ageing Windows 7 Professional desktop to be surprisingly painless. I’ll quickly run you through it.

  • I started out by grabbing Visual Studio Code from their website. I opened up that .exe file, decided I was happy with their default settings, and let it install.

  • I read the VSC marketplace Rust language page, which instructed me to install and update Rust.

  • I downloaded the Rust installer .exe from the rustup page and ran it to install Rust.

  • I opened the Windows command line and ran rustup update to update Rust.

  • Returning to the VSC marketplace Rust page, I clicked install to get the VSC Rust extension.

In theory this completed the basic setup, but following the Rust extension instructions, I proceeded with a test project which rounded out the installation of a few more Rust components.

  • I created a new folder on my desktop for Rust projects

  • I opened the Windows command line into this new folder and ran cargo new project_hello_cargo

  • In VSC I added the resulting project folder to the workspace through:

    • File > Add Folder to Workspace > project_hello_cargo

  • I opened the main code file, src/main.rs, in VSC.

  • VSC prompted me to install Rust components, which it did for me over a few minutes.

  • I built the project with the shortcut Ctrl+Shift+b.

  • I ran the program through:

    • Terminal > Run Task > Rust:cargo run

  • The terminal printed the program output “Hello World!” successfully.

With that, I have everything installed and tested for me to begin programming in Rust!

The next post on Friday will look into the first big design challenges on the horizon.

Previous
Previous

Leading Design Challenges

Next
Next

Inspiring Design