About Lua

TL;DR

Lua is dynamic language, comparable to JavaScript, Ruby, Python, Scheme, etc.

However:

Dynamic

Lua is dynamic language, comparable to JavaScript, Ruby, Python, Scheme, etc.

Dynamic programming language is a term used broadly in computer science to describe a class of high-level programming languages that execute at runtime many common behaviors that other languages might perform during compilation, if at all. wikipedia

For example, where a variable in C has a type bound to it which cannot change (static typing), a variable in Lua is just a name under which any type of value can be stored. (In a way, all variables in Lua behave like pointers.) More interestingly, any string of valid Lua code can be executed from within another script; opening the possibilty of generating new functions at run-time. Data structures can change size and layout during execution, and functions can be passed around just like any other object, all according to the vagaries of user input. (Some of these features are possible in C/C++ with a lot of clever coding, but the cleverer that code gets, the more it becomes like the virual machine of an interpreted langauge anyway…)

If dynamic languages are more flexible, adaptable, and extensible, why do people use static languages like C/C++/Java?

Usually the argument goes that dynamism implies less efficient performance; however through the use of just-in-time (JIT) compilation, LuaJIT can approach and sometimes even exceed the speed of C/C++! It does this by recording “traces”: converting the most heavily used (“hot”) code paths into optimized machine code, including complex traces running through different loops and function call chains.

Many of the recent innovations increasing the speed of JavaScript in modern web browsers use similar techniques as LuaJIT. An interesting, though very technical, discussion here.

Expressive

Lua began as a data-description language, and continues to benefit from a universal and flexible array/hash data structure. The syntax is largely procedural, however it supports fully functional programming features such as first-class functions, closures and coroutines, and lexically scoped upvalues (granting capabilities similar to Scheme)). It also supports various models of inheritence through a prototype inheritence chain (conceived in Self) and also used in JavaScript). The runtime is also fully re-entrant.

Documentation and Resources

Programming in Lua

This book is excellent. Get it from here:

PiL

Programming in Lua (second edition)
by Roberto Ierusalimschy
Lua.org, March 2006
ISBN 85-903798-2-5 (also available as an e-book)

Programming in Lua is also available in German, Korean, Chinese, and Japanese.

The Lua 5.1 Reference Manual

Another excellent resource. Fortunately, it is available online

Reference

Lua 5.1 Reference Manual
by R. Ierusalimschy, L. H. de Figueiredo, W. Celes
Lua.org, August 2006
ISBN 85-903798-3-3

In particular, this is the URL that should be bookmarked.

The Lua and LuaJIT mailing lists

Lua-l, and archive.

Note that LuaJIT, and thus LuaAV, are based on Lua 5.1 syntax (with some Lua 5.2 features added), so some discussions on lua-l will not apply.

LuaJIT mailing list, and archive.

Other Lua guides

Some tutorials on the Lua Wiki

This unofficial FAQ may also be useful