[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: What would you remove from Lua - a case of regression?
- From: Gé Weijers <ge@...>
- Date: Sun, 25 Nov 2018 15:28:31 -0800
> On Nov 25, 2018, at 09:40, Dibyendu Majumdar <firstname.lastname@example.org> wrote:
> So I am thinking of experimenting with a minified Lua - regress back
> to 5.1 but on top of that:
> * Eliminate metamethods except for __gc.
> * No more coroutines
> So back to only one number type. As you can imagine this would mean
> add can simply be:
> a + b
You would still have to do a type check before adding the values,
because you may be adding a table to nil in stead of two numbers. Why
not call a runtime system routine that implements the full add
functionality if the type check fails?
> Now, I do not know how often people implement operator overloading -
> but given some languages do not have this feature it may not be a big
I have used it in a module implementing date and calendar arithmetic,
and in some other cases.
> I personally can do without coroutines too, I am not sure how widely
> they are used; but the trade off is that we eliminate a bunch of
> complexity from mini Lua.
Coroutines are very useful in event driven programs, I use them all
the time to implement protocols/state machines. You can use callbacks
more readable, the code is not littered with lambdas.
If removing complexity from the language adds complexity to the
programs written in the language you may be going down the wrong path.
An implementation of “mini Lua” would not be all that useful to me,
Lua 5.x has just about the right compromise of simplicity and
expressive power for me, and I can add any missing pieces through the
C interface. I’m currently using Lua and some custom C code for
in-house test scripts that interface to prototype hardware, and it’s
using about 1% of 1 CPU, so a JIT compiler would not be particularly
useful to have in this case.