Why Lua

Why Lua #

In my opinion, Lua strikes a solid balance between being simple and approachable, while also being of real practical use for game development at any level of experience.

Programming is a huge field with a wide variety of different languages, and it doesn’t matter that much where you start your journey, the main point is to get started. Once you’ve begun to pick up a single programming language, many of the concepts will carry over to others if the need or desire to learn another language comes along. Experienced programmers usually end up learning and using multiple languages sooner or later.

To compare a few of the more likely starting points for game development…

Lua is a very small and light language. There isn’t a lot to learn in order to know all of what Lua has to offer. It has an approachable syntax that reads a lot like English without too much visual clutter, and is relatively forgiving to program in. Some of the games I’ve worked on are written almost entirely in Lua (Don’t Starve, Invisible Inc, Griftlands), while many other games use Lua for writing mods (World of Warcraft), plugins, or to script things like quests, or game balance.

C++ is the heavy hitter. Along with it’s predecessor C, it has the widest adoption and longest history in game development, and is “closer to the metal” than the others, providing performance advantages. Unfortunately the power and flexibility of C++ comes with a significant overhead in both number and detail of concepts that need to be understood in order to use it effectively. Many games, software applications, and operating systems are written in C++.

C# is the primary language used in Unity games, so if Unity projects specifically are where your interest lies, you might want to dive right in with C# instead. It’s superficially similar to C++ in many ways but with a reduced reliance on low level details. There is a ton of beginner material available for Unity, but much of it necessarily ignores most general programming concepts in order to present how to use Unity specifically.

In September 2023, Unity introduced confusing and widely disliked licensing changes which make me reluctant to recommend it as a starting point unless you otherwise have a specific reason to.

Python strikes a bit of a middle ground, being reasonably approachable and easy to use, while also having much greater range of out of the box functionality than Lua. I’ve used Python mostly for things like graphics conversion tools and build server scripts. It’s widely used for web services (Google, Facebook, YouTube), and financial and scientific computing. There are some game development focused frameworks for Python such as pygame and renpy.

Why Love2D #

Love2D is a small and simple 2D game engine, which uses Lua as its scripting language.

The existence of Love2D is one of the biggest reasons I think Lua is a good idea for a first programming language with an eye towards game development. Lua doesn’t do much by itself and relies on a game engine to provide all of the functionality that you normally associate with games: drawing graphics, showing images and text on the screen, playing sounds, responding to input from the mouse, keyboard and controller… and this is what Love2D takes care of.

It’s a clean and straightforward engine that doesn’t require much additional knowledge to use beyond Lua basics.

Using Lua with the Love2D engine provides a short path from programming basics to practical game development, with no big leaps or curve balls thrown in. At the same time it provides real practical development experience, and isn’t just a toy useful for learning but not for “real programming”. Love2D is especially useful for game-jams and prototypes, no matter how experienced you become as a programmer.

There are even a handful of indie games written with Love2D on Steam.

Get Started