Lua is an extremely powerful interpreted language. It is most well known for its use in API’s (Application Programming Interface). From World of Warcraft to Kaseya’s VSA, all sorts of applications in different industries rely on Lua to make things work. Lua is almost everywhere, but is still relatively unknown.
Lua is more than just a language for API’s, it excels as a programming language in its own right. It’s fast and efficient, especially considered to other interpreted languages. Lua also has a JIT (Just In Time) compiler which makes it even faster for certain applications.
You can use it for making games, it has many modern frameworks which keep it competitive, and it’s great for general purpose system scripting. Lua is a powerhouse when used correctly. I’ve used it to replace Perl for most tasks and for Windows automation.
Lua For Games
Frameworks like Love2D (or LÖVE) and Corona make Lua practical for game programming. These two frameworks allow the creation of professional games which are cross-platform. Both are extremely mature and feature-rich.
LÖVE allows you to implement 2D games easily and efficiently from the ground up with worrying about the low-level graphics. The engine is extremely powerful and intuitive. It also has many extra libraries to add things like collision detection and similar. LÖVE’s only fallback is a lot of the library names can sound a bit immature.
Corona is a library for building games for the likes of iOS and Android as well as more traditional environments like Windows and MacOS. It’s free and open-source. Corona also has a massive community backing it and making it easy to learn and work with. It also works with Steam’s platform with a plugin.
Corona is the more commercially viable of the two for sure, but LÖVE is a great framework to learn on and to work with. There are still games on which are made with LÖVE, but they require extra work to get there. Both of these frameworks are extremely powerful and feature rich and can be used to make high quality games relatively easily.
Modern App Frameworks
If you don’t care about making games, Lua still has you covered. Lua has modern web frameworks via Lapis and Luvit (among many). It also has a deep machine learning framework via Torch. All of these are open source and easy to use (all things considered).
Lapis allows the creation of flexible, self-contained REST API based applications (brush up on your JSON). With a little extra work, you can use it for quick, self-contained microservices. It can easily be extended to resemble Perl’s Dancer and many other equivalent frameworks.
If Node.JS is more your thing, give Luvit a chance. Luvit implements the same API as Node.JS in Lua so it’s easy to migrate to or use if you’re already used to Node. It’s mature, extensible, and uses a similar backing as one of the most popular asynchronous frameworks in the world.
Aside from Lapis and Luvit, there are dozens of other frameworks of varying levels of maturity with different philosophies. I never really felt the need to move from Lapis for anything I do with web programming in Lua so I haven’t played with all that many. That being said, there are a lot.
Torch is an extremely powerful scientific framework for LuaJIT which is often used for machine learning. Torch works well with C, leverages GPU’s, and is extremely flexible. For a machine learning framework, it is extremely simple but powerful. For instance, it can be used for deep machine learning as easily (from a technical side) as any other algorithm of choice. There is also an extremely strong community around Torch.
General Purpose Scripting
Lua is extremely powerful as a general purpose scripting language. I have used it extensively for scripting in a systems admin position due to how small the binaries are and how efficient it is. You don’t need to worry about versioning (unlike with Powershell) when you’re dropping precompiled binaries on each machine. The compressed 7Z package for my entire drop tends to be less than a single megabyte. You don’t have to do much to make a script work on different Windows versions from 2000 to present, and it’s built into most Linux distributions.
Lua features regular expressions and is Unicode agnostic. It has OS level libraries, can handle files, and basically any task a standard language can do. I feel the need to clarify this as most people who have worked with or heard about Lua only know it as an “API language” rather than a standalone language.
It has tables, classes, logic, and all of the other basics, as well as bells and whistles you’d expect from a modern programming language. The core language is extremely simple, but it’s simple like C. The language can be extended with packages via LuaRocks or similar depending on the platform.
Using Lua
Lua can do so much more than just extend applications. There are mature frameworks for basically any task you can think of. The language is simple but rich, terse but relaxed, and flexible but powerful. You don’t need to compile anything, but you can if you want with LuaJIT.
See why Lua is so much more than that API language for Roblox. Give it a try and see just why it is good for making games, or applications. Automate your worries away with a powerful, flexible language which is also quick to scaffold and implement with. You won’t even need to worry about how to build an API into your application!
Image by Free-Photos from Pixabay