Introduction to Lua Programming

Written By: S Kokila

- 31 Aug 2007 -
















Description: Lua is a powerful, light-weight programming language designed for extending applications. Coupled with it being relatively fast and having a very lenient license, it has gained a following among game developers for providing a viable scripting interface. It has been used in games such as World of Warcraft and Far Cry, and in applications such as Adobe Photoshop Lightroom and Snort.

  1. What is Lua?
  2. Getting Started
  3. Identifiers, Types, and Values
  4. Variables and Expressions
  5. Operators
  6. Statements and Assignments
  7. Control Structures
  8. File I/O

What is Lua?

Lua is a powerful, light-weight programming language designed for extending applications. Lua is also frequently used as a general-purpose, stand-alone language. It is dynamically typed, interpreted from opcodes, great facility to handle strings and other kinds of data with dynamic size, and has automatic memory management with garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

Lua is easily extended not only with software written in Lua itself, but also with software written in other languages, such as C and C++. Lua is also a glue language. Lua supports a component-based approach to software development, where we create an application by gluing together existing high-level components, written in a compiled, statically typed language, such as C or C++; Lua is the glue that we use to compose and connect those components. However, unlike other glue technologies, Lua is a full-fledged language as well. Therefore, we can use Lua not only to glue components, but also to adapt and reshape them, or even to create whole new components.

When to use Lua?

Lua is not the only scripting language around. There are other languages that you can use for more or less the same purposes, such as Perl, Tcl, Ruby, Forth, and Python. The following features set Lua apart from these languages; although other languages share some of these features with Lua, no other language offers a similar profile:

For detailed information on Lua, please refer to the book Programming in Lua by Roberto Ierusalimschy, and Lua’s official site www.lua.org.

Next >>