Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What’s the dev experience actually like for serious Lua? I’ve only used it for some basic neovim configuration. The dynamicism and lack of type hinting in Python that was the norm when I started having to review professional code, after transitioning from pure mathematics, was a major cognitive blocker for me. With a math paper I could typically skim the first few pages to map the author’s particular symbology (if non-standard) and know exactly what was being expressed. I could never do that with untyped code.


Lua can be quite an elegant language once you get to know it well, but you can still use it like most other programming languages, it's not that weird. There are quirks like arrays starting at 1 (and all arrays being hash tables) but they don't take that long to get used to. The real strength is in the ecosystem and implementation itself, it's designed to be easily embedded into applications and there's not really much else like it. Some developers want to incorporate a scripting language into their project and get turned off by Lua's quirks and choose something else, but it usually ends up causing more problems than it was meant to solve.

On typing, there's only a few main ones you need to worry about—strings, functions, tables and numbers. I don't think it does weird things like JS where it converts between them without asking. Luau adds some type hinting if it's a big point of concern but I haven't really looked into it much.


> There are quirks like arrays starting at 1

I know it’s probably and overreaction, but this was a compete non-starter for me.


While I understand the aversion, I can't help but think that people miss out on some really cool experiences when they balk at stuff like 1-based arrays or parens in Lisp or whatever. Sure, those quirks may remain deal breakers after you've given the language a thorough try, but you may also gain super interesting new perspectives in the process.


Not having to put length-1 everywhere is a good thing, actually.


Probably just use a .last method or something. Reads better too.


There are languages that transpile to Lua that get you things like typing…

https://typescripttolua.github.io/

I’m personally a fan of YueScript which is basically an evolution of MoonScript (but it’s not typed).

https://yuescript.org/

LuaJIT has ridiculously easy C interop.


> What’s the dev experience actually like for serious Lua

The dev experience for lua is f-ing awful.

The language is small, but not “simple”; it’s stuck in 1985.

The tooling is nearly non-existent and the stuff that does exist is a joke.

The few libraries that exist are awful and barely maintained; the maintained libraries are maintained by neckbeards with a god-complex.

The community is “reimplementing everything by hand is the right way to do it AND ALSO you’re an idiot doing it wrong” toxic. There are a million good reasons why it’s only has a foothold in nginx and Roblox territory.

It’s not a joke to say that it’s f-ing terrible all the way around.


Lua was designed in 1993. This was back when MS-DOS was still cutting edge and the 66MHz Pentium was cutting-edge consumer technology.

Even "modern" languages often don't have features like first-class functions, closures, proper tail calls, etc that Lua has had for a very long time now. LuaJIT also trades blows with JS almost certainly making it the fastest or second-fastest dynamic language around.

There's a lot to like about the language (aside from array indexes starting at 1), but I think you are right about the ecosystem and probably right about most of community.


MS-DOS was never cutting edge, but I came here because I wonder about the performance claims.

https://benchmarksgame-team.pages.debian.net/benchmarksgame/...

makes it look fairly slow, competing with Ruby, rather then JS.


He removed LuaJIT from the benchmark opting to use the much slower Lua (Lua is used for small embedded stuff and LuaJIT is used for high-performance stuff with a popular recent example being the game Balatro). Here's the Vercel version which uses LuaJIT. I have no idea if the benchmarks were deoptimized by him (as he did to several language he thought "were too fast").

https://programming-language-benchmarks.vercel.app/lua-vs-ja...

LuaJIT used to have a performance comparison page, but it was removed a couple years ago apparently. It shows that LuaJIT is an average of around 16x faster than standard Lua (geomean). Very impressive considering it was written by just one guy for years (Mike Pall) and even more impressive when you consider that the JIT is only around 0.5mb (compare that with v8 which comes in at somewhere around 28mb IIRC).

https://web.archive.org/web/20230605114058/http://luajit.org...


> I have no idea if …

You have no idea.

> He removed LuaJIT

LuaJIT supports Lua 5.1

The benchmarks game shows Lua 5.4.7


> LuaJIT supports Lua 5.1

From what I understand, LuaJIT was removed before Lua 5.2 was released, so that wasn't the reason.

https://luajit.org/extensions.html

LuaJIT supports most of the features of Lua versions after 5.1 with the major missing feature being 64-bit integers, but like modern JS JITs, it actually uses 31/32-bit ints internally most of the time. Even in Lua 5.4 code, you are using implicit rather than explicit ints 99% of the time.

I haven't run the code to see, but I'm willing to bet that you can copy all the current benchmark code into LuaJIT and it'll run just fine.

> You have no idea.

I know with certainty that deoptimizations were applied to at least some scripts. Here's three examples for Common Lisp, StandardML, and Haskell over some time.

https://zerf.gitlab.io/ComputerLanguageBenchmarksGame2018Arc...

https://github.com/lemire/ComputerLanguageBenchmark/blob/fbe...

https://hackage.haskell.org/package/ajhc-0.8.0.4/src/example...

Here's a C example from Mike Pall (presumably the same guy who created LuaJIT) that also got the deopt treatment by Isaac Gouy.

https://github.com/lemire/ComputerLanguageBenchmark/blob/fbe...

It's not a question of if this happens -- only if it affects Lua (I've never checked).


Wait, that's news to me. Last time I checked, maybe 2 years ago, luajit supported some Lua >5.2 features. But, just a handful of those. Is it truly supporting most of the newer features nowadays?


> extensions.html

On that page, what words do you think support your claim "was removed before Lua 5.2 was released".

> I know with certainty

I made those code changes. I wrote de-optimized as a joke.


nginx and Roblox and redis and nmap and neovim and cryengine … the list goes on

There are a LOT of tools with embedded Lua scripting capabilities.


8 years of full time professional lua development experience here and unfortunately I agree with all of this. I use fennel when I can; it doesn't improve any of the library or tooling problems but it doesn't make them worse either and addresses several of the problems with the language semantics itself.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: