Re: Turning Lua into C++ (was: alleviate the load of the GC)

  • From: Mike Pall <mikelj-1509@xxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 2 Sep 2015 17:38:53 +0200

Tudor Bosman wrote:

I don't think anyone wants to turn Lua into C++; they want to turn Lua into
Javascript :)

But Javascript doesn't have an overridable assignment operator.
Oh ... wait ...

I'd add only one thing -- differentiating between initialization and
assignment. Which means that "a = 2" should error if a can't be found in
scope rather than creating a new global variable; I'd suggest "global a =
2" for that.

I've previously proposed a way to smoothly transition away from
global-by-default and make better use of the 'global' scope:

//www.freelists.org/post/luajit/LuaJITfriendly-API-and-data-structure-design,5

There are other language warts (nil === undefined means that typos are
difficult to catch;

Partially solved by the above.

varargs and select() are ugly;

Agreed. But vararg handling is ugly in most other languages, too.
Find out what's bad, why it's bad and how to solve it. Then
propose a change.

even with the __eq
metamethod, you still can't use tables as table keys the way you'd want to;

Key identity has its uses (and it's simple). Key equality is a
different beast. Mixing both approaches in a core data structure
is difficult and may cause overhead in unexpected ways, unless one
is very careful.

I'm all for extending the standard library, though; you can do much worse
than imitating the Python standard library and cherry-picking good stuff
from Penlight.

The question is: where's the boundary between the core and the
library? This distinction has long lost its utility.

What's more important is the old issue with cohesion vs. coupling.
Especially for the core. You really, really don't want to go down
the path that e.g. Node.js has gone. (*)

Feel free to open issues for the above.


(*) There's my personal war story of (naively) attempting to
change the CSS of Bootstrap in the source and regenerating it: OK,
so I need to install npm. Simple, huh? Then I find out it doesn't
work because of some distro idiocy, fix it up, start it and wait
ages for the download ... only to find 300 Megabytes (!) of silly
dependencies evenly spread out between the system directory, my
home directory and the Bootstrap directory. Of course, it didn't
work out-of-the-box, either ... Anyway, you get my point.

--Mike

Other related posts: