Lua is an imperative, structured and quite light programming languageor that it was designed as an interpreted language with extensible semantics. This programming language It is cross-platform and open source which is released under the MIT license.
This programming language is one of the recommended languages to start and understand programming, because it is considered one of the simplest programming languages to understand.
About the Lua programming language
Lua is a programming language compact enough to be used on different platforms.
In Lua the variables have no type, only the data and can be logical, integers, floating point numbers or strings.
Data structures such as vectors, sets, hash tables, lists, and records can be represented using Lua's unique data structure.
Moon is a multiparadigm language because its semantics can be extended and modified by redefining functions of the structures of data using metatables, almost as in Perl (thus it allows to implement, for example, inheritance, although it is foreign to the language).
Lua offers support for higher order functions, garbage collector. Combining all of the above, it is possible to use Lua in object-oriented programming.
The programs in Lua are not interpreted directly, but compiled to bytecode, which is run in the Lua virtual machine.
The compilation process is normally transparent to the user and is done at run time, but it can be done ahead of time to increase performance and reduce memory usage by bypassing the compiler.
Between Its main characteristics can be highlighted:
- It is based on all systems with a standard C compiler.
- It is very light, fast, efficient and portable.
- It is easy to learn and use.
- It has a simple and well documented API.
- It supports various types of programming (such as procedural, object-oriented, functional, and data-driven programming, as well as data description).
- It implements object-oriented through meta-mechanisms.
- It also brings together simple procedural syntax with formidable data description constructs rooted around associative arrays and extensible semantics.
- It comes with automatic memory management with garbage collection (making it perfect for real-world setup, scripting, and also fast-paced prototyping).
- To start learning this programming language, it is necessary to have the system language interpreter.
How to install the Lua programming language on Linux?
Due to its great popularity of the language its interpreter is found in most Linux distributions.
So for its installation you can install it with any of the following commands according to the distribution you are using.
For those who are users of Debian, Ubuntu, Linux Mint or any system derived from these, we only have to open a terminal and execute the following command in it:
sudo apt install lua5.3
If they are users of Arch Linux, Manjaro, Antergos or any distribution derived from Arch Linux, we can install the interpreter from the AUR repositories, for this we only have to type:
aurman -S lua
While for Those who are users of CentOS, RHEL, Fedora or any distribution derived from these, we can install it with:
sudo dnf install lua
Those who They are openSUSE users, they must add a repository and install, they do this by typing the following according to their version they are using:
For openSUSE Tumbleweed run the following as root:
zypper addrepo https://download.opensuse.org/repositories/devel:languages:lua/openSUSE_Tumbleweed/devel:languages:lua.repo
zypper refresh
zypper install lua51-luaexpat
If you use openSUSE Leap 42.3 run the following as root:
zypper addrepo https://download.opensuse.org/repositories/devel:languages:lua/openSUSE_Leap_42.3/devel:languages:lua.repo
zypper refresh
zypper install lua51-luaexpat
For openSUSE Leap 15.0 run the following as root:
zypper addrepo https://download.opensuse.org/repositories/devel:languages:lua/openSUSE_Leap_15.0/devel:languages:lua.repo
zypper refresh
zypper install lua51-luaexpat
And ready with it, I am already installed.
You can carry out a simple test creating the famous hello world, you just have to create a file with the .lua extinction and within the place:
nano holamundo.lua
print("Hola mundo!")
And to see how it works, just run it from the terminal with:
lua holamundo.lua
In Arch Linux the package "lua" is in the official repositories and does not have to be compiled
$ sudo pacman -S lua