Why So Many Programming Languages? I Just Want to Build a Game!

Alex J. Champandard on January 11, 2008

Despite all this talk of Open Source, it’s sadly still the case that most software is as “open” as a high-voltage transformer. Even if you manage to download some cryptic source code, you’re in for a bit of a shock unless you know what you’re doing!

Unfortunately, that’s not very good news for anyone wanting to build artificial intelligence for games. This week’s question is by SRC who asks [1]:

“I’m wondering: why all the languages? I’m trying to get oriented with programming and everything I’ve heard. It seems confusing!”

As far as helping you get started, I’ll just emphasize what I said in Getting Started with AI and Programming in Games:

  1. Pick any language and find its best tutorial. Then follow the instructions step by step. Just going through the motions is a great way to start.

  2. Once you’re comfortable, pick a random game engine and try to get the examples up and running. Then start out my making minor changes to the demos.

I recommend Python as it’s a great way to get started, but it doesn’t matter really. Try to get into the habit of being patient when looking for solutions, and persisting at solving problems yourself. You can move on to different languages later once you feel comfortable, of course.

In the rest of this article, I’ll try to explain why there are different languages and what that means for you when you’re building game AI.

Elegant Origins in Computer Science

From a theoretical perspective, there are different ways you can approach the problem of describing the behavior of a program. The following languages are typically very minimalist and some might say academic implementations of their concepts:

  • Stack-based concatenative languages like Forth, which can be surprisingly low-level as well as extensible. (Useful for memory constrained hardware primarily.)

  • Functional languages like Lisp or Haskell showing the mathematical elegance of lambda calculus. (Best at modeling high-level logical concepts.)

  • Search-based languages like Prolog that use matching and depth-first traversal of a program tree. (Work well for finding solutions to board-games, for example).

  • Object-oriented languages like Smalltalk that help group data and code into logical chunks. (Useful for representing worlds with many different entities.)

  • Procedural languages like C which map relatively straightforwardly into assembler and machine code. (Turn out to be the most computationally efficient in practice.)

It’s useful to spend a little time with these languages, if anything to expose your mind to different ways of solving the problem. I often turn to these elegant languages as sources of inspiration when implementing AI systems; there’s a lot of wisdom hidden in there.

But you can also understand these categories as different features to compare the different languages to…

So Many Other Languages…

“First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack.” — George Carrette

In practice you’ll end up using some hybrid language that combines the ideas above. There are many reasons for this:

  1. Specific languages are suited to certain problems. For example, Lua is easy to make changes to on the fly as it’s very “late bound” so it works well for expressing game logic the needs to be changed often.

  2. Industries converge towards particular languages as their standards. C++ seems to be the weapon of choice of most people in the AAA games industry, and things will most likely remain that way for a while.

  3. Vendors are keen to provide key features with their proprietary languages to lock-in customers. For instance, game developers frequently use Microsoft’s C# and .NET for user-interfaces and build tools.

Most mainstream advice you’ll get is that there’s always a tool for the right problem, and you need to use many different tools to get a job done. Is this just a poor excuse though?

Enough Excuses!

No matter which mainstream language you choose, it doesn’t detract from the fact that “coding” is a rather unapproachable task for non-technical people. It’s a rather sad situation, as Chuck Moore (inventor of Forth) points out:

“The concept that programming is something that you need special education to do is not right. It is something that is promoted by the priesthood.”

Why is that the case? If you want to be cynical, you could point out that software vendors have no interest in selling you an extensible piece of software, otherwise you wouldn’t need them anymore. The same goes for operating systems even! As for open source, if libraries were designed to be elegant, then there’d be no need for consulting or expensive documentation…

So until some fundamental paradigm shift happens that will make an intuitive and extensible language available to everyone, it seems things are not going to get much better in the short term. You’re stuck with overly complex languages and large piles of cryptic code I’m afraid!

Photo 1: Want to learn game development by modifying an existing C++ engine?

Back To Basics

On the bright side, AI programmers in the games industry are working to break down this (artificial) barrier to help the designers create behavior easily. Once designers can build a game on their own, specifying its behavior without getting lost in code, then it might even work for the general public!

The solution, as far as I’m concerned, is to go back to those basic languages and find better ways to represent and edit them. The source code itself is a big barrier to this, so you can understand my emphasis on building powerful user interfaces and editors for things like behavior trees or other languages.

Until then, don’t give up hope on becoming a programmer! The human mind is capable of learning incredible things, it just takes perseverance. So get coding. Also be sure to stay tuned to for better solutions to this fascinating problem.

Discussion 3 Comments

Andrew on January 11th, 2008

Hehe, instead of the power plant, I'd have recommended [URL=""]Babbage's Difference engine[/URL] instead :) - maybe a little [i]less[/i] overwhelming :D And you used the phrase "paradigm shift", tut tut. ;) If you're getting stuck knowing what language to pick, choose one and work with it, since trying to learn them all at once is a world of pain, especially for a beginner.

alexjc on January 12th, 2008

It's a transformer, and it fits better with my opening sentence metaphor. :-) Would you have rather I said disruptive technology? Alex

Andrew on January 12th, 2008

Hehe, that's slightly better :) I just don't trust much which use "paradigm shift" - especially out of the context of it's original [url=]science association[/url]. ;) - maybe it's just it's used too often, in too many inappropriate places.

If you'd like to add a comment or question on this page, simply log-in to the site. You can create an account from the sign-up page if necessary... It takes less than a minute!