If you’re one of the 58.5 million people who play the online game Roblox each day, there’s a good chance you’ve interacted with Lua before. Lua is a programming language that you can use to code game mechanics in Roblox and create custom features.
But game development is just one way that Lua comes in handy. The wildly popular language can also be used to build applications from scratch or extend the functionality of existing software.
In our new free course Learn Lua, you’ll learn the fundamentals of the general-purpose, embeddable programming language. You’ll practice using Lua data types, controlling the flow of a program with conditional logic, and building functions to pass data through them. If you’ve never coded before, don’t be intimidated — we’ll explain everything you need to know each step of the way.
Here’s what you need to know about Lua, the fast and flexible programming language taking the gaming world by storm.
Learn something new for free
What is Lua?
Lua is a powerful and efficient general-purpose programming language that was created in Brazil in 1993. Fun fact: Lua was inspired by the programming language SOL (Simple Object Language), and in Portuguese, “sol” means “sun.” When it came time to name the new language, the team of professors at the Pontifical Catholic University in Rio de Janeiro thought of “lua,” because it means “moon.”
The dynamically-typed, embeddable scripting language has a simple syntax that’s similar to Python. Lua code is read line by line, from top to bottom, making it concise and easy to read and write. Here’s an example of a Lua code snippet you’ll practice writing in the course Learn Lua:
print("Dear Self,")
print("Maybe Lua is the right language for me.")
print("Codey")
print("November 2022")
What’s so special about Lua?
Lua is unique because it’s designed to be used as an “extension language,” which means that it can be embedded in any other platform or system, explains Brandon Haffen, a Video Game Software Engineer who worked on the course Learn Lua. Developers can use Lua to fully customize products, and Lua can interoperate with any C code. “Taking the existing functionality of something and extending it is extremely fun,” he says.
Whether you’re making new game systems, quickly changing a website to add a bespoke feature, or building a unique tool to level-up your favorite art program, Lua can facilitate changes to pretty much any basic system, existing application, or hardware (even down to tiny microchips), Brandon says. Lua’s small size, flexibility, and portability, makes it a go-to for extending all kinds of programs. “How could you not get hyped about the cool new feature you added to something you already use?” he adds.
What can you build with Lua?
Lua can be used to develop games, web apps, and developer tools. The mobile payment app Venmo, for example, was built using Lua. And the game Angry Birds was made using Lua and the game engine LÖVE. “However, it’s most useful for people to learn if they want to add new functionality to an existing game, website, or application that allows Lua code to extend it,” Brandon says.
A lot of popular games and gaming platforms support using Lua to extend or create new game systems, Brandon says. The gaming platform Roblox, for example, allows players to write code in Lua to create their own original games. In the massively multiplayer online role-playing game World of Warcraft, you can use Lua add-ons (aka “mods”) to customize the game interface.
More of a photographer than a gamer? Lua is also built into the image-editing software Adobe Lightroom, so you can build your own plug-ins that help streamline your workflow and organize photos.
Get started learning Lua
Ready to jump in and try our free course Learn Lua? In Learn Lua, you’ll start working with different data types, variables, operators, conditionals, and functions. And you’ll get to put your Lua skills into practice creating a receipt generator for a (totally made-up) Mystic Moon Potion Shop. After taking this course, you’ll have the foundational skills you need to build an iconic game like Roblox and Angry Birds. (Check out these inspirational games built by members of the Codecademy community.)
If this is your first time learning to code, Lua is a great starter language because it’s straightforward. “The good thing about Lua is that it is very minimalistic,” Brandon says. “There is usually only one way to accomplish something.” With other languages, there may be multiple shortcuts or ways to execute something, which can be a little bit tedious when you’re starting out.
You can take your Lua knowledge a step further with the skill path Scan Systems with Nmap. You’ll learn how to use Lua to write scripts for the ethical hacking tool Network Mapper (Nmap), which is used in network discovery and security auditing.
And if you want to learn more about how popular video games like Roblox are created, be sure to check out our free course Introduction to Game Development or our blog post on other popular game development programming languages.