Live data from Hacker News

LuaJIT 3.0 proposed syntax extensions

github.com

41–50 of 170 posts

Re: LuaJIT 3.0 proposed syntax extensions

#41

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.

That’s why “if” should just be an expression

Yep. Everything should be.

Re: LuaJIT 3.0 proposed syntax extensions

#42
post #4
post #2

So is LuaJIT resuming active development after a decade or so of only maintenance? Great! 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.

>TIMTOWTDI What on earth is this supposed to mean?

[deleted]

Re: LuaJIT 3.0 proposed syntax extensions

#43

Earlier quoted context omitted.

Are there any rough estimates on popularity of lua implementations? At this point it feels lua means luajit

not even close, because there are a lot of places where you can't run LuaJIT

Where can you not run LuaJIT? Genuinely curious

Re: LuaJIT 3.0 proposed syntax extensions

#44
Lua has a lot of useless syntax. For instance, the "then". I have been using ruby and python for many years. Lua is living in the old age here.

That'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.

Re: LuaJIT 3.0 proposed syntax extensions

#45

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.

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"

That’s what compression is for.

Re: LuaJIT 3.0 proposed syntax extensions

#46
post #23
post #20

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

> 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.

LuaJIT of course.

Re: LuaJIT 3.0 proposed syntax extensions

#47
post #32

Earlier quoted context omitted.

I love the ternary operator as much as anyone. But dang if it doesn't get hard to read when there is are a few, nested even. Does that operator compile to faster assembly that if I make the same logic with verbose `if` logic? Is that a language specific outcome?

cond1 ? res1 : cond2 ? res2 : cond3 ? res3 : or_else_res If they are truly nested, then that is confusing. But if you have an if-else chain, then it can be quite readable.

I find that so much harder to read compared to if/else or case/when in ruby.

The ? is basically an attempt to use fewer if/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't. case/when in ruby is even better here e. g. regex check:

   def foo(i)
     case i
     when /^cat/
       handle_cats
     when /^dog/
       handle_dogs
(I ommitted the "end"s here to just focus on the conditional logic.)

Re: LuaJIT 3.0 proposed syntax extensions

#48

What are some pragmatic embedded scripting languages of choice these days if one has to consider: 1) Ease of learning, ideally minimal deviant behaviour (eg i consider lua tables to be a new concept in itself) 2) Reasonably fast. Not as much as lua jit but even half would be good enough 3) Mature 4) Has Rust bindings

Lua. Lua tables are easy and awesome. My hobby language unites Lua tables with functions too.

Re: LuaJIT 3.0 proposed syntax extensions

#49
> For compatibility with other computer languages, the following classic Lua operators can be written in a more customary syntax:

Why though? What does changing `and` to `&&` actually achieve? Were people confused?

Changing the syntax seems very surface level. It's not actually fixing any problems, just making Lua no longer look like Lua. It's not going to help anyone write/learn Lua. It will make everything more complicated as there are now two ways to do everything.

This feels like adding braces to Python because you don't like indenting your code.

Post reply on HN