lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Lua is used in World of Warcraft for user interface scripting.  That's about as AAA as it gets.
Here's a list off of Wikipedia:
There's a few more AAA's on there as well.
In my experience as long as you keep performance critical code in C (graphics, physics, etc.) you can keep most everything else in Lua.  If you find that something in Lua is taking too long, you move it to C.  This lets you rapidly iterate on features in Lua and move them into C as they mature.  If you go into it planning for this to happen you can save yourself a lot of headache.
If I was making a AAA title I don't think I'd change that process too much.  You'd probably just find that more things are being moved into C a little more often.  Which is fine, because you'd also have more programmers ;) 
One of the keys to keeping your performance under control is to identify your bottlenecks.  If one of them is happening in Lua the easiest way I've found to fix it is to move it into C :)
In the game I just shipped we put all of our gameplay logic in Lua.  You can find some stats I posted about it on my website here:
The most expensive thing for us was calling between C and Lua.  We used Luabind to generate our bindings so there was an awful lot of function call overhead.  We also paid a little under a millisecond a frame in garbage collection costs.  We probably could have afforded the memory hit and GC'd less often but it wasn't an issue.

On Sun, Feb 14, 2010 at 4:07 PM, Mark Feldman <> wrote:
Enrico Colombini wrote:
Not bad at all. On the Nintendo DS, I was limited to a few calls per frame :-)

Out of curiosity, where did you put the Lua/C(++) boundary? What did the frame loop look like? (if you can talk about it)

I work for Infinite Interactive and we develop all of our games in Lua, although our titles are more "A" than "AAA" (Puzzle Quest is one of ours). Our main loop and engine technology is all C++, with some MIPS asm thrown in for fun, but the game code is all Lua (i.e. the game teams implement _G.OnTick, _G.OnDraw etc which then get called each frame).

Getting Lua to run well on low-end hardware can be tricky as the VM tends to hammer the cache lines pretty hard, especially on something like a PSP which has a crap bus architecture to begin with. I've done some preliminary experiments converting Lua to C by running the raw op-codes through a processor and substituting each one with the equivelent instructions from luaV_execute...idea being that you eliminate loop mechanics and disruptions to the pipeline from branching and you also take advantage of the C++ compiler optimizing away the work of extracting fields from the op-codes. If you're doing a lot of table look-ups then obviously you don't get that much of a performance improvement but for everything else the results have been suprisingly promising, with an overall 50% performance increase to the routines I've tested it on.

Mark Feldman

This message and its attachments may contain legally privileged or confidential information. This message is intended for the use of the individual or entity to which it is addressed. If you are not the addressee indicated in this message, or the employee or agent responsible for delivering the message to the intended recipient, you may not copy or deliver this message or its attachments to anyone. Rather, you should permanently delete this message and its attachments and kindly notify the sender by reply e-mail. Any content of this message and its attachments, which does not relate to the official business of the sending company must be taken not to have been sent or endorsed by the sending company or any of its related entities. No warranty is made that the e-mail or attachment(s) are free from computer virus or other defect.