32 comments

  • Ardren10 hours ago
    &gt; For compatibility with other computer languages, the following classic Lua operators can be written in a more customary syntax:<p>Why though? What does changing `and` to `&amp;&amp;` actually achieve? Were people confused?<p>Changing the syntax seems very surface level. It&#x27;s not actually fixing any problems, just making Lua no longer look like Lua. It&#x27;s not going to help anyone write&#x2F;learn Lua. It will make everything more complicated as there are now two ways to do everything.<p>This feels like adding braces to Python because you don&#x27;t like indenting your code.
    • nullpoint4209 hours ago
      &gt; This feels like adding braces to Python because you don&#x27;t like indenting your code.<p>Now this I can get behind...
      • bonoboTP5 hours ago
        You need Bython <a href="https:&#x2F;&#x2F;github.com&#x2F;mathialo&#x2F;bython" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mathialo&#x2F;bython</a>
    • simonask7 hours ago
      Ruby has both kinds of operators as well, and it&#x27;s fine. The thing in Ruby, though, is that the English logical operators have lower precedence than the symbolic logical operators, so you can use them in place of parentheses. Sometimes that&#x27;s confusing, other times it can be used to make code very readable.<p>In general, I would expect symbolic operators to be desirable in complex boolean expressions, because &quot;loud punctuation&quot; stands out among English words when reading the code.
      • spider-mario4 hours ago
        Same in Perl, hence the good old pattern:<p><pre><code> open my $fh, &#x27;&lt;&#x27;, &#x27;input.txt&#x27; or die;</code></pre>
        • codesnik3 hours ago
          yes, ruby inherited this from perl, though &#x27;or&#x27; has lower precedence than &#x27;and&#x27; in perl, and they&#x27;re equal in ruby. Which sounds like something going to cause mistakes, but I yet to see &#x27;and&#x27; and &#x27;or&#x27; together in the same expression in ruby.
      • ClikeX3 hours ago
        I&#x27;ve always found it odd that and&#x2F;or in Ruby isn&#x27;t just considered equal to &amp;&amp;&#x2F;||, and I have never really used the english operators except for the usual modifiers like if and unless.<p>What is a practical use case where the lower precedence makes sense?
        • aeonflux7 minutes ago
          Those two behave in the same way if you drop the parentheses:<p>1. statement if (condition || something)<p>2. (statement if condition) or something
    • doophus8 hours ago
      &gt; Why though? What does changing `and` to `&amp;&amp;` actually achieve? Were people confused?<p>Also consider AI, that has a greater training base of JavaScript than Lua. So making Lua look more like JS, should improve output and reduce mistakes.
      • lionkor7 hours ago
        No, don&#x27;t consider AI.
      • boxed7 hours ago
        AI has greater training on Python, which uses `and` and `or`, and it has absolutely no issue keeping that straight.
  • Heliodex12 hours ago
    A comment &lt;<a href="https:&#x2F;&#x2F;github.com&#x2F;LuaJIT&#x2F;LuaJIT&#x2F;issues&#x2F;1475#issuecomment-4790753620" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;LuaJIT&#x2F;LuaJIT&#x2F;issues&#x2F;1475#issuecomment-47...</a>&gt; has already been made on the issue regarding the ternary operator, recommending `if x then y else z` over `x ? y : z`. This is exactly how it&#x27;s done with if-then-else expressions in Luau &lt;<a href="https:&#x2F;&#x2F;luau.org&#x2F;syntax&#x2F;#if-then-else-expressions" rel="nofollow">https:&#x2F;&#x2F;luau.org&#x2F;syntax&#x2F;#if-then-else-expressions</a>&gt;, another language compatible with Lua, and makes it a ton easier to nest (especially with elseif) and I believe still easier to read than `y if x else z`.
    • noelwelsh6 hours ago
      Exactly. I don&#x27;t understand why people think the ternary operator is needed when you can just make `if` an expression instead of a statement. Then there is no new syntax to learn and `if` just becomes more useful.
      • aeonflux4 minutes ago
        I don&#x27;t really understand where is this need to compress the logic into where small chunks comes from. In result we get single line of code which has multiple statement conditions, different paths, and it&#x27;s not possible to grasp in one go.<p>Other practical example why ternary is bad: Many code-coverage solutions break on ternary because they don&#x27;t correctly see that one of the branches was missed in tests.
    • mjcohen12 hours ago
      The ternary operator is easy to nest if you put each clause on a separate line. Then it looks just like nested if-then-else.
      • edoceo12 hours ago
        I love the ternary operator as much as anyone. But dang if it doesn&#x27;t get hard to read when there is are a few, nested even.<p>Does that operator compile to faster assembly that if I make the same logic with verbose `if` logic? Is that a language specific outcome?
        • gnubison11 hours ago
          <p><pre><code> cond1 ? res1 : cond2 ? res2 : cond3 ? res3 : or_else_res </code></pre> If they are truly nested, then that is confusing. But if you have an if-else chain, then it can be quite readable.
          • a-french-anon6 hours ago
            Or they could just ask granddaddy for advice:<p><pre><code> (cond (cond1 res1) (cond2 res2) (cond3 res3) (t else_res)) </code></pre> =)
          • froh1 hour ago
            or<p><pre><code> if cond1 then res1 else if cond2 then res2 else if cond3 then res3 else or_else_res </code></pre> or<p><pre><code> if cond1 then res1 elif cond2 then res2 elif cond3 then res3 else or_else_res </code></pre> what is most lua-like?
          • shevy-java10 hours ago
            I find that so much harder to read compared to if&#x2F;else or case&#x2F;when in ruby.<p>The ? is basically an attempt to use fewer if&#x2F;else, at the cost of condensed if-else like structure. I always need to look at both parts after the ? whereas in a single if or elsif I don&#x27;t. case&#x2F;when in ruby is even better here e. g. regex check:<p><pre><code> def foo(i) case i when &#x2F;^cat&#x2F; handle_cats when &#x2F;^dog&#x2F; handle_dogs </code></pre> (I ommitted the &quot;end&quot;s here to just focus on the conditional logic.)
      • spider-mario4 hours ago
        Unless you mess up its associativity, like PHP until 7.4.<p><a href="https:&#x2F;&#x2F;wiki.php.net&#x2F;rfc&#x2F;ternary_associativity" rel="nofollow">https:&#x2F;&#x2F;wiki.php.net&#x2F;rfc&#x2F;ternary_associativity</a><p><a href="http:&#x2F;&#x2F;phpsadness.com&#x2F;sad&#x2F;30" rel="nofollow">http:&#x2F;&#x2F;phpsadness.com&#x2F;sad&#x2F;30</a>
  • mid-kid1 hour ago
    LuaJIT has held back the lua ecosystem for over a decade. There&#x27;s no reason to not at least try to move the implementation closer to luau or puc lua, not create yet more incompatible syntax
    • kzrdude44 minutes ago
      I don&#x27;t think Lua is your average ecosystem. Lua is used as an embedded interpreter. For example, Neovim doesn&#x27;t want to change its configuration language&#x27;s syntax just because there is a new version of Lua available.<p>On the contrary, we can claim that luajit has stabilized lua for implementations and for users (strengthening Lua 5.1 dominance, which makes the experience more homogenous across apps).
  • omoikane11 hours ago
    Lua 5.3 (2015-01-12) added the bitwise operators:<p><a href="https:&#x2F;&#x2F;www.lua.org&#x2F;versions.html#5.3" rel="nofollow">https:&#x2F;&#x2F;www.lua.org&#x2F;versions.html#5.3</a><p><a href="https:&#x2F;&#x2F;www.lua.org&#x2F;manual&#x2F;5.3&#x2F;manual.html#3.4.2" rel="nofollow">https:&#x2F;&#x2F;www.lua.org&#x2F;manual&#x2F;5.3&#x2F;manual.html#3.4.2</a><p>Looks like LuaJIT is catching up, but calling these &quot;syntax extensions&quot; is confusing. Is the intent to hold LuaJIT fixed against some earlier Lua version (I guess 5.1) and adopt newer syntax piecemeal?<p>I welcome the compound assignment operators. Playdate&#x27;s version of Lua also has that extension.
    • orthoxerox7 hours ago
      LuaJIT is an involuntary fork of 5.1. It already had various extensions that conflicted with the 5.2 implementation of the same features, and Mike Pall made it clear on the mailing list he wasn&#x27;t going to change how LuaJIT worked.
  • pansa213 hours ago
    So is LuaJIT resuming active development after a decade or so of only maintenance? Great!<p>A lot of these changes make sense (although some of them are a bit too TIMTOWTDI for my taste) - but perhaps LuaJIT 3 would benefit from a change of name as well? Certainly with all these changes, it would be more like a separate language than merely a JIT-compiled version of Lua.
    • orthoxerox7 hours ago
      A bunch of them are from Luau, the Roblox fork of Lua and the dialect most young programmers know. Adding them to LuaJIT will make it easier to write for both Zoomers and AI agents, who have been exposed to a lot of Luau code.
      • krapp4 hours ago
        I know the LuaJIT maintainer(s?) will never add it because it&#x27;s too radical a departure from Lua but I wish they would include Luau&#x27;s type annotations. There are typed languages like Teal that will compile to Lua that should work (although I&#x27;ve had a difficult time getting Teal to work with cdefs) and you can kind of fake it by using C structs obviously but having such a feature be native to Lua itself would be nice.
    • 20198413 hours ago
      &gt;TIMTOWTDI<p>What on earth is this supposed to mean?
      • Twirrim13 hours ago
        There Is More Than One Way To Do It.<p>That takes me back a bit. It&#x27;s a perl-ism. I used to think it was a great design feature but I&#x27;ve come to strongly prefer &quot;There should be one way to do it, and it should be obvious&quot;
        • BobBagwill30 minutes ago
          TCBOO, AKA, the Highlander Conjecture.
        • 20198413 hours ago
          Interesting, thank you.
        • ncruces4 hours ago
          Using acronyms is one of those ways. &#x2F;s
      • matheusmoreira13 hours ago
        There is more than one way to do it.
  • camgunz7 hours ago
    One of the interesting things about Lua is because they don&#x27;t really maintain compatibility between major versions, there isn&#x27;t a huge ecosystem, and as a result there&#x27;s less friction against making your own, slightly incompatible version. When you add on the simplicity of implementing the language, it&#x27;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.
  • ianm21811 hours ago
    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 <a href="https:&#x2F;&#x2F;github.com&#x2F;ianm199&#x2F;omnilua" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ianm199&#x2F;omnilua</a>.<p>My ultimate goal was to support LuaJIT in Rust as well but this does not make it easier.
    • valorzard8 hours ago
      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.<p>For example, what’s the performance like?
      • ianm2181 hour ago
        Performance dashboard is linked here <a href="https:&#x2F;&#x2F;ianm199.github.io&#x2F;omnilua&#x2F;performance.html" rel="nofollow">https:&#x2F;&#x2F;ianm199.github.io&#x2F;omnilua&#x2F;performance.html</a>.<p>In a mix of official and unofficial benchmarks wall clock performance is ~1.4x as fast as C Lua and the memory usage is ~1.7x.<p>So performance is worse to be clear but within range. There’s some performance improvements I haven’t gone for yet that would get it down to ~1.1 I think.
    • lifthrasiir9 hours ago
      Oh wow, seriously, I always thought Lua should have been like this. The 5.1&#x2F;5.2&#x2F;5.3+ split was so painful.<p>&gt; My ultimate goal was to support LuaJIT in Rust as well but this does not make it easier.<p>I think you could stop right before the syntax extension.
    • genxy9 hours ago
      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?
    • valorzard8 hours ago
      [dead]
  • ricardobeat13 hours ago
    I see JavaScript.<p>Some of these really look like QoL improvements. I&#x27;m not convinced ternary statements are an ergonomic improvement in particular. The examples given don&#x27;t make a compelling case, &#x27;visually tidy&#x27; is not the same as readable.
    • nine_k12 hours ago
      Worse, I see C (as in ! or &amp;&amp;), and Perl (as in manifestly more than one way to do it).<p>There are real improvements though, such as ?. and ??= that help with default-nullable everything.<p>Ternary is very useful, but it I&#x27;d rather see it implemented idiomatically:<p><pre><code> pos += (if forward then +1 else -1) </code></pre> Structural pattern-matching could be fantastic, but no syntax is suggested.
    • jsomedon5 hours ago
      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&#x27;t really find the exact reference I have seen.. it was long time ago when I read this.
      • cygx3 hours ago
        There&#x27;s some overlap in the languages they were inspired by (eg Scheme, or the chains Modula -&gt; Lua vs Modula -&gt; Java -&gt; Javascript), but as far as I&#x27;m aware, the original designs were made independently.<p>Now, the object systems do look similar, but that seems to be a case of convergent evolution: Javascript took direct inspiration from Self, whereas Lua&#x27;s system is based on a more generic fallback mechanism for table access.
    • fluoridation6 hours ago
      Lua to me always felt very JavaScripty, just with a different syntax.
      • drdexebtjl54 minutes ago
        Lua predates JavaScript by about 2 years though.
  • 3eb7988a166313 hours ago
    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.
    • demilicious12 hours ago
      That’s why “if” should just be an expression
      • matheusmoreira12 hours ago
        This is the best answer in my opinion. Ternary is just sugar for an expressive if. LuaJIT seems to be focusing on adding new syntax though, maintainer might not be amenable to updating existing semantics.
        • wavemode11 hours ago
          I don&#x27;t think if-expressions have to affect existing semantics. Basically, in the parser you would have two different kinds of AST nodes, one for when the `if` keyword is encountered in statement position and another for when it&#x27;s encountered in expression position.<p>Right now, `if` in expression position is just a syntax error (&quot;unexpected symbol&quot;)
          • Joker_vD9 hours ago
            Well, I believe there could be some complications with parsing related to the fact that Lua grammar doesn&#x27;t really requires semicolons between the statements.<p>But other than that, yeah, detecting &quot;if&quot; in the expression position is pretty unambiguous. No idea why most languages went with &quot;cond-expr ? then-expr : else-expr&quot; bracketed syntax instead.
            • _flux8 hours ago
              Surely the most likely explanation is familiary from C?<p>But e.g. ml-family languages (like OCaml, F#, Haskell) and Rust just have the *if* expression that has a non-void value. If your language accepts expressions as statements (most do?), then I think that should just be compatible out of the box.
              • Joker_vD8 hours ago
                Yes, but why C had that syntax? Oh, right, because it didn&#x27;t use if-then[-else]-end for the conditional statement, and reusing if(cond)[-else] with prohibited braces would be awkward.<p>Oh, and Lua most famously does <i>not</i> accept expressions as statements. Which, now that I think of it, would actually evade most of the parsing complications.
      • NuclearPM10 hours ago
        Yep. Everything should be.
    • otikik15 minutes ago
      In Lua (and LuaJIT) you can already use `and` and `or`:<p><pre><code> local x = y and y + 1 or 0 </code></pre> The knuckle heads are already using them everywhere.
    • 20198413 hours ago
      Lua basically already has ternary operators anyway since &quot;and&quot; and &quot;or&quot; short circuit. I also don&#x27;t see the need of adding additional syntax for it.<p><pre><code> local x = condition ? value_a : value b local x = condition and value_a or value_b</code></pre>
      • matheusmoreira12 hours ago
        &gt; The classic Lua idiom a and b or c has a pitfall when b is nil or false: then c is returned, even when a is truthy.<p>&gt; E.g. true and false or 42 returns 42, whereas true ? false : 42 returns the (expected) false.
    • Gualdrapo12 hours ago
      I guess for the JS case it makes sense to be able to shave a few characters for file shrinking purposes, but generally I&#x27;m more biased to code clarity and &quot;self-explainability&quot;
      • NuclearPM10 hours ago
        That’s what compression is for.
    • hiccuphippo12 hours ago
      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.
  • mingodad8 hours ago
    For others interested in alternative syntax to the Lua VM&#x2F;API sometime ago I&#x27;ve created LJS <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljs</a> and also <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljsjit" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljsjit</a>, I&#x27;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 <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljs&#x2F;tree&#x2F;master&#x2F;lua2ljs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ljs&#x2F;tree&#x2F;master&#x2F;lua2ljs</a>, to test it I&#x27;ve also translated a few non trivial projects (<a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ZeroBraneStudioLJS" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;ZeroBraneStudioLJS</a> , <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;raptorjit-ljs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;raptorjit-ljs</a>, <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;snabb-ljs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;snabb-ljs</a>, <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;premake-core&#x2F;tree&#x2F;ljs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;premake-core&#x2F;tree&#x2F;ljs</a>, <a href="https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;CorsixTH-ljs" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mingodad&#x2F;CorsixTH-ljs</a>).<p>I&#x27;m proud of it and thankfull to the Lua&#x2F;Luajit projects.
  • HexDecOctBin8 hours ago
    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.
  • matheusmoreira13 hours ago
    Looks like LuaJIT is really going to fork away from Lua this time. After these changes, it won&#x27;t be a compatible Lua 5.1 implementation anymore, it will be a new language.<p>So shouldn&#x27;t it have a new name?
    • orthoxerox7 hours ago
      Why won&#x27;t it be compatible? Any code written in Lua 5.1 will run on LuaJIT.
    • ulbu9 hours ago
      well, it doesn’t say Lua5.1-JIT
    • a_t4812 hours ago
      It could be opt in.
    • sourcegrift12 hours ago
      Are there any rough estimates on popularity of lua implementations? At this point it feels lua means luajit
      • latenightcoding12 hours ago
        not even close, because there are a lot of places where you can&#x27;t run LuaJIT
        • tuvix10 hours ago
          Where can you not run LuaJIT? Genuinely curious
          • Boxxed10 hours ago
            Wasm and platforms like iOS and Nintendo Switch (I think).
          • extrememacaroni10 hours ago
            anywhere that does not allow self modifying code such as app stores.
        • Dylan168079 hours ago
          LuaJIT is not just a JIT, it also includes high speed interpreters for x86, Arm, and more.
  • spankalee8 hours ago
    They shouldn&#x27;t add the ternary operator, it keeps `?` from being usable on it&#x27;s own for safe navigation and requires the ugly `?.` operator, like `a?.[b]` or `f?.()` instead of `a?[b]` or `f?()`.
    • orphea3 hours ago
      Yep. This is awful:<p><pre><code> obj?.:method(…)</code></pre>
  • bawolff13 hours ago
    += and ..= are things i find i&#x27;m constantly missing in lua.<p>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 ?:
    • linzhangrun8 hours ago
      Lua pursues &quot;simplicity, purity, and simplicity.&quot; So... too much syntactic sugar is unlikely
  • drunken_thor16 minutes ago
    I was surprised that LuaJIT didn&#x27;t have some of these things because my side project is constantly working on a Lua VM and I use PUC Lua as a reference. Some of these things are already implemented and released in PUC Lua. I don&#x27;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.<p>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.<p>Here is a list of things already implemented in PUC Lua:<p>- ~ a Bitwise negate - a &amp; b Bitwise and - a | b Bitwise or - a ~ b Bitwise Xor - a &lt;&lt; b Left-shift - a &gt;&gt; b Logical right-shift - a &#x2F;&#x2F; b Floor divide - break Break statement<p>Dont get me wrong, I love some of these quality of life changes like:<p>- changing const from `local a &lt;const&gt; = 42` to `const a = 42`. That syntax is way better. - 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. - I <i>like</i> the ternary operators and will help stumbling block of the `a and b or c` common pattern already in use. Honestly this is just supporting what users are already trying to do. - `continue` it is nicer than a goto and is helpful. - String interpolation: I honestly don&#x27;t love lua&#x27;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&#x27;s effect on parsing performance. _ Underscores in numbers, <i>shrug</i><p>These are great ideas for the language but I would want <i>all</i> lua versions to support them, not just JIT. These are things that I think are a distraction:<p>- The `and` `&amp;&amp;` 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 beyond me. - Named varargs. Like 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&#x2F;Match&#x2F;Select Statements: An optimized if&#x2F;else block works just as well and another expansion of a small language.
  • pseudony10 hours ago
    Seems like a bad idea to actively diverge from Lua, hostile even, especially without at least a clear change of name.
  • linzhangrun13 hours ago
    I thought luajit had completely stopped feature updates
  • le-mark12 hours ago
    I’m confused I thought Mike Pall left luajit and Laurence Tratt took over as maintainer?
    • dang11 hours ago
      Mike Pall is to LuaJIT as PG is to Hacker News.<p>Edit: meaning he can come back anytime.
    • misiek084 hours ago
      He left for a break, returned and there was no second break or anything.<p>I don&#x27;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.
      • swah3 hours ago
        Are there great uses of LuaJIT out there? It was such a big thing before fast JS engines IIRC.
  • larrry12 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
    • Rohansi12 hours ago
      &gt; It’s nice that Lua is simple, the syntax changes should hopefully make Lua code even simpler to read too<p>But which Lua?<p>Lua as implemented by LuaJIT is a fork of the language at this point. It&#x27;s not fully compatible with PUC Lua (the reference implementation) and LuaJIT does not support features from the latest Lua version.
  • childintime6 hours ago
    &gt; local gauge = direction == &quot;up&quot; ? count + 10 : count - 10<p>local gauge = count + (direction == &quot;up&quot; ? 10 : -10)<p>I imagine these changes make the original Lua adepts think their training wheels have come off. The language now looks like any other. That&#x27;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.<p>From that perspective the conditional operator seems defensible, where it would be feature creep otherwise, as it is generally unloved elsewhere.
  • flumpcakes9 hours ago
    Is LuaJIT still based on Lua5.1? I wonder why they haven&#x27;t followed the language spec up to Lua5.5.
    • radiator8 hours ago
      Because they don&#x27;t like the changes, to put it mildly.
  • freestanding2 hours ago
    extensions are detachable&#x2F;optional, those arent extensions but features
  • kibwen12 hours ago
    Please don&#x27;t, inscrutable bitwise operators are an accident of the past even in systems languages, let alone in a scripting language. I&#x27;m not against infix operators for bitwise operations, just please spell them out with keywords rather than giving them sigils.<p>Likewise, going from `and` and `or` to `&amp;&amp;` and `||` would be a dispiriting regression. This is something that Zig got right.
    • Dylan168079 hours ago
      What kind of person understands and needs bitwise operators but can&#x27;t easily remember &amp; | ~ and the arrows for shift? It&#x27;s very little information.<p>The part I&#x27;d call a hassle is the different kinds of right shift but you have that same hassle if you use keywords.<p>I like using the and&#x2F;or keywords for logical operations. Now let&#x27;s make bitwise look significantly different from that.
      • Mond_7 hours ago
        It&#x27;s not about having to remember them, it&#x27;s that you shouldn&#x27;t waste these short single symbols on operations that are only rarely used.<p>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).<p>I dislike basically everything about these syntax extensions.
        • Dylan1680710 minutes ago
          Lua is very unlikely to want to add newer&#x2F;less-common syntax with special symbols.<p>Also a syntax for types can repurpose most symbols without being ambiguous.<p>And you can overload the bitwise operators. You can configure __bor to give you pipelining right now.
    • astrobe_8 hours ago
      You can have them in C&#x2F;C++ at least [1]<p>[1] <a href="https:&#x2F;&#x2F;en.cppreference.com&#x2F;cpp&#x2F;language&#x2F;operator_alternative" rel="nofollow">https:&#x2F;&#x2F;en.cppreference.com&#x2F;cpp&#x2F;language&#x2F;operator_alternativ...</a>
    • gautamcgoel11 hours ago
      Doesn&#x27;t Zig also have bitwise operators?
    • JSR_FDED12 hours ago
      The btiwise operators library doesn’t go away
    • krapp4 hours ago
      I&#x27;m going to disagree only because one of the primary use cases for LuaJIT is interop with C and I think there&#x27;s a case for making the ergonomics match.
  • JSR_FDED12 hours ago
    What’s the Lua&#x2F;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?
    • zdragnar10 hours ago
      There&#x27;s a bunch of options from a Google search, but embedding it in a thin C program and building that with <a href="https:&#x2F;&#x2F;github.com&#x2F;jart&#x2F;cosmopolitan" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jart&#x2F;cosmopolitan</a> would be a pretty go-like experience, I&#x27;d think.
    • gucci-on-fleek11 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&#x27;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&#x27;s usually not <i>too</i> hard.
    • orthoxerox6 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&#x2F;COFF binary that would read itself when run.<p>Love2D does it as well: zip -9 -r SuperGame.love . cat love.exe SuperGame.love &gt; SuperGame.exe<p>This doesn&#x27;t work with ELF files, though.
  • JSR_FDED12 hours ago
    Cool to see this - ergonomic syntax will make it easier to recommend Lua. Hope the PUC team aligns with this.<p>Also, I love this kind of pragmatism:<p>&gt; 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.<p>A ‘defer’ for closing files or deleting temp files at the end of a script will make life more enjoyable.
  • yxhuvud7 hours ago
    In aggregate this looks like a godsend, but there are some examples (like foo?.:method) that looks atrocious.
    • Ciantic4 hours ago
      Yeah, &quot;?.&quot; as safe navigation operator even in JS where it already exists is eye-sore. They could use some other single character instead of two characters. Question mark is already doing a lot with ternaries etc.<p>Instead of obj?.:method?.(…) it would be like obj#:method#(…)<p>Replace # with your favorite extra character instead of questionmark.
      • JBits1 hour ago
        Is there any reason why they&#x27;re not considering a single &#x27;?&#x27; like rust? Is it a parsing issue?<p>So you&#x27;d have: obj?:method(…)
  • sourcegrift12 hours ago
    What are some pragmatic embedded scripting languages of choice these days if one has to consider:<p>1) Ease of learning, ideally minimal deviant behaviour (eg i consider lua tables to be a new concept in itself)<p>2) Reasonably fast. Not as much as lua jit but even half would be good enough<p>3) Mature<p>4) Has Rust bindings
    • NuclearPM10 hours ago
      Lua. Lua tables are easy and awesome. My hobby language unites Lua tables with functions too.
  • kevinten105 hours ago
    [dead]
  • shevy-java10 hours ago
    Lua has a lot of useless syntax. For instance, the &quot;then&quot;. I have been using ruby and python for many years. Lua is living in the old age here.<p>That&#x27;s just one example of so many more. I get that lua occupies a useful niche with its focus on embedded systems, but lua is not really a well-designed language in general. JavaScript has a similar problem.
    • xonre8 hours ago
      For readability, `then` allows splitting with newlines very long conditional expressions, without having to wrap the condition in parentheses:<p><pre><code> if x + y + z &gt; a or verylongconditionalhere () or anotherverylongconditionalhere () then ... </code></pre> after `if` and `elseif` the parser simply goes on until it finds `then`.
    • Dylan168079 hours ago
      Python spells &quot;then&quot; as &quot;:&quot;<p>In Ruby you can choose between &quot;then&quot; and a newline.<p>This is very pot calling the kettle black.
    • mjmas8 hours ago
      English too
    • modulared10 hours ago
      [dead]