Lua is a lightweight, compact, and fast programming language designed as an embeddable scripting language. This cross-platform interpreted language has a simple syntax with powerful data description constructs. Lua aims for simplicity, small size, performance and portability. It has automatic memory management and incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.
In the popularity takes, Lua lags behind say Python, Perl, or Ruby for scripting purposes. And Lua is not designed to develop standalone software. But Lua excels as a secondary language. Witness Lua cropping up in kernels, tools, and games.
Lua is free software distributed under the terms of the MIT license. Lua’s developers consist of a team at PUC-Rio, the Pontifical Catholic University of Rio de Janeiro in Brazil. The language has been in development for more than 24 years.
We publish a series covering the best open source programming books for other popular languages. Read them here.
By Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes (HTML)
This reference book describes version 5.3 of the Lua programming language and the Application Program Interface that allows interaction between Lua programs and their .host C-programs. The book provides a thorough treatment of the latest version.
The book explores:
- Basic concepts – describes the basic concepts of the language: Values and types, environments and the global environment, error handling, metatables and metamethods, garbage collection, and coroutines
- The Language – describes the lexis, the syntax, and the semantics of Lua: Lexical conventions, variables, statements, expressions, and visibility Rules
- The Application Program Interface – describes the C API for Lua: The stack, stack size, valid and acceptable indices, C closures, registry, error handling in C, handling yields in C, functions and types, and the debug interface
- The Auxiliary Library – provides several convenient functions to interface C with Lua
- Standard Libraries – provide useful functions that are implemented directly through the C API: Basic functions, coroutine manipulation, modules, string manipulation, UTF-8 support, table manipulation, mathematical functions, input and output facilities, operating system facilities, and the debug library
- Lua Standalone
- The Complete Syntax of Lua
The book is released freely under the Lua license.
By ignatz (83 pages)
Lua for Beginners is an unofficial guide designed to offer a good introduction to the world of Lua. It covers the basics of Lua, taking the reader a step at a time through the language. It comes with exercises to test learning.
The guide is incomplete in parts.
- A first look at Lua – printing results
- Variables – variable names, changing a variable, types of variable, and deleting variables
- Conditions – shows how decisions are made in Lua. Covers the basic If test, how to set conditions, and combining multiple if tests
- Lists – an introduction covering making date lists
- More lists, tables and loops – two dimensional tables, tables of named items
- Functions – built in functions, building your own functions, optional variables and defaults, variable number of parameters, and named parameters
- Scope – includes “local” functions
- Playful practice projects – the fairground coin trick, Wimbledon, and downloading movies
- Classes – explains classes with 3 examples
- Classes and Callbacks
- Class inheritance
- Closures (and zombic variables)
- Debugging and error handling
No mention is made about the book’s license.
By Roberto Ierusalimschy (288 pages)
Programming in Lua is the official book about the language, giving a solid base for any programmer who wants to use Lua.
Chapters of the book:
- The Language: Types and values, expressions, statements, functions, more about functions, iterators and the generic for, compilation, execution and errors, coroutines, and complete examples
- Tables and Objects: Data structures, Data files and persistence, metatables and metamethods, the environment, packages, object-oriented programming, and weak tables
- The Standard Libraries: The mathematical library, the table library, the string library, the I/O library, the operating system library, and the debug library
- The C API: An overview of the C API, extending your application, calling C from Lua, techniques for writing C functions, user-defined types in C, and managing resources
This online book is freely available for personal use only. It cannot be copied to other web sites or further distributed in any form.
Click to rate this software