Lua Programming tutorial

Lua Tutorial

Lua is a lightweight, scripting language written in standard C and opened in source code, designed to be embedded in an application to provide flexible extension and customization capabilities for applications.

Lua is a research group in the Pontifical Catholic University of Rio de Janeiro, Brazil, composed of Roberto Ierusalimschy, Waldemar Celes and Luiz Henrique de Figueiredo and developed in 1993.

aim of design

It is designed to be embedded in the application, so as to provide flexible application extensions and customization capabilities.

Lua characteristics

  • Lightweight : it is written in standard C language and open source code, compiled only one hundred K, can be easily embedded in other programs.
  • Scalable : Lua provides a very easy-to-use interface and the expansion mechanism: provide these functions by the host language (usually C or C ++), Lua can use them, as it would have been like a built-in feature.
  • Other features :
    • Support for process-oriented programming and functional programming;
    • Automatic memory management; only provides a common type of table (table), it can be used to achieve the array, hash table, collection, object;
    • Language built-in pattern matching; closure; function can also be seen as a value; provide multi-threaded (collaborative process, not supported by the operating system thread) support;
    • Through the closure and table can be very convenient to support object-oriented programming needs of some of the key mechanisms, such as data abstraction, virtual function, inheritance and overload.

Lua application scenario

  • game development
  • Independent application script
  • Web application script
  • Extensions and database plugins such as MySQL Proxy and MySQL WorkBench
  • Security systems, such as intrusion detection systems

The first Lua program

Then we use Lua to output “Hello World!”

Example (Lua 5.3)

Print (“Hello World!”)

Running examples »

After running, will be displayed on the screen Hello, world !.

Leave a Reply

Your email address will not be published. Required fields are marked *