Last Updated on May 22, 2022
Lua is a lightweight, small, 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. It has automatic memory management and incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping. Lua tries to help you solve problems with only hundreds of lines, or even less. To achieve this aim, Lua relies on extensibility.
In the popularity stakes, Lua lags behind say Python, Perl, or Ruby for scripting purposes. As a barometer of its popularity, Lua is currently ranked in 33rd place on the TIOBE Index.
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 was designed, from the beginning, to be integrated with software written in C and other conventional languages. But it’s also used as a standalone language.
This language 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 26 years.
This article recommends free books to help you master programming in Lua. As the range of good free books is fairly limited, I close the article with a few carefully selected tutorials that are genuinely useful.
1. Lua 5.3 Reference Manual by Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes
Lua 5.3 Reference Manual offers the official definition of the Lua language. This expertly written book describes the syntax and the semantics of Lua, the standard libraries, and the C Application Program Interface (API). The section on the API covers the stack, stack size, valid and acceptable indices, C closures, registry, error handling in C, handling yields in C, and more.
The book ends with the complete syntax of Lua in extended Backus Normal Form (BNF 1).
Read the book at https://www.lua.org/manual/.
The book is published under the terms of the Lua license.
2. Programming in Lua (first edition) by Roberto Ierusalimschy
Programming in Lua is a detailed and authoritative introduction to all aspects of Lua programming written by Lua’s chief architect.
The free online version of this book focuses on Lua 5.0. While this is not the latest release of Lua, the book remains very relevant. You’ll just have to refresh the latest changes in the syntax of the language.
Read the online version of the book at https://www.lua.org/pil/contents.html.
We recommend purchasing a paperback version of the fourth edition of the book, which updates the book to Lua 5.3.
3. Lua for Beginners by ignatz
Lua for Beginners is an unofficial guide designed to offer a good introduction to the world of Lua. It’s targeted at beginners to the language.
Spanning 83 pages, this book covers the basics of Lua, taking the reader a step at a time through the language. Along the way you’ll learn about variables, conditions, loops, lists, functions, classes, pointers, classes and callbacks, class inheritance, coroutines, closures, debugging, and metatables.
The book is supplied with exercises to test learning.
Download a PDF copy of the book.
4. Lua Programming Gems edited by L. H. de Figueiredo, W. Celes, R. Ierusalimschy
Lua Programming Gems is a collection of articles that express some of the existing wisdom and practice on how to program well in Lua.
Please note some parts of the book are not freely available, and some of the links are broken. But there are some free chapters with accompanying code. You’ll learn how to write better Lua programs.
Read the articles and code at https://www.lua.org/gems/.
Other useful guides for learning how to program in Lua include:
- Learn Lua in 15 Minutes. This is a Lua script written as both an introduction and a quick reference.
- Lua for Programmers – a four part series that shows you how to program in Lua. It covers the language essentials, data and standard libraries, and more advanced concepts. The final part ends with some tips and tricks.
- Lua Tutorial by tutorialspoint
1 BNF is a metasyntactic notation procedure used to specify the syntax of computer programming languages, command/instruction sets, document formatting and communication protocols.
All books in this series:
|Free Programming Books|
|Ada||ALGOL-like programming language, extended from Pascal and other languages|
|Agda||Dependently typed functional language based on intuitionistic Type Theory|
|Arduino||Inexpensive, flexible, open source microcontroller platform|
|Assembly||As close to writing machine code without writing in pure hexadecimal|
|Awk||Versatile language designed for pattern scanning and processing language|
|Bash||Shell and command language; popular both as a shell and a scripting language|
|BASIC||Beginner’s All-purpose Symbolic Instruction Code|
|C||General-purpose, procedural, portable, high-level language|
|C++||General-purpose, portable, free-form, multi-paradigm language|
|C#||Combines the power and flexibility of C++ with the simplicity of Visual Basic|
|Clojure||Dialect of the Lisp programming language|
|COBOL||Common Business-Oriented Language|
|Coq||Dependently typed language similar to Agda, Idris, F* and others|
|Crystal||General-purpose, concurrent, multi-paradigm, object-oriented language|
|CSS||CSS (Cascading Style Sheets) specifies a web page’s appearance|
|D||General-purpose systems programming language with a C-like syntax|
|Dart||Client-optimized language for fast apps on multiple platforms|
|Dylan||Multi-paradigm language supporting functional and object-oriented coding|
|ECMAScript||Best known as the language embedded in web browsers|
|Eiffel||Object-oriented language designed by Bertrand Meyer|
|Elixir||Relatively new functional language running on the Erlang virtual machine|
|Erlang||General-purpose, concurrent, declarative, functional language|
|F#||Uses functional, imperative, and object-oriented programming methods|
|Factor||Dynamic stack-based programming language|
|Forth||Imperative stack-based programming language|
|Fortran||The first high-level language, using the first compiler|
|Go||Compiled, statically typed programming language|
|Groovy||Powerful, optionally typed and dynamic language|
|Haskell||Standardized, general-purpose, polymorphically, statically typed language|
|HTML||HyperText Markup Language|
|Icon||Wide variety of features for processing and presenting symbolic data|
|J||Array programming language based primarily on APL|
|Java||General-purpose, concurrent, class-based, object-oriented, high-level language|
|Julia||High-level, high-performance language for technical computing|
|Kotlin||More modern version of Java|
|LabVIEW||Designed to enable domain experts to build power systems quickly|
|LaTeX||Professional document preparation system and document markup language|
|Lisp||Unique features - excellent to study programming constructs|
|Logo||Dialect of Lisp that features interactivity, modularity, extensibility|
|Lua||Designed as an embeddable scripting language|
|Markdown||Plain text formatting syntax designed to be easy-to-read and easy-to-write|
|Objective-C||Object-oriented language that adds Smalltalk-style messaging to C|
|OCaml||The main implementation of the Caml language|
|Pascal||Imperative and procedural language designed in the late 1960s|
|Perl||High-level, general-purpose, interpreted, scripting, dynamic language|
|PHP||PHP has been at the helm of the web for many years|
|PostScript||Interpreted, stack-based and Turing complete language|
|Prolog||A general purpose, declarative, logic programming language|
|Python||General-purpose, structured, powerful language|
|QML||Hierarchical declarative language for user interface layout - JSON-like syntax|
|R||De facto standard among statisticians and data analysts|
|Racket||General-purpose, object-oriented, multi-paradigm, functional language|
|Raku||Member of the Perl family of programming languages|
|Ruby||General purpose, scripting, structured, flexible, fully object-oriented language|
|Rust||Ideal for systems, embedded, and other performance critical code|
|Scala||Modern, object-functional, multi-paradigm, Java-based language|
|Scheme||A general-purpose, functional language descended from Lisp and Algol|
|Scratch||Visual programming language designed for 8-16 year-old children|
|SQL||Access and manipulate data held in a relational database management system|
|Standard ML||General-purpose functional language characterized as "Lisp with types"|
|Swift||Powerful and intuitive general-purpose programming language|
|Tcl||Dynamic language based on concepts of Lisp, C, and Unix shells|
|TeX||Markup and programming language - create professional quality typeset text|
|Vala||Object-oriented language, syntactically similar to C#|
|VHDL||Hardware description language used in electronic design automation|
|VimL||Powerful scripting language of the Vim editor|
|XML||Rules for defining semantic tags describing structure ad meaning|