Join the discussion
Write your take first — we'll ask for email only when you're ready to publish.
- Hacker News
- 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.
by mingodad - This:
Is not a good idea. I tried using Haxe with Lua target at some point - the mismatch between what you think you get with [], and what you actually get in Lua, requires either a lot of boilerplate (Haxe compiles [] to Array objects), or a chronic WTF from all the new people reading your code (and from yourself, after a few weeks to months of disuse). If you want [1,2,3], make it behave more like an array - or just leave it out, would be my advice. Lua doesn't have arrays, and adding syntax that suggests it does will be a permanent footgun for your users, I think.var ary = [1,2,3,4]; //Array style declaration, syntax sugar for {}by klibertp - It might have been better to publicly document and stabilise the LuaJIT bytecode, which would allow people to then come up with whatever syntax they wanted in their own custom frontends.by HexDecOctBin
- 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.
by kibwen - The btiwise operators library doesn’t go awayby JSR_FDED
- Doesn't Zig also have bitwise operators?by gautamcgoel
- 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.by krapp
- You can have them in C/C++ at least [1]
[1] https://en.cppreference.com/cpp/language/operator_alternativ...
by astrobe_ - 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.
by Dylan16807 - One of the interesting things about Lua is because they don't really maintain compatibility between major versions, there isn't a huge ecosystem, and as a result there's less friction against making your own, slightly incompatible version. When you add on the simplicity of implementing the language, it's created a really diverse set of lua-alikes. Weird (and cool) for a language to have a diverse ecosystem of implementations, but not necessarily libraries.by camgunz
- Fragmentation is terrible for a language. Just look at Scheme. Nobody actually uses Scheme itself, it's always some Scheme implementation like Racket, Guile, Chicken, Chez, etc.
Languages should probably protect themselves with trademarks or something.
- 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?
- Are there any rough estimates on popularity of lua implementations? At this point it feels lua means luajitby sourcegrift
- It could be opt in.by a_t48
- well, it doesn’t say Lua5.1-JITby ulbu
- Why won't it be compatible? Any code written in Lua 5.1 will run on LuaJIT.by orthoxerox
- Never will I understand ternary operators. As soon as you introduce it, some chuckle heads want to use them everywhere. Worse if the syntax allows nested ternarys. I guess it keeps the language open for code golfing, but it otherwise seems like redundant syntax that at best saves a few characters.by 3eb7988a1663
- In Lua (and LuaJIT) you can already use `and` and `or`:
The knuckle heads are already using them everywhere.local x = y and y + 1 or 0by otikik - I find it most useful in languages that have non-mutable variables and you want to avoid a mutable variable or an extra function when the value comes from a simple condition.by hiccuphippo
- I guess for the JS case it makes sense to be able to shave a few characters for file shrinking purposes, but generally I'm more biased to code clarity and "self-explainability"by Gualdrapo
- Lua basically already has ternary operators anyway since "and" and "or" short circuit. I also don't see the need of adding additional syntax for it.
local x = condition ? value_a : value b local x = condition and value_a or value_bby 201984 - That’s why “if” should just be an expressionby demilicious
- I see JavaScript.
Some of these really look like QoL improvements. I'm not convinced ternary statements are an ergonomic improvement in particular. The examples given don't make a compelling case, 'visually tidy' is not the same as readable.
by ricardobeat - Lua to me always felt very JavaScripty, just with a different syntax.by fluoridation
- I kinda have seen somewhere on internet, that the language design of lua and js(well, ecmascript to be precise) is somehow related. But can't really find the exact reference I have seen.. it was long time ago when I read this.by jsomedon
- Worse, I see C (as in ! or &&), and Perl (as in manifestly more than one way to do it).
There are real improvements though, such as ?. and ??= that help with default-nullable everything.
Ternary is very useful, but it I'd rather see it implemented idiomatically:
Structural pattern-matching could be fantastic, but no syntax is suggested.pos += (if forward then +1 else -1)by nine_k - Tangently related but I’ve been deep in Lua recently working on a rust implementation that supports Lua 5.1-5.5 in one Rust Binary https://github.com/ianm199/omnilua.
My ultimate goal was to support LuaJIT in Rust as well but this does not make it easier.
by ianm218 - This is amazing! Can a program call across versions? Like could we take a Lua 5.1 codebase and upgrade only a portion of it at a time to a new Lua version?by genxy
- Oh wow, seriously, I always thought Lua should have been like this. The 5.1/5.2/5.3+ split was so painful.
> My ultimate goal was to support LuaJIT in Rust as well but this does not make it easier.
I think you could stop right before the syntax extension.
by lifthrasiir - Also, one issue I have with this repo is that, since so much of it seems to use Claude, as an actual human I struggle to read and parse any of the information.
For example, what’s the performance like?
by valorzard