Should I Really Learn Lua?
Nearly 3 years ago I stumbled across a light-weight, powerful and fast programming language called Lua that seemed to come up as a rapid prototyping language for several game development SDKs. I recall a few months later speaking to a friend that does server-side programming mainly using the .NET framework (and C#…. “C sharp”). I recall him saying “Hmmm… never heard of that one before?…”.
If you type in “Popular Programming Languages” in a Google Search you get the major index listings from TIOBE, IEEE, Github. And heck… Lua only (to my surprise) comes up in 1 of the top 20 of these indices (ranked #17 in the Github index at the time of me writing this post).
So, one might ask the question…. why would you invest your time in learning such a relatively un-popular language?
Well, if you are into cross-platform app development (and specifically mobile game development) then Lua is a big deal. Cross platform means you write the app in 1 programming language to publish your app to multiple target operating systems (such as iOS, Android, Windows 10). “Write once…. deploy everywhere” as the popular Sun Microsystems (now Oracle) slogan once rang. That is a big time saver! and critical to cost effective, boot strapped (ZERO budget), indie app and mobile game development.
I was recently listening to Game Design Careers with Brenda Romero, and she mentioned Lua in one of the video segments.
Surely, if game design industry icons like John and Brenda Romero know and use Lua… then surely it must be worth investing my time in.. right?
Personally, I don’t have a Computer Science (CS) degree. I did have exposure to programming prior to learning Lua. In the late 90’s I had to learn ANSI C and Matlab while completing an Engineering degree. But you totally don’t need any exposure to prior programming languages to be able to learn Lua. Yes, prior exposure will help…. but you will find that Lua has a very gentle learning curve when compared to C and other languages like Java, Objective-C and even Swift.
Created in 1993 by researchers at the Pontifical Catholic University of Rio de Janeiro in Brazil, Lua is described as a dynamic, strongly typed language with programs that run by interpreting bytecode for a register-based virtual machine (making it cross platform in a manner similar to Java which is executed using the Java Virtual Machine).
What Game Engines currently use Lua?
There are many fantastic game engines / SDKs that use Lua. I personally use Corona SDK on a regular basis and have only experimented with the others. One new game engine that I came across this year while checking out the Global Game Jam held in January was Defold which comes from the wildly successful game creators King (surely you’ve played Candy Crush Saga, Farm Heroes Saga, etc). [Note: In November 2015, Activision bought out King for $5.9 Billion]
Another cool thing I noticed, was that Gideros recently announced in a blog post that they can run their game engine on a Raspberry PI. The reason this interests me is that I am currently planning to purchase a Raspberry PI 3 Model B to help teach my kids to program and learn computer science fundamentals.
Here are some of the top mobile game development SDKs that use Lua –
Where do I get Started Learning Lua?
You can start learning Lua in many different ways. Some of these include:
- Heading over to Lua.org and using the browser embedded live demo. Enter in code snippets and click “Run” to see what your code executes.
- Download one of the popular Game Engine SDKs mentioned above. This is a great method to learn Lua by seeing rapid results with only a small amount of code.
- Check out the Introduction to Lua guide over at coronalabs.com (maker of Corona SDK). If you haven’t installed Corona SDK before, check out my Youtube video to walk you through the install process here (takes roughly 6 – 7 minutes) –
In my opinion the most effective and efficient way to learn Lua is to start coding with it right away… obvious right? You can read all the books in the world on Lua and App/Game development, but until you start putting “finger to keyboard” it just won’t stick with you. Practice makes perfect and coding “by actually starting to code” is essential. You won’t break anything so don’t worry, just get started!
Then when you start to understand the language a bit, get yourself a book to solidify your knowledge.
- Programming in Lua is a great reference written by Lua’s chief architect Roberto Lerusalimschy.
- Beginning Lua Programming is also a solid reference. It cover Lua version 5.1 (the version currently implemented in Corona SDK as of Public Release build 2016.2830).
- You will also find a ton of great Lua-based SDK specific books. Check out these Corona SDK Books. If you are looking for a Corona SDK reference book make sure it covers Graphics 2.0 which was a major change to the API from around mid-2013. Graphics 1.0 has been deprecated in the latest Corona SDK public release build 2016.2830.
In the next installment on Lua programming, I’ll demo some of the basic language constructs in Lua including variable assignment types, functions and tables. Using and understanding tables in Lua is one of the most important things to master.
See you next time!
Computer vector designed by Freepik in the post banner.