Top
Best
New

Posted by phreddypharkus 18 hours ago

LuaJIT 3.0 proposed syntax extensions(github.com)
210 points | 134 commentspage 3
larrry 17 hours ago|
I would love to see all of these come to LuaJIT (and love2d to support the new version too). It’s nice that Lua is simple, the syntax changes should hopefully make Lua code even simpler to read too
Rohansi 17 hours ago|
> It’s nice that Lua is simple, the syntax changes should hopefully make Lua code even simpler to read too

But which Lua?

Lua as implemented by LuaJIT is a fork of the language at this point. It's not fully compatible with PUC Lua (the reference implementation) and LuaJIT does not support features from the latest Lua version.

klibertp 20 minutes ago|||
> Lua as implemented by LuaJIT is a fork of the language at this point.

Lua is strange. Lua 5.2 was more of a "fork of the language" than LuaJIT, at the time. 5.3 and 5.4 (especially the latter) changed even more. Lua looks like a family of languages, and it seems to be by design. It probably makes sense in the "embedded scripting" space. Lua is not really meant to be (though it obviously is, if you want) a general-purpose language. It's meant for extending other apps, and scripting engines have different requirements than other language implementations: basically, hardcore backward compatibility. But it's impossible to evolve the language and innovate in its design if you commit to that. This is still an academic project, so hardcore backward compatibility is unlikely to be something the authors would value. Hence, the mixed model - every major version is a new "take" on the language. You're expected to pick a version when you first need a scripting engine, and then sit on that version until the end of time. Meanwhile, PUC releases new versions of Lua, and new projects pick those newer versions (and then sit on them forever).

It looks strange, and it has important downsides (a fragmented ecosystem, huge PITA when trying to write portable libraries, so fewer libraries in general, etc.), but it does seem to work in that Lua still exists and, project after project (not within a single project), it continues evolving.

NuclearPM 15 hours ago|||
LuaJIT of course.
lt-runtime 3 hours ago||
The question is does the coding agent like it or not ?
flumpcakes 13 hours ago||
Is LuaJIT still based on Lua5.1? I wonder why they haven't followed the language spec up to Lua5.5.
orthoxerox 3 hours ago||
Because 5.2 had a bunch of breaking changes. https://www.lua.org/manual/5.2/manual.html#8
radiator 12 hours ago||
Because they don't like the changes, to put it mildly.
childintime 10 hours ago||
> local gauge = direction == "up" ? count + 10 : count - 10

local gauge = count + (direction == "up" ? 10 : -10)

I imagine these changes make the original Lua adepts think their training wheels have come off. The language now looks like any other. That's a good thing to me, and it will help with the adoption of the JIT, but the whole language could have been syntax modernized as a result. But.. when the work is done someone else can fork it into something independent from its Lua roots.

From that perspective the conditional operator seems defensible, where it would be feature creep otherwise, as it is generally unloved elsewhere.

kibwen 16 hours ago||
Please don't, inscrutable bitwise operators are an accident of the past even in systems languages, let alone in a scripting language. I'm not against infix operators for bitwise operations, just please spell them out with keywords rather than giving them sigils.

Likewise, going from `and` and `or` to `&&` and `||` would be a dispiriting regression. This is something that Zig got right.

Dylan16807 13 hours ago||
What kind of person understands and needs bitwise operators but can't easily remember & | ~ and the arrows for shift? It's very little information.

The part I'd call a hassle is the different kinds of right shift but you have that same hassle if you use keywords.

I like using the and/or keywords for logical operations. Now let's make bitwise look significantly different from that.

Mond_ 12 hours ago||
It's not about having to remember them, it's that you shouldn't waste these short single symbols on operations that are only rarely used.

This stuff (especially the ternary) are a step backwards. There is just no reason to waste | on a bitwise or that gets used at 1% of the frequency of the standard or. In the future you might have a better use for it (pipeline syntax, sum or union types come to mind in other languages).

I dislike basically everything about these syntax extensions.

Dylan16807 4 hours ago||
Lua is very unlikely to want to add newer/less-common syntax with special symbols.

Also a syntax for types can repurpose most symbols without being ambiguous.

And you can overload the bitwise operators. You can configure __bor to give you pipelining right now.

astrobe_ 12 hours ago|||
You can have them in C/C++ at least [1]

[1] https://en.cppreference.com/cpp/language/operator_alternativ...

gautamcgoel 15 hours ago|||
Doesn't Zig also have bitwise operators?
JSR_FDED 16 hours ago|||
The btiwise operators library doesn’t go away
krapp 9 hours ago||
I'm going to disagree only because one of the primary use cases for LuaJIT is interop with C and I think there's a case for making the ergonomics match.
JSR_FDED 16 hours ago||
What’s the Lua/LuaJIT story these days for bundling up all the scripts of an application into a single file? Is there a way to do the super convenient go-like thing?
zdragnar 15 hours ago||
There's a bunch of options from a Google search, but embedding it in a thin C program and building that with https://github.com/jart/cosmopolitan would be a pretty go-like experience, I'd think.
gucci-on-fleek 15 hours ago|||
I personally use a hand-written C wrapper program (which is not much more than a dozen lines long), and then embed the Lua scripts using objdump. This isn't quite as easy as Go since cross-compiling C programs is often somewhat tricky, but Lua is very portable and has zero dependencies, so it's usually not too hard.
orthoxerox 11 hours ago||
There was a Lua[JIT] fork called Idle that seems to have fallen off the face of the Earth that did exactly that: it would take a small stub program, a runtime library and all the scripts and package them into a single PE/COFF binary that would read itself when run.

Love2D does it as well: zip -9 -r SuperGame.love . cat love.exe SuperGame.love > SuperGame.exe

This doesn't work with ELF files, though.

freestanding 6 hours ago||
extensions are detachable/optional, those arent extensions but features
JSR_FDED 16 hours ago||
Cool to see this - ergonomic syntax will make it easier to recommend Lua. Hope the PUC team aligns with this.

Also, I love this kind of pragmatism:

> Exponentiation assignment a ^= b has been deliberately omitted to avoid a predictable pitfall: this is how xor assignment is written in most other computer languages. Also, a syntax for exponentiation assignment is rarely asked for.

A ‘defer’ for closing files or deleting temp files at the end of a script will make life more enjoyable.

More comments...