Lua? Are you out of your mind?
Jan 30, 2014
5 minute read

But Amos! You’re the ooc dude! I thought compiled languages were way better! Or faster, at least! And safer! And better for large projects!

Why would you try and use a scripting language for something high-performance like a game? Can’t you see you’re doing it wrong?

So, yeah, I’ve started tweeting around that I’m experimenting with moonscript and luajit. And suddenly my timeline starts going batshit crazy about it. Well, let me tell you what I have in mind.

Developing a game is hard. Like, directing a musical hard. But wait, developing is the wrong term - I’m not just programming a game here (ie. writing the code that makes the stuff on the screen happens), I’m also jointly designing it. And testing it. And marketing it. And making the soundtrack. And drawing it. And so on. And if I can find something that will make my life easier, trust me, I’m gonna do it.

I’ve been having a hard time with a certain brand of behavior lately, on Twitter and elsewhere. I call that behavior “theoretical fanaticism”. It’s when someone is really really convinced that something is possible in a given way, and that they honestly can’t see why anyone would ever want to try it any other way.

For example, it’s possible to write a full launcher and upgrader using only C++ and QT. But for Lestac’s launcher, I rolled with node-webkit - for the cost of about 30MB of webkit runtime. And Riot rolled with some bastard internet explorer embedding for the LoL launcher. And Steam also has an integrated web browser, because it makes sense for them.

Wait, am I saying people are going to download 30MB before they can even start downloading the game? Sure! We’re in 2014. It saves me dev time, if we want to do a mod browser, we can do it, it’s trivial to update the launcher, porting it was a non-brainer, it’s one less native thing to worry about cross-compiling, hey, I’m on board with that.

So, lua eh? It’s pretty much the same thing. It is possible to keep iterating on a game’s design in a compiled language such as ooc. In fact, it’s easy, even. The module system is nice, the build system is nice, I almost never run into cross-platform issues anymore, recompiling is rather fast… why would I even bother with one of those, uh, kiddie scripting languages?

Well, for one, we have a shitload of stuff to prototype. I will write code that we will throw away. While it might be harder to organize code in a dynamic language, it’s certainly faster to write at first. So even if i end up porting portions of that code to ooc later, for performance, it’s all good.

Two, I don’t want to be the only one to code. Learning ooc is not that hard (heck, having a compiler hand-holding you is probably friendlier than running into all kinds of runtime errors), but it’s still a hassle to recompile the game every time. A small hassle, but it adds up.

By using a scripting language for game logic (basically, entity behaviours) while keeping the 2D engine and the physics all in ooc, I’m getting the best of both worlds - a fast core, and a very customizable game. I’m at a friend’s place and all she has is Windows XP? Fuck that, I’m not installing mingw, let me just fire up Notepad++ and quickfix that enemy by editing a .moon file. Bam.

And three, it opens a whole new dimension of customization for players. Just look at how Don’t Starve is engineered. The folks at Klei could have written a skeletal animation tool from the ground up - but instead they used Flash, exported to a custom XML+PNG format, and wrote their animation engine in C++ - best of both worlds. And they’re using Lua for all in-game events. Makes perfect sense to me.

As developers, we tend to be obsessed by the technology we’re using, and have strong opinions about how things should be done. Well, I have good news: chill the fuck out, because there are a gazillion things that will get in your way other than technology, so you might as well make your bed comfy: you’re going to be sleeping there a long time if you want to ship anything worth a damn.

So, I’m rolling with the punches here - I’m pretty sure two years from now I’ll still get remarks about how dumb my tech choices are (disregarding the fact that I’ve been thinking several years about them) - much like there are still people poking Edmund about how silly it was to use Flash to make The Binding of Isaac.

And yet, it was the right thing to do - Florian & him knew the tool inside out, and they chugged an insane amount of content in a very respectable time frame.

If you stop thinking about the most perfect codebase and start thinking of every game project as a huge experiment in game design and iterative learning, then you’ll stop being so passionate about tech stacks argument.

And if your game design is so rigid that you can implement it from 0 to 100 in a statically typed language without even thinking twice about the structure of your code well congratulations, I hear King is hiring.

P.S: This post might sound angry or aggressive — please believe me when I say it’s not meant to. I just feel strongly about this. That said, I won’t try to convince you to follow the same path: whatever works for you. But please, please, if you’re planning to keep arguing with me about that, please consider how many games I have written in compiled languages before. Maybe if I’m changing strategies at some point there is a reason! Who knows? Happy game making!