3 ms·
I would say several things: - Its small size (the PUC Lua codebase is about 15000 lines of C and compiles to about 250 kB). PUC Lua is the reference implementa
by catwell 10y ago
I would say several things:
- Its small size (the PUC Lua codebase is about 15000 lines of C and compiles to about 250 kB). PUC Lua is the reference implementation of Lua, as opposed to e.g. LuaJIT.
- Its portability: PUC Lua is written in Clean C, the intersection of ANSI C and C++ 98. That makes it trivially portable to any architecture that matters in games.
- Its performance. PUC Lua is already faster than most popular scripting languages and uses less memory. If you need extra performance you can switch to LuaJIT and come close to C on a lot of codebases.
- The syntax is designed for data description, which makes it a very good language to implement DSLs for lots of things. Also the parser is very efficient so you can store data in Lua files.
- Coroutines. They let you propose an API to users (scripters) that appears synchronous but actually runs in an asynchronous fashion.
- The language is made to be embedded. Its C API is a central point of the design. The interpreter is reentrant so you can run several instances in threads without any problem.
All of this made Lua very popular in the game industry, along with its use in pretty famous games (initially Grim Fandango, then lots of others including World of Warcraft).