Top
Best
New

Posted by phreddypharkus 16 hours ago

LuaJIT 3.0 proposed syntax extensions(github.com)
210 points | 134 commentspage 2
mingodad 11 hours ago|
For others interested in alternative syntax to the Lua VM/API sometime ago I've created LJS https://github.com/mingodad/ljs and also https://github.com/mingodad/ljsjit, I've also included an utility lua2ljs program based on the Lemon parser and re2c that convert Lua scripts to LJS with line by line synchronization https://github.com/mingodad/ljs/tree/master/lua2ljs, to test it I've also translated a few non trivial projects (https://github.com/mingodad/ZeroBraneStudioLJS , https://github.com/mingodad/raptorjit-ljs, https://github.com/mingodad/snabb-ljs, https://github.com/mingodad/premake-core/tree/ljs, https://github.com/mingodad/CorsixTH-ljs).

I'm proud of it and thankfull to the Lua/Luajit projects.

matheusmoreira 16 hours ago||
Looks like LuaJIT is really going to fork away from Lua this time. After these changes, it won't be a compatible Lua 5.1 implementation anymore, it will be a new language.

So shouldn't it have a new name?

orthoxerox 9 hours ago||
Why won't it be compatible? Any code written in Lua 5.1 will run on LuaJIT.
matheusmoreira 1 hour ago||
But not the other way around.
orthoxerox 37 minutes ago||
LuaJIT has always been a superset of 5.1.
ulbu 12 hours ago|||
well, it doesn’t say Lua5.1-JIT
a_t48 15 hours ago|||
It could be opt in.
sourcegrift 15 hours ago||
Are there any rough estimates on popularity of lua implementations? At this point it feels lua means luajit
latenightcoding 15 hours ago||
not even close, because there are a lot of places where you can't run LuaJIT
tuvix 13 hours ago|||
Where can you not run LuaJIT? Genuinely curious
Boxxed 13 hours ago|||
Wasm and platforms like iOS and Nintendo Switch (I think).
extrememacaroni 13 hours ago|||
anywhere that does not allow self modifying code such as app stores.
Dylan16807 12 hours ago|||
LuaJIT is not just a JIT, it also includes high speed interpreters for x86, Arm, and more.
coneonthefloor 2 hours ago||
The syntax proposals look fine. But I don’t feel they are needed. Lua is easy to write and grok. I default to using LuaJIT, and have never had an issue with the actual code. Integration with the Lua ecosystem is the problem. Fix the compatibility issues with LuaRocks packages and PucRio. That would be the best dev ex update in my opinion.
bawolff 15 hours ago||
+= and ..= are things i find i'm constantly missing in lua.

Personally im a fan of introducing ternaranary operator in lua. Everyone uses `x and y or z` as a ternanary which i find way more confusing than ?:

linzhangrun 11 hours ago|
Lua pursues "simplicity, purity, and simplicity." So... too much syntactic sugar is unlikely
spankalee 11 hours ago||
They shouldn't add the ternary operator, it keeps `?` from being usable on it's own for safe navigation and requires the ugly `?.` operator, like `a?.[b]` or `f?.()` instead of `a?[b]` or `f?()`.
orphea 6 hours ago|
Yep. This is awful:

  obj?.:method(…)
pseudony 13 hours ago||
Seems like a bad idea to actively diverge from Lua, hostile even, especially without at least a clear change of name.
drunken_thor 3 hours ago||
Some of these things are already implemented in PUC Lua. I don't know why they are diverting from lua spec on other aspects though. Why not work together with the PUC Lua team to add some of these to both lua versions and work on bringing their functionality closer to each other instead of further apart. You might as well just make a new language instead. New features will end up not being used in effort to keep lua scripts portable.

In effort to not pollute the github issue, and hopes that the authors read this thread, I will put some of my thoughts here. There are 3 main strengths of Lua: Embeddable, Fast, and Small(easy to learn). I worry some of these changes divert from the last, expanding the language into a more complicated language.

Here is a list of things already implemented in PUC Lua so can be considered safe to add:

  ● ~ a     Bitwise negate
  ● a & b   Bitwise and
  ● a | b   Bitwise or
  ● a ~ b   Bitwise Xor
  ● a << b  Left-shift
  ● a >> b  Logical right-shift
  ● a // b  Floor divide
  ● break   Break statement
Don't get me wrong, I love some of these quality of life changes like:

  ● Const keyword: changing const from `local a <const> = 42` to `const a = 42` is far better syntax. The bracketed syntax was never a good idea.
  ● nil-Coalescing and safe navigation are great additions as they are basically macros at the parsing stage.
  ● Compound assignment is also basically a macro at the parsing stage as well. Lua should already have this honestly.
  ● Ternary Operator: I *like* it and it will help the stumbling block of the `a and b or c` common pattern already in use. Though I think (like others have stated) the If/then/else syntax would be more inline with the language, similar to ruby and would enable far more emergent behaviour. However it does establish a new pattern that the last value in a block is a return value similar to ruby so I am conflicted about that.
  ● `continue` it is nicer than a goto and is helpful.
  ● String interpolation: I honestly don't love lua's concat operator `..` so honestly string interpolation would be a nice to have and a feature of many modern languages. However I do worry about it's effect on parsing performance, and complexity of the language.
  ● Underscores in numbers: *shrug*
These are great ideas for the language but I would want all lua versions to support them, not just JIT. These are things that I think are a distraction:

  ● The `and` `&&` and `or` `||`. This just goes in the wrong direction for lua. It is often confusing in ruby (especially because of precedence issues) but also lua is a wordy language. It has `do` `end` blocks instead of brackets. It adds ambiguity for no reason.
  ● Short form function syntax. Lua does not need this and I am not sure anyone asked for this. Why `a = |x| do ... end` is more helpful than just `a = function(x) ... end` is unclear and would love to hear more about why this is being considered.
  ● Named varargs: It may be nice, but there is no real reason to add this. If you wanted a name for your varargs you could do `local name = ...` or just use the `args` variable already available in every function.
  ● Switch/Match/Select Statements: An optimized if/else block works just as well and another expansion of a small language.
linzhangrun 15 hours ago||
I thought luajit had completely stopped feature updates
le-mark 15 hours ago|
I’m confused I thought Mike Pall left luajit and Laurence Tratt took over as maintainer?
ltratt 16 minutes ago||
We did have a project some years ago looking at extending LuaJIT on which Tom Fransham did excellent work. Alas, the funder's priorities moved on (as is their right!), so we didn't get to finish it. It was a bit sad, as we (well, mostly Tom) had built up a real head of steam, but c'est la vie. Still, either way, I would never have claimed enough personal expertise with LuaJIT to take over maintainership!
dang 14 hours ago|||
Mike Pall is to LuaJIT as PG is to Hacker News.

Edit: meaning he can come back anytime.

misiek08 7 hours ago||
He left for a break, returned and there was no second break or anything.

I don't want to spam it in repo, so leaving it here: he is kind of a hero doing this work and I (hopefully we) am very grateful for his contribution to this world.

swah 6 hours ago||
Are there great uses of LuaJIT out there? It was such a big thing before fast JS engines IIRC.
orthoxerox 1 hour ago|||
Cloudflare does or at least did use it a lot.
LargoLasskhyfv 1 hour ago|||
https://en.wikipedia.org/wiki/Torch_(machine_learning)

http://torch.ch/

https://github.com/torch/torch7

More comments...