Has Lua reached perfection?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
54 messages Options
123
Reply | Threaded
Open this post in threaded view
|

Has Lua reached perfection?

Dibyendu Majumdar
I know that some of the folks on this list do not think so as is
evident from the continuous stream of feature requests. But I can't
think of any feature that I would want added to Lua 5.3 that would
justify breaking backward compatibility. There are some things that I
wish were different about Lua - e.g. I wish that variables were local
by default, or that arrays and hash maps were distinct types, but I
would not want such changes if it meant breaking existing code.

It takes good taste and years of effort to create a language such as
Lua. Despite some 'warts' overall Lua 5.3 appears to have reached a
state of perfection (or maturity) in my view.

Regards
Dibyendu

Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Coda Highland
On Sat, Jan 27, 2018 at 6:44 PM, Dibyendu Majumdar
<[hidden email]> wrote:

> I know that some of the folks on this list do not think so as is
> evident from the continuous stream of feature requests. But I can't
> think of any feature that I would want added to Lua 5.3 that would
> justify breaking backward compatibility. There are some things that I
> wish were different about Lua - e.g. I wish that variables were local
> by default, or that arrays and hash maps were distinct types, but I
> would not want such changes if it meant breaking existing code.
>
> It takes good taste and years of effort to create a language such as
> Lua. Despite some 'warts' overall Lua 5.3 appears to have reached a
> state of perfection (or maturity) in my view.
>
> Regards
> Dibyendu
>

"Perfection is achieved not when there is nothing more to add, but
when there is nothing left to take away."

The 5.x series as a whole is probably pretty close to perfect in terms
of language design. The variations appear to be mostly bikeshedding.

/s/ Adam

Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Dibyendu Majumdar
On 28 January 2018 at 00:52, Coda Highland <[hidden email]> wrote:

> "Perfection is achieved not when there is nothing more to add, but
> when there is nothing left to take away."
>

I would argue that perfection in language design is constrained by two things:

a) The goals of the language
b) The limitations placed by the need for backward compatibility (i.e.
your existing user base)

So one can't necessarily take away things even if they are superfluous.

Regards
Dibyendu

Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Paige DePol
In reply to this post by Dibyendu Majumdar
Dibyendu Majumdar <[hidden email]> wrote:

> I know that some of the folks on this list do not think so as is
> evident from the continuous stream of feature requests. But I can't
> think of any feature that I would want added to Lua 5.3 that would
> justify breaking backward compatibility. There are some things that I
> wish were different about Lua - e.g. I wish that variables were local
> by default, or that arrays and hash maps were distinct types, but I
> would not want such changes if it meant breaking existing code.

One of my goals with Lua++ is to allow fully backwards compatible parsing
of Lua code, which will be placed fully in a namespace. If the backwards
compatibility is not necessary then it can be compiled without that support,
much as Lua does for it's own compatibility. Other than adding new features
to the language I have tried to keep the existing syntax as compatible as
possible, however, my parser will have two modes available when parsing
source code; Lua mode and Lua++ mode as there are some syntax differences.

I think that no matter which features Team Lua adds to the language there
will always be other features that people would like to see added.
Or, features that are added that some see as "bloat" and unnecessary for
the core of the language. As the saying goes; you can please some of the
people some of the time, but not all of the people all of the time.


> It takes good taste and years of effort to create a language such as
> Lua. Despite some 'warts' overall Lua 5.3 appears to have reached a
> state of perfection (or maturity) in my view.

Lua is quite widely used in a number of places that I have seen online.
Quite frequently just used as is, sometimes with additions and changes
to promote interoperability. I don't think it may be fully realised just
how much Lua really is used out there "in the wild". I am always happy
when I find another instance where Lua is used. Team Lua should be very
proud of the language they have created.

~Paige


Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Peter Billam
In reply to this post by Dibyendu Majumdar
Greetings :-)

On 2018-01-28 11:44, Dibyendu Majumdar wrote:
> I know that some of the folks on this list do not think so as is
> evident from the continuous stream of feature requests. But I can't
> think of any feature that I would want added to Lua 5.3 that would
> justify breaking backward compatibility.

I've seen several languages commit slow suicide by adding things
and adding more things and adding more things until they become
a huge mess.  Also I really like the elegance in engineering
that comes from leaving things out if they're not necessary.
So I'm also a bit sad to see this stream of feature requests...
Lua is by far my favorite language, exactly because of its elegance.

Perfection may be too strong a word, but Lua is certainly close
to a local optimum.

Just my 2cents worth...
Peter Billam

http://www.pjb.com.au     [hidden email]     (03) 6278 9410
   The world is an eraser for these words
   -- Long Island Chinese Poem Rain, Pomes All Sizes, Jack Kerouac

Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

KHMan
In reply to this post by Coda Highland
On 1/28/2018 8:52 AM, Coda Highland wrote:

> On Sat, Jan 27, 2018 at 6:44 PM, Dibyendu Majumdar
> <[hidden email]> wrote:
>> I know that some of the folks on this list do not think so as is
>> evident from the continuous stream of feature requests. But I can't
>> think of any feature that I would want added to Lua 5.3 that would
>> justify breaking backward compatibility. There are some things that I
>> wish were different about Lua - e.g. I wish that variables were local
>> by default, or that arrays and hash maps were distinct types, but I
>> would not want such changes if it meant breaking existing code.
>>
>> It takes good taste and years of effort to create a language such as
>> Lua. Despite some 'warts' overall Lua 5.3 appears to have reached a
>> state of perfection (or maturity) in my view.
>>
>> Regards
>> Dibyendu
>>
>
> "Perfection is achieved not when there is nothing more to add, but
> when there is nothing left to take away."
>
> The 5.x series as a whole is probably pretty close to perfect in terms
> of language design. The variations appear to be mostly bikeshedding.

Perfection? No. I agree with what Peter said. When younger, I
would help with this kind of cheerleading. Now, not so much. When
younger, I was suitably impressed when reading about the beautiful
conceptual elegance of Lisp. Now, not so much. Things change.

I want a switch construct! I want a switch construct! I want a
switch construct!

:-) :-p

--
Cheers,
Kein-Hong Man (esq.)
Selangor, Malaysia


Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Paige DePol
KHMan <[hidden email]> wrote:

> On 1/28/2018 8:52 AM, Coda Highland wrote:
> Perfection? No. I agree with what Peter said. When younger, I would help with this kind of cheerleading. Now, not so much. When younger, I was suitably impressed when reading about the beautiful conceptual elegance of Lisp. Now, not so much. Things change.
>
> I want a switch construct! I want a switch construct! I want a switch construct!
>
> :-) :-p

I wrote one of those[1] and it wound up being quite performant... of course
you probably mean you'd like it in vanilla Lua, but I can't help there! ;)

The only restriction with the patch is the 'jumpto' command does not jump
to labels outside the current block, however, that is something I will be
fixing and posting an update for fairly soon.

~Paige

[1] https://github.com/FizzyPopStudios/lua-patches


Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Soni "They/Them" L.
In reply to this post by Dibyendu Majumdar


On 2018-01-27 10:44 PM, Dibyendu Majumdar wrote:

> I know that some of the folks on this list do not think so as is
> evident from the continuous stream of feature requests. But I can't
> think of any feature that I would want added to Lua 5.3 that would
> justify breaking backward compatibility. There are some things that I
> wish were different about Lua - e.g. I wish that variables were local
> by default, or that arrays and hash maps were distinct types, but I
> would not want such changes if it meant breaking existing code.
>
> It takes good taste and years of effort to create a language such as
> Lua. Despite some 'warts' overall Lua 5.3 appears to have reached a
> state of perfection (or maturity) in my view.
>
> Regards
> Dibyendu
>

Yes, Lua 5.3 is pretty close to perfect. It's the almost perfect balance
between performance and flexibility (including optimized varargs). :)

I often miss a trait system/OOP by composition, tho...

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.


Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Coda Highland
In reply to this post by Dibyendu Majumdar
On Sat, Jan 27, 2018 at 6:57 PM, Dibyendu Majumdar
<[hidden email]> wrote:

> On 28 January 2018 at 00:52, Coda Highland <[hidden email]> wrote:
>
>> "Perfection is achieved not when there is nothing more to add, but
>> when there is nothing left to take away."
>>
>
> I would argue that perfection in language design is constrained by two things:
>
> a) The goals of the language
> b) The limitations placed by the need for backward compatibility (i.e.
> your existing user base)
>
> So one can't necessarily take away things even if they are superfluous.
>
> Regards
> Dibyendu
>

Well, certainly so, but at that point they aren't things that remain
to be taken away. :P

/s/ Adam

Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

KHMan
In reply to this post by Paige DePol
On 1/28/2018 10:04 AM, Paige DePol wrote:

> KHMan wrote:
>
>> On 1/28/2018 8:52 AM, Coda Highland wrote:
>> Perfection? No. I agree with what Peter said. When younger, I would help with this kind of cheerleading. Now, not so much. When younger, I was suitably impressed when reading about the beautiful conceptual elegance of Lisp. Now, not so much. Things change.
>>
>> I want a switch construct! I want a switch construct! I want a switch construct!
>>
>> :-) :-p
>
> I wrote one of those[1] and it wound up being quite performant... of course
> you probably mean you'd like it in vanilla Lua, but I can't help there! ;)

Yeah, I reckon we'll have to make more noise then. :-) Lemme get
some pots and pans...

These days I like "no surprises" and being able to clearly express
things in code. After all, Lua is not competing in the JIT
pedal-to-the-metal race, and neither is it going
super-linguistic-expressive as in Perl 5. I'm not so gung-ho on
"minimal" these days.

Switch constructs are almost ubiquitous. For many things, the
brain wants to construct code like a switch statement. Being able
to express an idea clearly as a switch construct is better than
shoehorning the thing into a mass of if-then statements, or worse.
For me, performance is now a secondary consideration.

How many other major languages that avoids having a switch
construct are there? Lua puts in a utf8 library but not a switch
construct?

Clear and unambiguous code is a good thing to have. We want to be
in control of our mass of code, and not the other way round.
(Slightly OT: This week, an Ariane 5 likely launched perfectly on
a wrong heading, flew almost over spectators at Kourou beach, and
mission control appeared to have minimal situational awareness.
Who wants to bet it's related to software engineering and
processes, like last November's Soyuz/Fregat failure? And how much
do you trust software driving your car today?)

So given a choice between "minimal is elegant" and "clear
expression of ideas", guess what I would choose.


> The only restriction with the patch is the 'jumpto' command does not jump
> to labels outside the current block, however, that is something I will be
> fixing and posting an update for fairly soon.
>
> ~Paige
>
> [1] https://github.com/FizzyPopStudios/lua-patches


--
Cheers,
Kein-Hong Man (esq.)
Selangor, Malaysia


Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Sean Conner
It was thus said that the Great KHMan once stated:
>
> How many other major languages that avoids having a switch
> construct are there? Lua puts in a utf8 library but not a switch
> construct?

  Not built in, but ...

        function switch(var,case)
          if case[var] then
            case[var]()
          end
        end
       
        x = 4
       
        switch(x, {
          one   = function() print "yada"  end,
          two   = function() print "blah"  end,
          three = function() print "yahoo" end,
          [4]   = function() print "this is four" end,
        })

  You still have the overhead of a table lookup, but this is about as close
to a switch statement you can get in Lua without changing the language.

  -spc


Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Vadi

I'd like to see Lua's tooling ecosystem improved. As 2017 showed, the tooling a language has on offer is just as important as the language itself.


On Sun, 28 Jan 2018, 9:26 am Sean Conner, <[hidden email]> wrote:
It was thus said that the Great KHMan once stated:
>
> How many other major languages that avoids having a switch
> construct are there? Lua puts in a utf8 library but not a switch
> construct?

  Not built in, but ...

        function switch(var,case)
          if case[var] then
            case[var]()
          end
        end

        x = 4

        switch(x, {
          one   = function() print "yada"  end,
          two   = function() print "blah"  end,
          three = function() print "yahoo" end,
          [4]   = function() print "this is four" end,
        })

  You still have the overhead of a table lookup, but this is about as close
to a switch statement you can get in Lua without changing the language.

  -spc


Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

KHMan
In reply to this post by Sean Conner
On 1/28/2018 4:26 PM, Sean Conner wrote:

> It was thus said that the Great KHMan once stated:
>>
>> How many other major languages that avoids having a switch
>> construct are there? Lua puts in a utf8 library but not a switch
>> construct?
>
>    Not built in, but ...
>
> function switch(var,case)
>  if case[var] then
>    case[var]()
>  end
> end
>
> x = 4
>
> switch(x, {
>  one   = function() print "yada"  end,
>  two   = function() print "blah"  end,
>  three = function() print "yahoo" end,
>  [4]   = function() print "this is four" end,
> })
>
>    You still have the overhead of a table lookup, but this is about as close
> to a switch statement you can get in Lua without changing the language.

There's a lot of legacy wisdom here:

http://lua-users.org/wiki/SwitchStatement

I'd like a native switch. :-) Please, pretty pretty please :-)

--
Cheers,
Kein-Hong Man (esq.)
Selangor, Malaysia



Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Dirk Laurie-2
2018-01-28 10:52 GMT+02:00 KHMan <[hidden email]>:

> I'd like a native switch. :-) Please, pretty pretty please :-)

So which do you want? Like Pascal's 'case' statement [1]
or like C's 'switch' statement?

Personally I heartily detest the C 'switch'. You need to put
'break' all over the place. I never use the fall-through trick.
It's a fast-track to lurking bugs.

I am willing to keep an open mind on 'case'. I don't
really think Lua needs it, but the workarounds are not pretty.

[1] I was a Pascal user from Wirth's first report until one
needed p2c to run it under Linux. Now that Free Pascal
has reached stability, I use Pacal again. Think of it as
C with Lua readability. One can write Lua API code in
Pascal and call Lua code from Pascal.

Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Marc Balmer


> Am 28.01.2018 um 10:36 schrieb Dirk Laurie <[hidden email]>:
>
> 2018-01-28 10:52 GMT+02:00 KHMan <[hidden email]>:
>
>> I'd like a native switch. :-) Please, pretty pretty please :-)
>
> So which do you want? Like Pascal's 'case' statement [1]
> or like C's 'switch' statement?
>
> Personally I heartily detest the C 'switch'. You need to put
> 'break' all over the place. I never use the fall-through trick.
> It's a fast-track to lurking bugs.

Have you ever heard of duff's device?

>
> I am willing to keep an open mind on 'case'. I don't
> really think Lua needs it, but the workarounds are not pretty.

I usually create a table of functions and use the value I would use
in a C switch as the index.

That not only works well, but structures the code nicely and in
practive the function calling overhead is small.

>
> [1] I was a Pascal user from Wirth's first report until one
> needed p2c to run it under Linux. Now that Free Pascal
> has reached stability, I use Pacal again. Think of it as
> C with Lua readability. One can write Lua API code in
> Pascal and call Lua code from Pascal.
>


Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Tony Papadimitriou
In reply to this post by Vadi
I second that (but I think this is more of a community responsibility than a language design issue).
 
The only thing I would certainly add to Lua is a `yield` keyword to complement `return` similar to Python’s way.
 
The current method (or hack) of implementing co-routines is unnecessarily verbose and often resulting in hard to understand code.
 
From: [hidden email]
 
I'd like to see Lua's tooling ecosystem improved. As 2017 showed, the tooling a language has on offer is just as important as the language itself.
Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Francisco Olarte
On Sun, Jan 28, 2018 at 1:09 PM, Tony Papadimitriou <[hidden email]> wrote:
...
> The only thing I would certainly add to Lua is a `yield` keyword to
> complement `return` similar to Python’s way.
>
> The current method (or hack) of implementing co-routines is unnecessarily
> verbose and often resulting in hard to understand code.

How do you think this will improve? One of the reasons I'm currently
using lua is for it's coroutine support. I've used yield in python,
great for one liners not so for real world stuff ( my yields are
buried deep in the libraries I use to linearize event loops to
coroutines, I looked at python and it didn't have anything aproaching
real coroutines ( except for stackless ), and I'm still trying to
understand how to use those fancy "async" thingies they have come up
with.

In lua? coroutines are what they have been in nearly every other
system I've used, same functions as packages I've used in C, C++,
pascal and even assembler ( 8 bit one ). Nothing especial to be done
in any function used in a coroutine heavy program, just a couple
function calls.

Francisco Olarte.

Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Paige DePol
In reply to this post by Dirk Laurie-2
Dirk Laurie <[hidden email]> wrote:

> 2018-01-28 10:52 GMT+02:00 KHMan <[hidden email]>:
>
>> I'd like a native switch. :-) Please, pretty pretty please :-)
>
> So which do you want? Like Pascal's 'case' statement [1]
> or like C's 'switch' statement?
>
> Personally I heartily detest the C 'switch'. You need to put
> 'break' all over the place. I never use the fall-through trick.
> It's a fast-track to lurking bugs.

This is why my patch offers both options, when you declare the switch
you can choose to break or fallthrough as the default action.

The other issue with non-native switch cases that rely on functions is
the overhead of the function call as well, plus the lack of fallthrough
should that be required.

My patch does still require the overhead of a table lookup, however,
I can't really see any way around that requirement as the case values
have to be stored in some sort of lookup table.

I think another issue with switch/case in Lua is that vanilla Lua has no
facility for const values that aren't just table lookups or variables,
neither of which can be used as case values for a switch statement... so
you're left with coding potential "magic numbers" as case values, which
isn't good... and is also a limitation present in my patch as well.

For Lua++ I have a pretty robust preprocessor along with an additional
patch which allows for the declaration of consts, enums, macros, and
even basic inline functions. This patch and my switch/case patch work
quite well together at eliminating magic numbers.

One thing I have figured out and will be implementing is the ability for
macros to combine tokens and parameters that can then be fed back through
the parser. Right now my macros are essentially just recorded token streams
with parameters that can be replaced, but new tokens can not yet be formed
and re-parsed as part of the macro stream.

~Paige


Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Paige DePol
In reply to this post by KHMan
KHMan <[hidden email]> wrote:

> These days I like "no surprises" and being able to clearly express things
> in code. After all, Lua is not competing in the JIT pedal-to-the-metal
> race, and neither is it going super-linguistic-expressive as in Perl 5.
> I'm not so gung-ho on "minimal" these days.
>
> So given a choice between "minimal is elegant" and "clear expression of
> ideas", guess what I would choose.

One of the goals I am trying to achieve with Lua++ is to keep the runtime
portion of the code as minimal and as fast as possible. Currently, I have
managed to achieve only a 15% increase in the runtime size, however, the
size of the parser has ballooned up by 233%!

I would like to try to keep a parser-less Lua++ binary size within the
footprint of vanilla Lua as much as I possibly can. A lot of what I have
added to the language happens during parsing, so I don't see the expanded
parser size as a bad thing, if the end goal is to improve performance of
the runtime significantly.

~Paige


Reply | Threaded
Open this post in threaded view
|

Re: Has Lua reached perfection?

Soni "They/Them" L.
In reply to this post by Paige DePol


On 2018-01-28 11:48 AM, Paige DePol wrote:

> Dirk Laurie <[hidden email]> wrote:
>
>> 2018-01-28 10:52 GMT+02:00 KHMan <[hidden email]>:
>>
>>> I'd like a native switch. :-) Please, pretty pretty please :-)
>> So which do you want? Like Pascal's 'case' statement [1]
>> or like C's 'switch' statement?
>>
>> Personally I heartily detest the C 'switch'. You need to put
>> 'break' all over the place. I never use the fall-through trick.
>> It's a fast-track to lurking bugs.
> This is why my patch offers both options, when you declare the switch
> you can choose to break or fallthrough as the default action.
>
> The other issue with non-native switch cases that rely on functions is
> the overhead of the function call as well, plus the lack of fallthrough
> should that be required.
>
> My patch does still require the overhead of a table lookup, however,
> I can't really see any way around that requirement as the case values
> have to be stored in some sort of lookup table.
>
> I think another issue with switch/case in Lua is that vanilla Lua has no
> facility for const values that aren't just table lookups or variables,
> neither of which can be used as case values for a switch statement... so
> you're left with coding potential "magic numbers" as case values, which
> isn't good... and is also a limitation present in my patch as well.
>
> For Lua++ I have a pretty robust preprocessor along with an additional
> patch which allows for the declaration of consts, enums, macros, and
> even basic inline functions. This patch and my switch/case patch work
> quite well together at eliminating magic numbers.
>
> One thing I have figured out and will be implementing is the ability for
> macros to combine tokens and parameters that can then be fed back through
> the parser. Right now my macros are essentially just recorded token streams
> with parameters that can be replaced, but new tokens can not yet be formed
> and re-parsed as part of the macro stream.
>
> ~Paige
>
>

I want a switch where you can use math.random() in switch cases and it
lazy-evaluates them and just works.

--
Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.


123