Programming Games by Hand Using the Odin Programming Language

Patrick O'Dacre
Handmade Games

--

Odin has been designed for modern systems programming. It is practical, easy to learn, powerful, and fun to write.

With a number of officially-supported bindings for gamedev libraries like SDL2, Odin is the perfect language for programming games from scratch.

If you’re interested in programming games from scratch using Odin, you can learn along with me at Handmade Games on YouTube.

If you’re interested in programming games from scratch, you’ve probably agonized over how to get started.

You could use an existing tool, you could write everything from scratch, or you could do a little bit of both.

I really like the idea of programming everything by hand. Learning how to use an existing engine like Unity or Godot isn’t easy. If you’re going to invest hours upon hours into learning something, you may as well apply yourself to building something from scratch.

Choosing a Programming Language

When deciding on a language I knew I wanted the following:

  • no garbage collection
  • a simple language
  • a simple toolchain
  • online resources to help me learn game dev using that language

I considered the following languages:

  • C
  • Rust
  • Odin

Each language has aspects that appeal to me.

What about C?

When you’re learning it’s really helpful to have an abundance of resources, and because the C programming language has been around forever, there are many examples of how to make games with it. My favorite resource, Handmade Hero, is a prime example.

I like writing C, and I believe I would really enjoy programming with it, but I would like to have a few more modern conveniences if possible.

Rust? not so much…

I really appreciate Rust’s toolchain and learning resources. I wrote Rust professionally for about 6 months when I was working on a Substrate-based blockchain, and all of these resources really helped me be productive.

But I’m sorry to say that I don’t like Rust very much as a language. I found it very tedious to follow along with all the traits, type aliases, impls, etc. I like simplicity, and Rust is complex.

Couldn’t I just write my own Rust code to be less complex? Of course, but Rust has one more thing I don’t like — ownership semantics.

Rust has a particular approach to memory management. It is A way to write code, not THE way. And while ownership semantics may work well in a lot of applications (I’m not sure that it does), I don’t find the approach particularly compelling in a gamedev context.

Hello, Odin

I chose Odin for many reasons.

Odin in simple.

Odin is simple like C. The language is very practical and offers many useful features like array programming, slices, bit sets, and more.

Odin doesn’t use garbage collection.

Odin is fast and modern like Go, but it doesn’t have a garbage collector. I want to get more experience with manual memory management, and using something like Go doesn’t allow me to do that.

Many C tutorials are easy to translate to Odin.

Odin offers officially-maintained bindings for helpful libraries like SDL2. Unlike the Rust bindings which are more “idiomatic”, Odin’s SDL2 bindings are identical to C, so any gamedev tutorials using C is easily translated to an Odin program.

Visit the official site for a full list of Odin vendor libraries.

Odin is for getting stuff done.

And finally, as icing on the cake, I have been regularly impressed by the care and thoughtfulness that has gone into the design of the language.

It has been designed by someone who actually ships software — Ginger Bill. He has put a lot of thought into how Odin works, and it has been battled-tested and refined in the real world. There has been a deliberate effort to create a language that is incredibly powerful but easy to learn, and fun to program with.

At the end of the day, I want to enjoy the language I’m using, and Odin certainly delivers.

What Others Say About Odin

If you’d like to read what others think about Odin, I recommend the following posts:

--

--

Patrick O'Dacre
Handmade Games

Coffee-fueled Programmer. I like making games and web things.