Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Lua Tutorial

Lua Tutorial

Lua is a lightweight and compact scripting language, written in standard C and open in source form. Its design purpose is to be embedded in applications, thereby providing flexible extension and customization capabilities for applications.

Lua was developed in 1993 by a research group at the Pontifical Catholic University of Rio de Janeiro, whose members are Roberto Ierusalimschy, Waldemar Celes, and Luiz Henrique de Figueiredo.


Design Purpose

Its design purpose is to be embedded in applications, thereby providing flexible extension and customization capabilities for applications.


Lua Features

- Supports procedure-oriented programming and functional programming; - Automatic memory management; provides only one general type of table, with which arrays, hash tables, sets, and objects can be implemented; - Built-in pattern matching; closures; functions can also be regarded as a value; provides multithreading (coroutines, not threads supported by the operating system) support; - Through closures and tables, it can very conveniently support some key mechanisms needed for object-oriented programming, such as data abstraction, virtual functions, inheritance, and overloading.

Lua Application Scenarios


The first Lua program

Lua code files have the extension .lua.

Next, we use Lua to output "Hello World!"

Example (Lua 5.3)

print

(

"Hello World!"

)

Run Example »

After running, it will display Hello, world! on the screen.