Lua – A New, Fast and Powerful Programming Language

Lua is a scripting language born in Brazil and is quite special. Lua, compared to the well-known programming languages such as PHP, Perl, Python and Ruby, stands out for its extreme compactness, speed and a strong emphasis on the description and management of data.
In addition, from the beginning, it was designed and built to be embedded (embedded) within applications written in C / C ++, D, Pascal, Ada. In this way, it is possible to extend and modify an already completed application and distributed to customers without having the source code and above all using such a small and simple language that you learn in one day!
Lua is not just an extension language, it is also a general purpose language for writing a wide variety of applications. Said in challenging terms, you can write in Lua everything you can write in Python or Ruby with a considerable gain in terms of speed of application execution.


The Lua language

lua programming language logo
Lua is a very small and flexible dynamic scripting language. The entire interpreter is contained in a single executable file of approximately 200 KB. Just copy this file to a system directory or present in your Path and Lua becomes ready to use without limits. Compiling Lua from source code (a few thousand C code very clean) is quick and easy on any platform that has an ANSI C compiler.
Instead, providing an application written in C / C ++, D or Pascal / Object Pascal of a Lua interpreter is simple and convenient.
The syntax of Lua is similar to that of Pascal, but is closer to Ada; this gives the language great readability and elegance. Anyone who knows a scripting language finds Lua simpler, smaller and more immediate than any other. In fact, Lua is composed of a handful of keywords and symbols (see box).
The fact that it is such a small language should not lead the reader to think that with Lua you can do little or nothing. But again, with Lua, you can do everything you would do with Perl, Python or Ruby. When it comes to extending an application, Lua demonstrates its nature. It is possible to write Lua code according to the procedural, functional and object paradigm.

The Lua compiler

Like all scripting languages, a Lua script is executable from source code and this is a real problem for those who want to distribute their applications without allowing the user to browse the source code or modify it. A viable but not effective solution is to obfuscate the code.
Lua solves this problem by providing a very small utility called “LUAC“. It is not a true compiler as we understand it, that is, it translates the source code of a program into executable code but simply transforms the Lua code into encrypted code making it absolutely unreadable.
The “compiled” Lua code does not gain and loses nothing in terms of performance compared to the source code.

Extend an application into Lua

There are so many really interesting things to say about Lua, but the essence of the language remains to write scripts that interact with compiled applications written in other languages, typically in C / C ++ and Object Pascal (Delphi, Kylix and Free Pascal). Think how useful and interesting it is for the user to customize and extend an application without having to source code. Not only. Thanks to Lua it is possible to write a “kernel” application around which to develop specialized software using components in lua. Indeed, this is the most common use of Lua. Just go to the site dedicated to the language and see how many projects have been made in this way.
Lua is very close to C, calling C functions or inversely calling Lua from C is immediate and without many complications.
Personally of Python and I learned only the rudiments, but for what I saw Lua is superior, except that Lua is Brazilian and this does not put him at the top of the visibility.
If you look at the sources, find out who wrote this stuff knows the C very well and the performance is also due to this non-secondary circumstance.

Conclusion

Learning a new programming language has always been useful, interesting and sometimes even fun. But when the knowledge of a new language also helps us to improve our work, then it becomes a real investment. However, there is always a price to pay in terms of time, money, energy and perhaps even health, before becoming really productive with a new language. All this then becomes proportional to the complexity of the language and the validity of the available development environments.

Comments

Popular posts from this blog

E-bandage generates electricity, speeds wound healing in rats

Fathers Are Happier Than Mothers, Study Shows — And Here's Why

Your friends shape your microbiome — and so do their friends