loading...
Cover image for Is Lua Doomed?

Is Lua Doomed?

adam_cyclones profile image Adam Crockett ・1 min read
function say.greet()
   print("Lua rocks!")
end

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?

Posted on by:

adam_cyclones profile

Adam Crockett

@adam_cyclones

I work at ForgeRock as Staff UI Engineer, I play with all sorts really. Lately WASM is my toy of interest.

Discussion

pic
Editor guide
 

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.

 

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

 

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

 

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.

 

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.

 

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.

 

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. :)

 

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.