DEV Community

Cover image for Is Lua Doomed?
Adam Crockett
Adam Crockett

Posted on

Is Lua Doomed?

function say.greet()
   print("Lua rocks!")
Enter fullscreen mode Exit fullscreen mode

I love Lua as a language it's fantasticly simple, no word of a lie, you can learn all of Lua in around an hour.

If your here reading this you might already know what Lua is and why it's a bit special with it's relationship to C, it's no wonder Lua is big in the game dev world as the scripting language of choice.

Alt Text

Brazil have the most interest, no surprises being the origin of this wonderful language, actually on the subject, Lua is the only language to gain any traction originating from a less developed country in the world.

In web development, Lua can be used and is a major component of OpenResty, aka Nginx's cousin. And yet it has little importance in web development, there are some who wish that Lua could be a direct competitor to JavaScript.

If your wondering, "but does it web?" yes, yes it does, we can run Lua in the browser through Wasm or in node via my node Wasm project (my hopes to make a multiplayer game with Lua game engines), ironically the Lua will be faster than the JavaScript. but honestly it's a toy project.

If a language is dieing a slow death can it ever hope to recover, what does it take to do that?

Top comments (14)

mdxprograms profile image
Josh Waller

Neovim has moved to Lua. I find it best suited for plugin ecosystem but I know there are lots of games using Lua as well. I wouldn't tout it as a dying language. Just has more of a niche on where it shines best.

tilkinsc profile image
Cody Tilkins

I created LuaConsole to address some pitfalls Lua can have. The packaged CLI is just terrible and functions sporadically when combined with multiple different switches. You can't capture output easily due to copyright messages. My aspiration for the project was to also replace bash and batch in my image. That got as far as relying on exec() to do everything, so I focused on making Lua great with a powerful REPL environment and tons of switches for endless possibilities. Lua isn't dying on my watch!

adam_cyclones profile image
Adam Crockett

That gives me hope. A few years back Lua was on a worst languages to learn list for the given year so I sort of just stopped trying to embed it into node.js. I'm resuming my effort for the fun of it

mdxprograms profile image
Josh Waller

As you should! I love Lua as well. It's just not the hot new thing, but still has plenty of love.

ahferroin7 profile image
Austin S. Hemmelgarn

Lua isn't exactly dying, it's just not a general purpose language.

The simple fact is that it fills couple of rather disjoint niche use cases because it has a rather atypical set of major selling points, namely:

  • It's remarkably small and fast for what it is (yes, I'm talking about the reference implementation, not LuaJIT). This is a large part of why it's so popular as an embedded scripting language, it has almost no overhead. This is also why it's used in some of the less well known places it's found, such as the init process for some implementations of L4
  • It's written in ANSI C. That is, it's written in a version of C that's 31 years old now. This is huge because combined with how low the overhead is it means you can run it on damn near anything. I've seen it run on PIC and AVR and MSP430 microcontrollers, I've seen people put it on LEGO Mindstorms NXT control bricks, I've seen people run it on old Garmin handheld GPS units, I've even seen it run as a raw REPL on hardware older than the language itself. Quite simply, if you can develop software for a particular piece of hardware, chances are you can run Lua on it.
  • It's very easy to learn while still being relatively powerful. This is big for a lot of applications where it's used for embedded scripting for a number of reasons, and also makes it attractive for hobbyists and other people who don't program as a career.

Now, it obviously still has some limitations, the big ones being a rather anemic standard library and the fact that a number of the design choices that make it so easy to implement and embed also make doing certain things with it very difficult (lack of true parallelism support in the language itself being one of the biggest examples).

You can see the same kind of thing with a number of other languages, they're very big in specific niche use cases, but almost unheard of outside of those. Forth is an excellent example as a comparison, it's widely used for firmware, but rarely touched for almost anything else.

tilkinsc profile image
Cody Tilkins

I've seen it run on PIC and AVR and MSP430 microcontrollers,
I've even seen it run as a raw REPL on hardware older than the language itself.

It was pretty big in the PSP and PSP hombrew scene. Embedded hardware yes!
I created LuaConsole to patch what was missing from our modern day REPLs. It's still expanding!

gwutama profile image
Galuh Utama • Edited

Lua was never meant to be a general purpose language or an alternative to existing scripting languages. It was designed to be embedded into applications where the complexity and most of the logic are hidden.

There’s really not so many contender in that area. Embedding python in an application is such a hassle, and libpython itself is huge. There’s AngelScript and ChaiScript which are easy to embed but are specifically for C++ only.

Embedding lua is simpler and the library can easily be linked statically. It doesn’t have dependencies. It’s really small. And the language is easy enough that a seasoned programmer can start code in it (to extend the functionality of an application) within a day.

0916dhkim profile image
Danny Kim

Off the topic, but your google trends analysis is a little off. "Lua" simply means the moon in portuguese; no wonder the word is used most often in Brazil and Portugal. Set your scope to programming language, and you will see Lua the language actually gets the most interest from China.

turbine1991 profile image

Lua is really a terrible language. JavaScript is
just far superior.

Every Lua environment is just so different from each other. The ones I've used don't allow for custom exception handling or concurrency. Lua is not used because it's good or the best, it's used because it's easy to embed and it does the job.

adam_cyclones profile image
Adam Crockett

Your comment was quite negative 😔, this is an old post for me but I'm hungover and don't care alot to fight about language X is better than Y.

Lua is (a great language which is interesting to me) if rarely used as I do what the rest of the world does, use JavaScript. Lua has a design philosophy which should be understood before you can say it doesn't even come with Z. That's my two cents

souksyp profile image
Souk Syp.

You can do Javascript for front-end and Lua for back-end.

Check out OpenResty, Lapis Web Framework and Moonscript.

markjschafer profile image
Mark Schafer

I'm fairly new to linux, having been a programmer in clipper5, (dos) for 25 years. First I tried languages that resembled clipper, but they were all dying out. Bash came next, which I'm good at, stumbled around python, rust, then I say a reference to lua. My first 10 minutes, I was just saying WOW.

Lua is the closest I've found to clipper, but then why wouldn't it be, both are written in ansi C. I had customized clipper to be a sudo multi threading system, so working in lua is my choice now. I only found it a few days ago, so I'm still experimenting. So many of the commands and statements are the same, which makes things easier.

I'm going to say that's as long as C Is a functional useful language, lua will exist.

juancarlospaco profile image
Juan Carlos

Lua and LuaJIT should merge and collab together, without it Lua can be slow,
at least thats my feeling when I was learning it, nothing particular with Lua,
I feel the same for Ruby and Crystal etc, now I feel comfy with Nim.

pentacular profile image

Yes. Lua is doomed.

Just like every other language.

As the saying goes, "this too shall pass".

This is not a bad thing - evolution carries on.

The useful ideas popularized by lua will be more likely to be picked up in newer languages, and the bad ideas that became trapped in lua will be allowed to die.

Perhaps your question was intended to be, "Is lua worth investing in?" which is a bit more complicated. :)