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|
|Java||General-purpose, concurrent, class-based, object-oriented, high-level language|
|C||General-purpose, procedural, portable, high-level language|
|Python||General-purpose, structured, powerful language|
|C++||General-purpose, portable, free-form, multi-paradigm language|
|C#||Combines the power and flexibility of C++ with the simplicity of Visual Basic|
|PHP||PHP has been at the helm of the web for many years|
|HTML||HyperText Markup Language|
|SQL||Access and manipulate data held in a relational database management system|
|Ruby||General purpose, scripting, structured, flexible, fully object-oriented language|
|Assembly||As close to writing machine code without writing in pure hexadecimal|
|Swift||Powerful and intuitive general-purpose programming language|
|Groovy||Powerful, optionally typed and dynamic language|
|Go||Compiled, statically typed programming language|
|Pascal||Imperative and procedural language designed in the late 1960s|
|Perl||High-level, general-purpose, interpreted, scripting, dynamic language|
|R||De facto standard among statisticians and data analysts|
|COBOL||Common Business-Oriented Language|
|Scala||Modern, object-functional, multi-paradigm, Java-based language|
|Fortran||The first high-level language, using the first compiler|
|Scratch||Visual programming language designed for 8-16 year-old children|
|Lua||Designed as an embeddable scripting language|
|Logo||Dialect of Lisp that features interactivity, modularity, extensibility|
|Rust||Ideal for systems, embedded, and other performance critical code|
|Lisp||Unique features - excellent to study programming constructs|
|Ada||ALGOL-like programming language, extended from Pascal and other languages|
|Haskell||Standardized, general-purpose, polymorphically, statically typed language|
|Scheme||A general-purpose, functional language descended from Lisp and Algol|
|Prolog||A general purpose, declarative, logic programming language|
|Forth||Imperative stack-based programming language|
|Clojure||Dialect of the Lisp programming language|
|Julia||High-level, high-performance language for technical computing|
|Awk||Versatile language designed for pattern scanning and processing language|
|BASIC||Beginner’s All-purpose Symbolic Instruction Code|
|Erlang||General-purpose, concurrent, declarative, functional language|
|VimL||Powerful scripting language of the Vim editor|
|OCaml||The main implementation of the Caml language|
|ECMAScript||Best known as the language embedded in web browsers|
|Bash||Shell and command language; popular both as a shell and a scripting language|
|LaTeX||Professional document preparation system and document markup language|
|TeX||Markup and programming language - create professional quality typeset text|
|Arduino||Inexpensive, flexible, open source microcontroller platform|
|Elixir||Relatively new functional language running on the Erlang virtual machine|
|F#||Uses functional, imperative, and object-oriented programming methods|
|Tcl||Dynamic language based on concepts of Lisp, C, and Unix shells|
|Factor||Dynamic stack-based programming language|
|Eiffel||Object-oriented language designed by Bertrand Meyer|
|Agda||Dependently typed functional language based on intuitionistic Type Theory|
|Icon||Wide variety of features for processing and presenting symbolic data|
|XML||Rules for defining semantic tags describing structure ad meaning|
|Vala||Object-oriented language, syntactically similar to C#|
|Standard ML||General-purpose functional language characterized as "Lisp with types"|
|D||General-purpose systems programming language with a C-like syntax|
|Dart||Client-optimized language for fast apps on multiple platforms|
|Markdown||Plain text formatting syntax designed to be easy-to-read and easy-to-write|
|Kotlin||More modern version of Java|
|Objective-C||Object-oriented language that adds Smalltalk-style messaging to C|
|VHDL||Hardware description language used in electronic design automation|
|J||Array programming language based primarily on APL|
|LabVIEW||Designed to enable domain experts to build power systems quickly|