DEV Community

5 reasons you should learn Lua

Jeremy Woertink on December 14, 2018

If you haven't heard of Lua, it's a really small programming language. Maybe you have heard of it, but never had a reason to learn it because your ...
Collapse
 
jld3103 profile image
jld3103

Minus: Arrays start at 1 ;)

Collapse
 
jwoertink profile image
Jeremy Woertink

Ha! Yeah, there's a few weird things in Lua, but once you learn that, then it opens your mind to the fact that not all languages are created equal. Now, if we were to not use a language because it had something weird, we'd all have dropped javascript by now :p lol

Collapse
 
ricky11 profile image
Rishi U

whaaaaa...... mind blown.

Collapse
 
ondrejs profile image
Ondrej • Edited

Another reason - Nmap is written in Lua; customize your Nmap!

Collapse
 
jwoertink profile image
Jeremy Woertink

That's true. Look like a movie hacker with a little lua :D

Collapse
 
ondrejs profile image
Ondrej

Yeah, why not? :) Btw I was joking a little - it's great to customize your nmap, but Lua is also good general scripting language. Sadly, not much used in comparison with Python/Ruby.

Collapse
 
tobiassn profile image
Tobias SN

I’ll admit that Lua was actually my first programming language.

Collapse
 
booterror profile image
Vighnesh SK

Minecraft with computercraft mod has computers and robots(turtle) which are programmed in Lua to do things like dig a strip mine or control machinery with redstone.

Collapse
 
renatosuero profile image
Renato Suero • Edited

Great post Jeremy,

For me as Brazilian is an honor see people write about Lua <3
I'd like to recommend exercism.io, I think that it can be useful to improve the learning.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

It's been a little while since I commented about wanting to learn Lua. I lovit ha, see what I did... Anyway I'l start with what I dislike.

  1. ~= is not !=
  2. Braces are not a thing, I write in braced languages and I find this a little jarring.
  3. require is not node js require

What I love, Lua is tiny, fast and I can change it as I like. I'm currently hijacking V8 to launch the majority of my node js web app in Lua. That includes using the c binding directly from node with node require and a js proxy.

Because why not, it's fun.

Collapse
 
jwoertink profile image
Jeremy Woertink

Awesome! Yeah, I agree with the ~= thing. That throws me off all the time especially since my main languages (Ruby & Crystal) use =~ for regex matching lol. But I don't work in curly brace languages, so for me I love that it doesn't have those :D

Sounds like you found a great use for using Lua! Thanks for sharing.

Collapse
 
jessekphillips profile image
Jesse Phillips

I don't like Lua as a programming language. It is nice to use to extend a language. I like using LuaD to add runtime configuration and logic. The simplicity of the structures and something else I don't know haw to describe is really cool.

Collapse
 
jwoertink profile image
Jeremy Woertink

It's definitely not a primary language for me. Not one of those "do everything" tools, but it has it's place. Almost like that weird screw driver you use on faucets. Most people never need one, but the second you do, it's a nice thing to have.

Collapse
 
samyeyo profile image
Sam

I don't agree. Lua as a programming language has all it takes : garbage collection, iterators, lambdas, speed, simple but powerful types...
It just lacks a better standard library to be able to "do more".

Thread Thread
 
jessekphillips profile image
Jesse Phillips

Lua is definitely not limited as a language. I find that it's focus on being a configuration language to create some not so desirable synthetic choices.

I would probably much rather write a parser for Lua than yaml though.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

I have for the 3rd time looked at Lua but this time with an open mind. I'm interested in webdev. I see LuaRocks and some JavaScript or C like familiarity but also some quirks. I am very excited to try writing something, but I'm not sure what.

Collapse
 
jwoertink profile image
Jeremy Woertink

Making a game love2d.org/wiki/Getting_Started is fun way to start. Or just start by making a small console app and getting that to work. That will help you feel out the flow of lua.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀 • Edited

Very nice idea! Segway: what is the dotnotation in this function declaration function love.load().

Thread Thread
 
jwoertink profile image
Jeremy Woertink

Lua has 2 different type of notations. Since it's not an object oriented language, you can think of . like a class method, and : like an instance method. So love.load() vs love:load(). Lua basically determines what self is based on how you call the functions (if that makes sense)..

Collapse
 
tadman profile image
Scott Tadman
  1. It takes very little time! There's not too much to Lua so you can pick it up quickly.
Collapse
 
wfelix profile image
W. Felix

Recently I wrote a script to authenticate users against Redis with Lua on Nginx. The result was great in simplicity and performance. The code is available on my Github github.com/waldyrfelix/nginx_lua_auth

Collapse
 
pyrodogg profile image
Skyler Kehren

I was introduced to Lua in ComputerCraft, a Minecraft mod. Most recently I've been diving into the Advent of Code challenges in it, although I'm falling behind. I find it a flexible language to use when solving fun problems.

Collapse
 
joshuawoodsdev profile image
JoshuaWoods

I want to learn it I'm learning ERB, And I just learned the basics of INK. I would like to learn Lau where can I start?

Collapse
 
jwoertink profile image
Jeremy Woertink

When you say ERB, do you mean in ruby? I'm not sure what INK is... but you can start here to learn Lua tylerneylon.com/a/learn-lua/

Collapse
 
joshuawoodsdev profile image
JoshuaWoods

Yes, I started learning Rails and Middleman but then I hit a wall. I was like whats ERB? I got it but not I have to learn just how the layouts work? Like how to I make a picture go into the place I want it to go with <%yeild%> I have not found a place that explained how outside of the super basic layouts. And INK is cool inklestudios.com/ink/ thanks so much for your response.

Thread Thread
 
jwoertink profile image
Jeremy Woertink

Not really the place for these, but ERB is just HTML where you can use ruby code to extend, and dynamically generate HTML. If you don't know HTML that well, then you should start there. Placing an image is as easy as just using <img src="" > where you want it. The only difference being that your src attribute has to be dynamic based on the asset pipeline or however you serve up your images. Rails also gives you the image_tag helper method to make it more ruby-like.

That ink looks cool.

Thread Thread
 
joshuawoodsdev profile image
JoshuaWoods

Lau looks like a really good language, I interested in starting to learn it it seems that you you can do alot with it

Collapse
 
tepythai profile image
Tepy Thai

I've started my first line of code in Lua to build game using Corona SDK :D

Collapse
 
rapidnerd profile image
George

Lua is a great language, only thing I don't like about it is that arrays start at 1 instead of 0

Collapse
 
jdespraz profile image
Julie

We started using Lua for Alloverse, an app platform for collaborative workspace in VR/AR - and so much easier! Loving it!

Collapse
 
megatux profile image
Cristian Molina • Edited

Also, the Luajit Lua implementation is very fast.
Kong is made with Lua.
Moonscript and Haxe transpile to Lua.

moonscript.org/
haxe.org

Collapse
 
neryajanel profile image
Nery Ajanel

for video games is behind c ++ or c #, I think execelent that has a lot of weight, very strong in video games