Lua, install this powerful scripting language on Ubuntu

about moon

In the next article we are going to take a look at Lua. This is a free and open source scripting language. It is powerful, robust, minimal and integrable. Lua is a scripting language that supports procedural programming, object-oriented programming, functional programming, data-driven programming and description of these.

Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. This language is dynamically typed, runs when interpreting bytecode with a registry-based virtual machine and it has automatic memory management with incremental garbage collection. It is ideal for configuration, scripting, and rapid prototyping.

This language has been used in many industrial applications, such as Adobe Photoshop Lightroom. It has also been used in games such as World of Warcraft and Angry Birds. According to their website, this is the leading scripting language in games. Various versions of Lua have been released and used in real applications since its inception in 1993.

Lua has a well-deserved reputation for performance. Say be 'as fast as lua', is an aspiration of other scripting languages. Various landmarks show Lua as the fastest language in the field of interpreted scripting languages.

We will be able to run it on all, if not most of the operating systems, Gnu / Linux and Windows among others. It also runs on mobile operating systems like Android, iOS, BREW or Windows Phone. We will also find it working on integrated microprocessors, ARM and Rabbit or on IBM mainframes and many more.

To learn to use this language we will have A wide reference manual and from several books about it. If we want to take a look at how Lua programs work before installing it on our Ubuntu, we can make use of the live demo that its creators make available to users.

General characteristics of Lua

Some of the general characteristics of the Lua language are:

  • It is a language of conventional scripting Easy to use.
  • It is remarkably light, fast and efficient.
  • It has a short learning curve. It is easy to learn and use.
  • This language is adaptable to a wide range of applications.
  • Its API is simple and it is well documented.
  • Supports various types of programming. Such as procedural, object-oriented, functional, and data-driven programming, as well as data description
  • Gather the direct procedural syntax, with formidable data description constructs rooted around associative arrays and extensible semantics.
  • Comes with automatic memory management with incremental garbage collection. This makes it a perfect option for configuration and scripting.

How to install Lua on Ubuntu

Lua is available in official repositories of the main Gnu / Linux distributions. In our Ubuntu we can install this language using the package manager by opening a terminal (Ctrl + Alt + T) and typing:

sudo apt install lua5.3

Compile Lua

First, make sure have the necessary tools installed in your system. You can run the following command to install them from the terminal (Ctrl + Alt + T):

sudo apt install build-essential libreadline-dev

After finishing the installation, to compile and install the latest version (version 5.3.5 at the time of writing these lines) from Lua, run the following commands to download the tar ball package, extract it, compile it, and install it.

mkdir lua_build

cd lua_build

curl -R -O http://www.lua.org/ftp/lua-5.3.5.tar.gz

tar -zxf lua-5.3.5.tar.gz

cd lua-5.3.5

make linux test

sudo make install

Once the installation is finished, run the Lua interpreter typing in terminal (Ctrl + Alt + T):

lua editor 5.3.5

lua

Create your first program with Lua

Using our text editor favorite, we can create our first Lua program. We edit the files as follows:

vim ubunlog.lua

And we will add the following code to the file:

vim program lua

print("Hola lectores de Ubunlog”)
print("Estamos probando el lenguaje Lua en Ubuntu")

Now we save and close the file. Then we can run our program typing in terminal (Ctrl + Alt + T):

launching the program written with lua

lua ubunlog.lua

For learn more and learn how to write programs with Lua, we can go to the project website.


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.