Lua is a lightweight, multi-paradigm programming language designed primarily for embedded use in applications. At the moment I am particularly interested in it because it is the only alternative to shell scripts supported by swupdate and it is also the language used to implement the application code for the Digital Loggers Pro Switch. I’m additionally interested in learning Lua to replace complex Bash programs.

Noteworthy characteristics

Based on my experience with programming languages the following includes unique, relatively novel or just plain interesting features:

Getting started

The lua compiler and VM are widely available among Linux distributions. Versions that are typically in use are 5.1, 5.2 and 5.3. LuaJIT is an alternative that supports just-in-time compilation.

LuaRocks is the package manager for Lua modules.

Unit testing

There are a ton of unit testing libraries and frameworks listed on awesome-lua and lua-users.org. A quick review based on GitHub statistics indicates that busted is the most used and well maintained. It is also one of the most downloaded modules using LuaRocks.

Execute an external application

os.execute([command]) will run command in the operating system shell and will return a status code.

io.popen(prog, [, mode]) will start a program and return a file handle that can be used to read or write to the program.