How to Learn Lua
Are you interested in game development, or using a scripting language to make changes to a program without affecting its infrastructure? Lua, a scripting language born in Brazil (“Lua” is the Portuguese word for “moon”), may just be the technology for you.
If you are interested in working in game development or making changes to web pages, you should seriously consider learning Lua.
What is Lua?
Lua is a
designed primarily for embedded use in applications and not meant to be used as a stand-alone language. Lua was designed in 1993 as a language for extending software applications to meet the increasing demand for customization at the time.
Lua is often used for making games with the Love 2D Game Engine. Lua is used in popular games such as Roblox , World of Warcraft , Angry Birds , and Civilization . Lua has also been widely used by editors to make changes to Wikipedia pages.
What is Lua Used for?
Lua is lighter and smaller than other scripting languages like Python, which makes Lua attractive to developers. Being “light” and “small” refers to how much memory something takes up in your application. Generally, Lua adds less than 100 kilobytes to your application. Rather than working as a stand-alone language, Lua can be embedded into applications.
Lua is used in game development, including in games such as
World of Warcraft
, you can use Lua to customize the game’s interface. There are even hackers in the game’s community that teach each other Lua. Lua is also used for building games in conjunction with game engines such as Love 2D and Corona.
But that’s not all. Lua is used in the Apache HTTP Server, a web server software; Celestia, which provides real-time 3D visualization of space; MySQL Workbench (the development environment used for the MySQL database); and Torch, a machine learning library based on Lua.
In 2013, Wikipedia announced that anyone can use Lua to build material on Wikipedia, Wikiquote, and Wiktionary. They created Scribunto, a MediaWiki extension to
allow editors to embed Lua scripts
to use with their templates. Templates include common elements like the infoboxes on many Wikipedia pages that include biographical information about a page’s subject.
Lua runs in a sandbox, which means that it is designed to not interfere with other code in the application. With Lua, you can limit how much CPU process time any one script can use. Both of these elements were factors in Wikimedia Foundation’s decision to use Lua.
Lua is also used in software such as Adobe Lightroom. You can enhance and extend Lightroom’s capabilities by building plug-ins with Lua with the Adobe Lightroom software development kit (SDK).
Lua is a valuable skill to learn if you are interested in game development, but it is also useful in other cases where an embeddable scripting language is needed. Companies such as Shopify, Venmo, and Thumbtack
use Lua as part of their tech stack
As of this writing, there are over
500 job listings on LinkedIn
that mention Lua. These include jobs such as Performance Model Development and Analysis Engineer, Software Engineer-Rendering, and AR Tools Engineer.
Other popular languages for game development include C++, C#, Java, and Python. If you’re interested in a career in game development, combining Lua with these other programming languages can make you a competitive job candidate.
"Career Karma entered my life when I needed it most and quickly helped me match with a bootcamp. Two months after graduating, I found my dream job that aligned with my values and goals in life!"
Venus, Software Engineer at Rockbot
How Long Does It Take to Learn Lua?
It takes 2–3 days to learn the basics of Lua, and 3–4 weeks to know enough to use it professionally. Lua’s syntax is simple and fairly easy to learn. Lua is “strongly typed”, which means that it is consistent and predictable.
Lua has its own libraries (a library is a collection of pre-built code), and you can extend Lua with libraries from other languages , such as C.
How to Learn Lua: Step-by-Step
There are different approaches you can take when learning any new technology. Here are some steps we recommend for learning Lua:
- Discover how Lua is used. Research some of the companies and industries Lua is used, such as game development.
- Read about Lua. There are books available to help you learn this scripting language, such as the free Programming in Lua , written by Lua’s creators and available on the official Lua website .
- Try out the Lua Demo . Before you decide whether you want to install Lua on your computer, you can see what the syntax looks like with this demo.
- Install Lua . When you’re ready to download Lua on your computer, you can do so on the official Lua website. You can use an IDE (integrated development environment) such as ZeroBrane Studio to code with Lua.
- Practice your skills. Check out tutorials such as “Getting Started with Lua” from Game Dev Geek.
- Get involved in the Lua community . On the official Lua website you can learn about the Lua community’s Discord room, forum, and StackOverflow tag.
The Best Lua Courses and Trainings
Lua courses can help you understand this programming language through exercises and projects.
In this beginner-friendly course, you will learn how to use Lua to develop games with the Love 2D Game Engine. You’ll understand Lua programming concepts such as variables, for loops, and functions, and create three games: Shooting Gallery, Top-Down Shooter, and Platformer. Plus, you’ll get lessons on mobile game development like adapting your games to screen size and publishing your game app.
This course includes 8.5 hours of video content, two articles and 16 other resources, and a certificate of completion.
To get started with this course, all you need to know is how to work with files and the basics of how to work with your command line. You’ll be guided through installing Lua, to embedding Lua within the C programming language, all the way to using Lua with Roblox Studio.
You will get 13.5 hours of video content, 16 articles, and 20 downloadable resources, along with full lifetime access to the course.
With this course, you will learn the basics of the Lua programming language, the basics of
game development, and how to create and publish your own games. Even if you’re completely new to programming, you will still be able to understand all of the content.
Course content includes eight hours of on-demand video, six articles, six downloadable resources, and a certificate of completion.
Books can be a great resource as you are learning to use Lua. Check out these options.
’Programming in Lua’ , Roberto Ierusalimschy
Written by Lua creator Roberto Ierusalimschy, the first edition of Programming in Lua is available online for free. You’ll get a detailed introduction to how to get started with Lua, along with knowledge of programming concepts like types and variables, expressions, statements, and functions. This book also dives into how to use the standard Lua libraries and using Lua with C, another programming language.
’Lua Quick Start Guide’ , Gabor Szauer
You won’t go wrong with this beginner-friendly introduction to Lua. Learn how to use the Lua standard libraries, debug Lua code, and embed Lua into applications. This book will teach you how to write Lua code that can interact with an operating system, automate tasks, and make games. Further, you’ll understand concepts like how to manipulate string data with Lua and how to use tables (a data structure in Lua).
‘Beginning Lua with with World of Warcraft Add-ons’ , Paul Emmerich
World of Warcraft is a popular video game. With Lua and XML (a markup language similar to HTML), you can learn how to build modifications to transform your Warcraft experience. This book features exciting code examples that you can run right away. With additional information about Lua concepts like debugging, error handling, and tables, this is a fantastic option for you if you’re new to Lua and interested in how to use it in Warcraft .
Online Lua Resources
Here are our top picks for great resources to help you learn Lua.
The website offers a variety of resources to help you learn this programming language. These resources include a Getting Started guide, Live Demo, and tips and tools for learning Lua. Plus, there are press releases so you can learn about the history and applications of Lua.
This free tutorial is a great option for getting started with Lua. While this is a tutorial for beginners, you will get the most from this course if you have a basic understanding for working with a code editor and command line.
You’ll learn how to set up your coding environment, how to use basic Lua syntax, and debugging strategies. The tutorial also covers how to use Lua for game development and features of Lua libraries.
Love 2D is a framework for making 2D games with Lua. Love 2D is a free, open-source framework that you can download for Windows, MacOS, or Linux. There’s a Wiki, Forum, community links, Lua code examples, and documentation.
Should You Study Lua?
Lua is a valuable programming language to learn if you want to be a game developer. Lua can also be used as a scripting language in other applications. Lua has powered projects such as Wikipedia and Adobe Lightroom.
Lua’s lightweight and embeddable structure has earned it a place in tech stacks at companies like Dailymotion and Venmo. Paired with other programming languages like C++, C#, Java, and Python, Lua can help you transition into a career as a game developer.