November 06, 2010 posted by Marc Balmer

About a week ago, I imported the Lua programming language, version 5.1.2, into NetBSD-current as a component of the base system.

Lua is a scripting language with a very small memory footprint that has been designed as an embedded (or hosted) language from the ground up. As such, it's integration into software written in e.g. C or C++ is straightforward. Lua is very fast, it is recognized as one of the fastest scripting languages. The language has a clear and simple syntax with some very powerful concepts; the libraries (called packages) that come with it are themselves reasonable small. Lua compiles programs to a bytecode which is executed by a very small virtual machine. Lua scripts can be precompiled to bytecode for faster load times (but not faster execution). The first versions of Lua date back in 1993, so the language is stable and mature.

Lua is excellent as a scripting language in base, because it is small, fast, and powerful and a user can learn it very quickly. For endusers, having Lua can leverage scripting in NetBSD, e.g. if an interface to e.g. POSIX functionality is used. For developers of software written in C it is a very convenient and efficient means to extend the software by a scripting engine.

Lua allows us to extend exisiting software in interesting ways, DHCP option processing in DHCP clients comes to my mind, or the system installer, sysinst, which can be made a lot more flexible using Lua scripting.

The only change I made to the default Lua distribution is to remove the current working directory ('.') from the module load paths, to avoid potential security problems.

The Lua homepage is at http://www.lua.org/, the reference manual can be found at http://www.lua.org/manual/5.1/. More information about Lua can also be found at http://www.lua.org/about.html.

[12 comments]