Hi All.hope you are good. today i want to talk about Lua and my experience with it. Lua is a lightweight, multi-paradigm, scripting programming language, intended to be a extension designed for embedded use in applications.
Lua had it’s origins as a data entry language(DEL) for simulations and a report description language called simple object language(SOL). You can read all about it’s interesting history.Its a very simple language with very few operators,small size and is very portable thus can be run on many platforms like windows,linux,mac,linux etc..
In my first use case i had written an erlang application where i was receiving financial transactions from external endpoints on a tcp port.the application was then supposed to process the transactions and then forward them to either another embedded web application so the transactions could be viewed on a browser or an email will be sent to a list of users depending on the result of the processing.the embedded processing was initially done using erlang and could be changed in real time because the processing rules were stored in a database. the rules language was initially in erlang but i changed it to lua for its ease of use and portability.
In the second use case i was working on game scripting using the love2d game engine.It’s a game engine which enables you to write game logic using lua and other tasks are handled by the game engine.
some observations that i made were that
- the language is very simple and most of the keywords can easily fit in your mind
- there is a data-type called table which is like a swiss army knife and can be used as an array,hashmap,key value pairs,list,map,dictionary,etc.. which is very convenient.
- functions can return multiple values and be pattern matched which was cool
- it has meta tables and metha methods (which allows you to change as well as configure the behaviour of tables
- it can be used as a library to extend an application’s functionality which makes Lua an extension language
- at the same time, a program that uses Lua can register new functions in the Lua environment; such functions are implemented in Erlang (or another language) and can add facilities that cannot be written directly in Lua. This is what makes any Lua implementation an extensible language.(from the luerl wiki)
- it supports a variety of programming paradyms like object oriented programming,functional programming,data-driven,etc…
- it has a jit compiler which is different from its normal compiler which enables you to write performance critical applications
- its very popular for scripting in the game development space
there are a lot of other neat features like its ease of embedding in other languages which have made it very popular as an embeddable scripting language common in games, IoT devices, AI bots, machine learning and scientific computing research.
I am having a very nice time using it and intend to use it for some game development projects i have in mind with love2d.give it a try and let me know how it goes !!.