Andreas Rozek Hints for Reading List of Recent Changes Guestbook Entry Contact the Author  Deutsche Version  HomePage Previous Topic Next Topic  First Page of Current Topic Next Page Previous Page


Despite its simplicity, the scripting language Lua [1] offers a remarkable potential, primarily because of a few "Meta Mechanisms" [2] not found in other languages.

The following pages give a brief overview of Lua and document the author's activities with respect to an evaluation of that language in the context of his Ph.D. thesis.

Please, also consider my "Hints for Reading" and the "List of Recent Changes".


The list of topics given below directly guides you to the desired information - just click on a topic of your choice:

  • Lua in brief - a brief description of the language and some important extensions
  • Distributions - Lua, TkLua, LuaSockets compiled for Win32 systems
  • Acquainting - a systematic approach to Lua programming
  • Modules - scripts for basic Lua functions
  • Examples - simple and less simple Lua and TkLua programming examples
  • Applications - stand-alone applications written in Lua/TkLua/LuaSocket
  • Miscellaneous - additional Lua stuff

Lua in brief

Development of Lua [1] began in 1993 by Roberto Ierusalimschy, Waldemar Celes and Luiz Henrique de Figueiredo at TeCGraf, the "Computer Graphics Technology Group" of "Departamento de Informática" (DI) at the "Pontifícia Universidade Católica do Rio de Janeiro" (PUC-Rio)[2]. Originally, Lua started up as a data description language with the intention to simplify the construction of parameter files for numerical simulations - meanwhile, it has become a generally applicable scripting language.

Lua uses a procedural syntax with comfortable mechanisms to describe data by means of associative arrays ("tables"). Data types are "dynamically" bound: while "variables" don't have a fixed type associated to them, "values" have. Prior to its interpretation by a "virtual machine" (VM), Lua source code will be compiled into an intermediate "byte code" - either explicitly using a Lua compiler or implicitly at run-time. Memory management is performed by the run-time system itself, an automatic garbage collection removes values from memory as soon as they are no longer in use.

A few "Meta Mechanisms" allow the implementation of mechanisms, which the Lua designers deliberately decided not to provide. E.g., while the language itself lacks important details of object orientation (such as single or multiple inheritance), these can be easily added with a few Lua statements. Lua designers call this feature "extensible semantics".

Lua has been primarily designed as an "extension and configuration language" and is foreseen to be integrated into a C/C++ application. It has been implemented in ANSI-C as a set of separately loadable libraries and can be easily ported to new platforms. An explicit C API (application programmers interface) allows the smooth interaction between Lua statements and objects or functions of a run-time environment. Nevertheless, by means of a simple shell application it is also possible to run "stand-alone" scripts.

The Lua licensing conditions [3] allow the utilization of Lua free of charge even for commercial applications.

A final note on the name "Lua": "Lua" means "moon" in portuguese - an allusion to the fact that the language is a successor of "Sol" (Simple Object Language), the portuguese word for "sun".

Important Extensions

Apart from the language itself, there are a number of important extensions such as:

  • tolua [12]
    based on the "canonicalized" form of a C/C++ header file, tolua automatically generates any "glue" code required to access C/C++ constants, variables, functions, classes and methods from within Lua scripts;

  • TkLua [13,14]
    allows the utilization of Tk widgets (and Tcl commands in general) from within Lua programs. Almost all Tk features are available for Lua programmers - in a (compared to Tcl itself) much more comfortable manner;

  • LuaSocket [15]
    extends Lua with a number of important IPv4 functions (DNS, TCP and UDP) and some higher-level protocols (SMTP, HTTP & FTP).


[1] The Programming Language Lua
the given address is the primary starting point for any investigation about Lua: from here you are directed to Lua distributions, documentation, additional libraries or tools - and you may get in contact with other Lua users;
[2] Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
this web page contains a brief description of the Lua language;
[3] Lua Copyright notice
not just for the company's laywer: the Lua licensing conditions;
[4] Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
Reference Manual of the Programming Language Lua 4.0
the official reference manual contains any relevatn information about the language itself, the set of standard libraries and its interface to the run-time environment;
[5] Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes Filho
Lua - an extensible extension language
Software: Practice & Experience (No. 6, Vol. 26, 1996), p. 635-652
this paper describes the fundamental characteristics of Lua (and its integration into applications written in C/C++), sometimes backed by source code examples;
[6] Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
Lua: an Extensible Embedded Language
A few metamechanisms replace a host of features
Dr. Dobb's Journal (No. 12, Vol. 21, December 1996), p. 26-33
this article describes the most important characteristics of Lua and TkLua. A number of source code examples illustrate the given descriptions;
[7] Reuben Thomas et al.
Technical Notes
the (extensible) series of "Technical Notes" describes particular language- and application-specific issues related to Lua;
[8] Lua 4.0 - Source Code and Platform-specific Distributions
the given page refers to the original source code and a number of binary distributions for several platforms;
[9] Win32 Port of Lua 4.0
the given ftp directory contains Lua libraries for several C development systems (Borland, Visual Studio, Watcom) and ready-to-use executables for execution and compilation of Lua scripts - for Win32 platforms;
[10] Philippe Lhoste
Lua Page

another Lua distribution (including project files) for Win32 platforms is provided by Philippe Lhoste;
[11] Lua Addons
this web page refers to a number of additional Lua distributions, libraries and applications;
[12] Waldemar Celes
tolua - accessing C/C++ code from Lua
tolua simplifies the construction of Lua interfaces for existing f C/C++ code. The given web page explains the underlying mechanism of tolua and describes how to use that tool;
[13] Waldemar Celes
tklua - Binding Tk to Lua
TkLua provides support for Tk widgets (allowing to construct graphical user interfaces) from within Lua scripts. The given web page describes the "basic concepts" behind TkLua and explains how to use it from within Lua scripts;
[14] Christian Vogler
TkLua (4.0a1)
since the original distribution of TkLua [13] has been developed for Lua versions prior to 4.0, Christian Vogler ported TkLua to the new Lua 4.0 API;
[15] Diego Nehab
LuaSocket - IPv4 Sockets support for the Lua language
LuaSocket provides support for a number of important IPv4 functions. From the given web page you will be referred to a description of LuaSocket as well as to source code and binary distributions;
[16] Tcl Developer Site
you will have to install Tcl/Tk in order to use TkLua. The given web page is a good starting point for any further investigation of Tcl/Tk;
[17] Download Tcl/Tk 8.3.4
you may download Tcl/Tk 8.3.4 from the given page - this version is needed for TkLua;


Please, consider also the author's Disclaimer!    (last Modification: 12.06.2002)