Lua plays a special role in a wide variety of programming languages. This scripting development language has a freely distributed interpreter. In its ideology, Lua is most similar to JavaScript. However, unlike the latter, Lua has more flexible designs.
A little bit of history
The language was developed by Tecgraf from Brazil. Lua appeared in 1993. The authors are Roberto Jeruzalimski, Valdemar Celis and Luis Enrique de Figueiredo. The language is open source, so anyone can contribute to its development. An important feature of the creation of this language is that it appeared in Brazil, a country that has never been particularly different in terms of development before or since.
The progenitors of Lua are two development languages — SOL and DEL. They were also developed by Tecgraf between 1992 and 1993. Moreover, the customer was the well-known company Petrobras. As of today, the latest version of the language is 5.4.0. The update was released in summer 2020.
As you can see, Lua, along with many modern programming languages, has a long history. At the same time, regular updates are carried out, which suggests that Lua is popular in certain circles and has a fairly serious community.
Features of the Lua programming language
The main feature of Lua is that it can be used both as a separate and built-in scripting language. Already in the process of creation, the developers set themselves the goal of making a compact and simple tool that could easily work in various execution environments and at the same time provide the proper level of performance.
In addition, Lua was designed so that later they could easily learn its syntax and understand its peculiarities. Moreover, the simplicity of the language makes it interesting even for non-professional developers.
Lua is an OOP programming language. Thanks to built-in parallel programming tools, developers can create multithreaded applications without accessing external libraries or APIs. At the same time, the language effectively implements the possibilities of cross-language interaction.
Where is Lua used? Despite its fairly wide use in industry (let's not forget that the language was originally developed for the needs of the oil company Petrobras), Lua is now more actively used in developing computer games.
This is due to the fact that Lua makes it quite easy to program the behavior of so-called NPCs (from English. Non-playable characters). Also, this language is used to program other characters whose behavior can be quickly changed later without affecting the engine.
The most famous game product that uses the Lua language is World of Warcraft. Here, the language was used when writing the interface. Lua was also actively used to create other famous game masterpieces, such as Civilization 5, Crysis, Sim City, Far Cry, Stalker.
In addition to gaming use, Lua is also suitable for writing Telegram bots, for example. Wikipedia also plans to use this development language for integration into MediaWiki.
Finally, Lua is also used in space exploration observatories. The language is also used by various universities. And in Brazil itself, it is used everywhere. So it has become something of a state programming language.
Advantages and disadvantages
The Lua programming language has the following advantages:
- Lua has good portability. For example, you can transfer a program from Windows to Linux without any special changes.
- A large number of libraries. Despite the fact that Lua beats JavaScript in this parameter, on the language's official website you can find all the libraries you need to work with, which are more than enough to perform various tasks.
- The ability to quickly add new libraries written in C.
- Easy syntaxes and deployment. Learning a language will not take much time for those who are already programming. For beginners, this language will also be easy to learn.
- Applications and programs written in Lua use less memory.
As for the drawbacks, these include the fact that the language is scripted. Of course, you can use it yourself, but most often it is used together with other programming languages, such as C. Therefore, to work properly, you will need knowledge of another development language.
Lua's criticism
Debates over this language continue among developers. For example, criticism has been made of the fact that Lua is designed for use with C rather than with C++. This is true. However, even now there are several libraries that allow Lua to be embedded in C++ as well. Such solutions have their drawbacks, but they work and, most importantly, many programmers work with them today.
The speed of this language is also criticized. There is an opinion among programmers that Lua is much slower than her “competitors”. But it's actually a myth. The fact is that a scripting language most often works with some kind of logic. That is, there is simply nothing to slow down the application process.
Finally, another misconception is that Lua is only suitable for smaller projects. This is partly rational, but Lua is a modular language. That is, you can build something big and significant from various small blocks.
Some developers criticize the “antiquity” of the language and the lack of OOP in its basic version. In addition, they say that element numbering does not start at 0, as is customary in most other NPs, but with 1. But here, rather, we are talking about the personal preferences and views of individual programmers.
Lua code example
Let's see how to write a simple program using the Lua programming language using the “Hello World” string as an example. It's quite easy to do this on Lua:
print (“Hello world!”)
As you can see, it's really very simple. Lua has a simple syntax, which greatly facilitates the process of studying it.
Outlook
Game development is a very promising area. The video entertainment industry is growing every year. Accordingly, this niche will only gain popularity. But what about the Lua language? According to the Tiobe Index of Popular Programming Languages, Lua is ranked 30th, behind many popular development tools such as JS or Java.
What's the reason? First of all, despite being used in the gaming industry, the games themselves are mostly written in other languages. With Lua, only individual components are made, such as interfaces, menus, and so on. That is, Lua is not the main language in product development.
Another important aspect is the community. Despite the fact that it has recently begun to intensify, it is still noticeably smaller and more modest than the community of more popular programming languages.
Today, supply exceeds demand. It is not so easy to find a developer job on Lua, and there are many people who want to get such a job. Therefore, if you wanted to join a company as a Lua developer today, you would not only face the difficulty of finding such a job, but also a fairly high level of competition.
Should kids learn Lua? If your child is interested in game development, you can start with the Roblox platform, which is entirely created using the Lua programming language. Roblox is written in such a way that you don't need to know code to create your own gaming applications. The platform is similar to Scratch, although it has its own distinctive features.