Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Why is Lua considered a game language?

I have been learning about Lua in the past month and I'm absolutely in love with the language, but all I see around that is built with Lua are games. I mean, the syntax is very simple, there is no fuss, no special meaning characters that makes code look like regular expressions, has all the good things about a script language and integrates so painlessly with other languages like C, Java, etc. The only down-side I saw so far is the prototype based object orientation that some people do not like (or lack of OO built-in).

I do not see how Ruby or Python are better, surely not in performance ( ). I was planning on writting a web application using Lua with the Kepler framework and JavaScript, but the lack of other projects that use Lua as a web language makes me feel a bit uneasy since this is my first try with web development. Lua is considered a kids language, most of you on Stack Overflow probably only know the language because of the WoW addons. I can't really see why that is... provides some insights on Lua against Python, but this is clearly biased.

share|improve this question
Check out the Squeezebox Duet and Harmony 1100 from Logitech. Both use Lua, and with the Duet you can even write your own plugins in Lua. – patros Feb 12 '09 at 20:59
Though this page doesn't mention Lua as much as Ruby and Python, I think it's relevant for discussing scripting languages in general: – magnetar Sep 3 '10 at 18:38
I don't find mentioned comparison to be biased, at least not towards Lua (and I'm an avid Python user myself). – fijal Feb 15 '11 at 0:57
The asker tresspassed overtly into language-war territory with comparisons to Python and Ruby. We already have a million threads like this, and yes they're popular, but it doesn't mean they are in keeping with this site's objectives. – Fixee Jul 10 '12 at 18:21

closed as not constructive by Will Nov 11 '11 at 21:34

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

23 Answers

up vote 39 down vote accepted

Languages rarely become popular simply on the merits of their technical features. Ruby languished for a decade, more or less, before people noticed it because of Rails. Lua would be a complete unknown without WoW's programming APIs. Lua is no more a "gaming" language than Ruby is a "web" language.

share|improve this answer
except for the fact that lua is not only used in WoW, it is used in a wide variety of games for scripting ad-ons. This is not the answer you are looking for. – Brian Leahy Sep 16 '08 at 7:31
-1 Wrong answer, developers use Lua for AI scripting and game play in all sorts of games. This is as a professional Game Developer myself – Robert Gould Dec 12 '08 at 10:13
Yeah, Lua was known and popular as a lightweight embedded language before WoW. And it's mostly because of the merits of its technical features. – Dan Olson Apr 15 '09 at 20:41
He isn't saying that Lua wasn't used before WoW any more than he's saying Ruby wasn't used before Rails. He's saying that WoW was arguably Lua's first step towards significant general awareness, just as Rails was Ruby's. – Ben Blank May 16 '09 at 0:22
"rarely become popular simply on merits of their technical features"? I don't think so. Lua became popular because it has an easy API, it has fast compiler and very fast VM with low memory footprint. Lots of games used it before WoW for these reasons. And you think people made this decision without regard to the technical features? – Nick May 21 '09 at 9:46
show 15 more comments

Speaking as a game developer, the games industry loves Lua because it's so lightweight. The size of Lua's runtime, its performance and memory usage, are an incredible combination compared to other languages. Game developers are highly paranoid (whether or not justifiably) about these things, which partly explains why Python, Ruby etc haven't been used much as game scripting languages.

It's also trivial to embed, and highly portable (with all the different console platforms around, this is extremely important).

As a result, Lua is the choice of the games industry, but that doesn't necessarily mean that's all it's good for.

I would also say WoW used it because it was already popular among game developers, not the other way around. However, because WoW uses Lua to allow extensibility or customisation, rather than just as an internal technology, it certainly raised Lua's profile outside the game development community.

share|improve this answer
The lightweight runtime is especially attractive for console developers, who must be much more careful about memory usage. On the PC side you see more developers willing to experiment with "larger" scripting languages like Python. Firaxis (Civilization IV) would be a good example of that. – Nathan Sep 16 '08 at 17:37
Doesn't this answer only address the "why lua is a game engine" side and not the "should I be afeared to use lua for web development" ? – Ziggy Dec 27 '08 at 12:41
It's Lua, not LUA. It's not an acronym. It means moon in Portuguese. – Nick May 21 '09 at 9:48
While Firaxis chose Python for Civ4, they switched to Lua for Civ5. – David Harkness Aug 20 '12 at 23:51

I'm surprised that no one has mentioned the Big Three of network security yet. Lua is used as an embedded language in nmap, snort, and wireshark. Writing a Wireshark packet dissector is an exercise in concision. A carelessly written dissector will really slow you down when you have a few hundred thousand packets to load. Lua is fast, as many have said already.

share|improve this answer
Excellent observation. Seems a natural choice for product extension. – unhillbilly Jul 7 '10 at 20:36

Lua is a great scripting language: it is extensible, it is simple to learn, and provides the basic primitives such that programmers can use OOP or functional programming (in the same league as Scheme and Javascript). It is one of the few scripting languages with support for coroutines, which help a lot when doing multi-threading programming.

In my tests (and I am an addict when it comes to programming languages) ... Lua is the fastest dynamic language I ever worked with. It is also very small, and can be embedded easily in a C/C++ application.

I think that Lua has all the qualities of a scripting language used for coding game logic. And game shops experiment with all kinds of technologies, from Lisp to Haskel, and Lua just happens to be a good compromise between flexibility and speed.

Lua is also not appropriate for web applications for a number of reasons ... lack of libraries, and (most annoying for me) a total lack of unicode support (although Ruby has this same flaw, and few people are complaining ... but still, it matters).

share|improve this answer
+1 for It is one of the few scripting languages with support for coroutines – Ian Ringrose Aug 22 '10 at 15:52

Last time I looked at Lua (just before falling in love with Python), this was version 4.0, 5.0 there too, there were a ton of Lua distributions around: Each with its own set of libraries.

What makes Lua a game language? Without a standard library that can actually do stuff I would want to do, it is limited to areas where this isn't much of a problem: Embedded scripting languages. You're not supposed to be able to do stuff to anything but your embedding application (game, editor/IDE, etc.), and a lack of standard library is a plus here!

share|improve this answer
Lua is supplied as source code and was designed to be an embedded language. A small set of standard libraries is supplied, but the idea is that you expose your application to Lua so that you can script things. These is no sense in having a standard "game library" as all games are different. Python is more of a standalone language and has more general purpose libraries. I use both for different purposes. – Nick May 21 '09 at 9:55
Lua is a natural fit where a plugin language is needed. Games need plugins. Lua == game language: Missing a logical step here. Once you see the "I need small, embedded language" is a common requirement for game development, you see why Lua is so often embedded into a game. Ironic then, that the OP is "worried" about using something that "is only for games", when in fact, game developers tend to not use anything that isn't super reliable. So, if it's good enough for WoW, it's NOT good enough for your lil' website? :-) W – Warren P Jun 10 '10 at 15:54

Just to correct David Locke's post, in which he wrote:

Python is distributed under the GPL. This means that embedding the Lua interpreter in you game won't require you to distribute the source code to the game.

Python is distributed under it's own license and even clarifies:

There is no GPL-like "copyleft" restriction. Distributing binary-only versions of Python, modified or not, is allowed. There is no requirement to release any of your source code.

share|improve this answer
This does not answer the question. (You should downvote the respective answer, and supply a comment, instead.) – Arafangion May 15 '09 at 1:01
@Arafangion, it answers the question indirectly as the author is comparing Lua with Python. I'm voting +1 because people thinking Python = GPL is a common misconception. – Unknown May 16 '09 at 0:50

Adobe also chose Lua for writing Lightroom plug-ins.

I haven't done anything complicated with it yet, but so far, so good...

and as I have since been told/discovered, most of Lightroom is written in Lua.

share|improve this answer
IIRC, most of Lightroom is in fact written in Lua, not just plugins. – Matthew Schinckel Sep 16 '08 at 8:02

I just want to underscore a point that's been made here already. The three things that make Lua more attractive to a game developer than other interpreted languages are:

  1. Memory
  2. Memory
  3. Memory
share|improve this answer

Lua is popular because is it very quick to achieve simple tasks. I've been looking at LOVE, which is game framework built using Lua, and you really can get up and running with just a few lines of code. You don't need any special IDE (any text editor will do), and your code is not bogged down with a whole bunch of package, class and import declarations. Best of all your game will run on Windows, MacOS and Linux without any changes.

LOVE Game Screenshot

share|improve this answer

From your link:

Python has a nice simple syntax and behaves "as you would expect". ie. no gotchas for scripters like undeclared local variables default to global.


Lua programs are much more error prone, due to automatic coercion, accessing of unset variables without an exception, and having to check most functions for nil values, rather than just catching the exceptions.


Lua handles only one type of numbers, usually C doubles or floats, which can lead to overwhelming processing.

In short, Lua is designed to be a small simple language for the scripting of applications. There's nothing wrong with this, and it's an excellent language for its intended purpose. But for writing applications entirely in Lua, it's a nightmare.

share|improve this answer
"But for writing applications entirely in Lua, it's a nightmare." I this from personal experience? What were some of the problems you faced? Did you write the original code or were you a maintainer? – Jon Ericson Sep 19 '08 at 8:02
Some experience with Lua, and much experience with similar "loose" languages. The "all numbers are floating-point" means slow and inaccurate math. Type coercion, automatic globals, and no error on failed attribute are also features of Javascript -- ones I could live without. – John Millikin Sep 19 '08 at 17:55

Lua was used in games LONG before WoW, and had a good reputation in the industry in those times as well. The reason why Lua is picked for games is because it's very lightweight, and simple to learn. Ruby and Python are more powerful languages, but to achieve that they lost speed and a bit of simplicity.

It's not a question of which language is "better". It's a question of which language best suits you needs. Ruby became a web language because of Rails, but it's a more than decent general purpose language as well. It would just never be useful in games because it's dog slow.

Python is used in some big games, but not as often as Lua.

It's just a matter of asking yourself which language you would like to use most, although I think that Lua will require a lot of scaffolding code to get a web application properly working.

share|improve this answer
"Ruby and Python are more powerful languages" -- I think that without defining "powerful" that statement carries no meaning... :-) – Jay Nov 12 '10 at 10:20
Generally speaking... anything Ruby and Python can do, so can Lua. – Steven Jul 29 at 22:29

To Till and Tanoku: Lua is not an acronym, it just means moon in Portuguese (coming from Brasil).

Lua is used in many applications beside games. For example in SciTE, a lightweight text editor. It is also used a lot in embedded platforms. A number of applications using Lua are listed in the Lua wiki and Wikipedia. Indeed, the fact it is very portable (runs on nearly all platforms, including game consoles from Xbox to NDS), lightweight yet powerful, fast and easy to integrate to C or C++ code (and other languages as well), and with a user-friendly syntax (important to be used by game designers or other non IT professionals) makes it a first choice as scripting language.

share|improve this answer

I've been fond of Lua since 2002 - 6 years now. It's foremost publicity comes via games, but they are in no way the "the" thing of the language. Lua wasn't even created with games in mind.

However, games do benefit from all the goodies of Lua; high performance, good productivity, small footprint, very high portability. One reason why Lua's been big there is that unlike desktop world, game scripts don't traditionally need to be backwards compatible.

To me personally, Lua is about the merger of Lua and C(++). It's about two languages working together, and bringing more onto the table than any single language does. Objective-C is like two languages baked in one (bad, because brain needs to jump line-by-line instead of by source file). C++ and C# will by definition not gain the dynamicity benefits of dynamic languages.

I know some people behind the Kepler effort; they sure are using it and there's support. You won't be alone. :) Welcome.

share|improve this answer

Think about what is required to actually make a game; I think it's actually a compliment to the language. Graphics programming (lots of heavy 3D math), interface programming, physics simulation (again, hardcore math), AI, and all running at 60 Hz. And on a console, you pretty much have to pack your own OS; there's no 'malloc' or 'fopen', you need to provide memory allocation, IPC, sometimes even a scheduler. And your own scripting environment, including all the interface between the core and the VM (you're not just running scripts on top of a framework that somebody else ships, you have to build your own). And Lua is perfect for this, because of the reasons mentioned before.

So unless you're some kind of badass kernel hacker, you don't get to call game development a task for "kids" :)

share|improve this answer
Hello, 1990. Modern consoles provide all sorts of OS support. – Fraser Jan 12 '10 at 9:32
What? Every console I know runs an operating system. Heck, Xbox 360 provides a full-featured framework and lots of tools (and the other bigs ones probably do as well). – Mircea Chirea May 12 '10 at 12:38

Lua works great as an embedded language in a larger project and it's a lot easier to teach to non-programmers. This makes it a good tool in game development, as you can have game designers with close to no knowledge of general programming techniques testing and modifying AI and quest scripts and the like.

Add to this its performance profile (both memory and speed-wise) and its permissive license (you can basically do whatever you want with the interpreter) and you'll see why it's such a hit.

share|improve this answer

Although a little off-topic, it's interesting to make the comparison with the (lastest) upcoming replacement to TeX called "LuaTeX", which will have a Lua interpreter built-in. It was chosen for all the same reasons quoted above that the game industry (apparently) like it for: lightweight and flexible, so it's not dragging a huge swathe of code into a program that is mainly looking for "just a scripting language" in which to implement algorithms and perform calculations.

share|improve this answer

Having used Lua extensively, I see why it's not used more often in non-game projects. Its dynamic nature and default global scoping doesn't play well for writing large applications. It can be done, but you'll have to be aware of those 2 issues and program around them (your own typing scheme and global guards).

share|improve this answer

Lua is a scripting language, I've actually only seen/used it in the lighttpd and MySQL (MySQL Proxy) areas. I've personally played with it when experimenting with the MySQL proxy.

I never heard of it as a game language. I think Lua was primarily written to be embedded in other languages and to still offer great performance. Due to its nature (compiled bytecode), it's also platform independent which is sometimes a huge advantage.

Some people also think of Lua as a configuration language since its syntax is pretty elegant and simple and suitable for configuration files.

As for stand-alone, I wouldn't know how to get started. I'd have to research this as well. If you are just doing it for the sake of research and learning, then it's great - but I wouldn't do it just because it's possible.

share|improve this answer

Actually, Lua was widely used for game scripting way before Blizzard used it for World of Warcraft GUI modding.

One of the best graphical adventures of all times, Grim Fandango, was fully scripted in Lua.

On a related note, the newly released MMORPG Warhammer Online also uses a mixture of XML and Lua for it's graphical user interface.

share|improve this answer
love that game :D – George May 25 '10 at 3:57

As the others had said, Lua is chosen primarily because of how lightweight it is. The popularity of World of Warcraft has certainly helped Lua become more known to the general public, but it has been in use for a long time. Other prominent games that uses Lua are Neverwinter Nights, Everquest 2, and most recently, Crysis.

share|improve this answer
Actually, Neverwinter Nights does not use Lua. NWN has its own special scripting language. However, the Baldur's Gate family of games -- also from Bioware -- do use Lua. – Adam Crossland May 28 '10 at 19:30

For some background on the history of Lua in game development check out the slides from the GDC 2010 tutorial "Lua in Game Dev":

share|improve this answer

As for still other uses: there's also the Kepler Project for developing webapps, working with any webserver that supports (F)CGI, and even has it's own webserver written entirely in Lua. An example project using kepler is the Sputnik wiki engine. Another free-standing web project is the Nanoki wiki engine (which in fact only needs Lua and luasocket to be present).

As such a claim as "Lua is not apt for web programming" is untrue.

share|improve this answer

Lua is not used for game engines, games have always been made with C++ simply because its fast. Even with the evolution of programing C++ still remains the industry leader, its because programmers can create far more sophisticated game centric algorithms.

Lua is used only as a form of scripting to make mod makers lives easier, though some recent game titles do utilize Lua but not completely the core of the game engine still remains C++. It is because its a corporate world and nothing runs directx faster than C++ just try creating an example dx code in another non MS language your guaranteed to run into trouble.

Personally hate Lua its a dirty code to work with, it maybe simple but simple doesn't mean better result and if you have modded any games made with Lua you would quickly realize how messy it is. With Lua the simple things will always seem simple.

It is also one of the easiest programming languages to hack you can practically copy paste physical actions within games into a text editor and see its code. Thus anyone can write injection code that can screw stuff up if you catch the drift. No mmo's don't use lua the companies would be screwed in the rear end. Game UI has almost always been done in XML.

share|improve this answer
Injection code and 'dirtiness' are generally the fault of the API, not of the language. Do you have examples where the language limits the API and makes it 'dirty'? – Computer Linguist Aug 21 '11 at 19:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.