Note: You are viewing an old revision of this page. View the current version.

Lua is a powerful light-weight programming language designed for extending applications. Lua is also frequently used as a general-purpose, stand-alone language. Lua is free software.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, interpreted from bytecodes, and has automatic memory management with garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

A fundamental concept in the design of Lua is to provide meta-mechanisms for implementing features, instead of providing a host of features directly in the language. For example, although Lua is not a pure object-oriented language, it does provide meta-mechanisms for implementing classes and inheritance. Lua's meta-mechanisms bring an economy of concepts and keep the language small, while allowing the semantics to be extended in unconventional ways. Extensible semantics is a distinguishing feature of Lua.

Lua is a language engine that you can embed into your application. This means that, besides syntax and semantics, Lua has an API that allows the application to exchange data with Lua programs and also to extend Lua with C functions. In this sense, Lua can be regarded as a language framework for building domain-specific languages.

Lua is implemented as a small library of C functions, written in ANSI C, and compiles unmodified in all known platforms. The implementation goals are simplicity, efficiency, portability, and low embedding cost. The result is a fast language engine with small footprint, making it ideal in embedded systems too.

Lua is designed and implemented by a team at Tecgraf, the Computer Graphics Technology Group of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro in Brazil). Tecgraf is a laboratory of theDepartment of Computer Science. (taken from

also used as a scripting language for game engines by lucassoft, microsoft, etc (watch the conference at

see and

example of lua:

-- simple program that reads a config file in the format "a = b" and -- prints them to the output as "a is b"

function fileexists( file )

local f = file, "r" ) if f then

io.close( f ) return true


return false



function loadconfig( file )

print( "+ reading config file " .. file ) if fileexists( file ) then

local cline = 1 for line in io.lines( file ) do

if string.sub( line, 0, 2 ) = "--" and line = "" then

local ,,var, val = string.find( line, "(%S+)%s?=%s?(.*)" ) ; if var == nil or val == nil then

print( "! malformed line on line " .. cline .. ", ignoring" )


print( var .. " is ".. val )


end cline = cline + 1



print( "! " .. file .. " does not exist !" ) print( "! exiting.." ) os.exit()



loadconfig( "blah.conf" )


junk@lizzy lua $ lua blah.lua

  • reading config file blah.conf

a is b var is val

malformed line on line 3, ignoring

nick is scope junk@lizzy lua $