
Show HN: Glua, a Full-Featured Lua VM for Nodejs and the Browser - fiatjaf
https://github.com/fiatjaf/glua
======
giann
This suffers from the same issue as
[https://daurnimator.github.io/lua.vm.js/lua.vm.js.html](https://daurnimator.github.io/lua.vm.js/lua.vm.js.html)
and others: there is 2 GC working side by side and it's bound to lead to never
freed objects.

~~~
CryZe
This isn't just because of 2 GC's working side by side. This happens to any
memory that isn't a JavaScript object. So every asm.js and WebAssembly library
is affected by the same issue, even if it doesn't have its own garbage
collector. With there no way of hooking into JavaScript's Garbage Collector,
you can't free your native handles when the JavaScript object wrapper gets
collected, so you get leaks all over the place. So the only option is to
manually manage your JavaScript objects in your JavaScript code by calling
their "destructors", which kind of defeats the whole purpose of having a
Garbage Collector. With WebAssembly on the rise, I hope people become more
aware of this issue and implement proper GC Hooks for JavaScript.

------
NiLSPACE
There is also one in WebAssembly:
[https://github.com/vvanders/wasm_lua](https://github.com/vvanders/wasm_lua)

------
daliwali
This seems to be a thin wrapper for the actual Lua VM implemented in Go:
[https://github.com/yuin/gopher-lua](https://github.com/yuin/gopher-lua)

~~~
swah
So Lua to Go, and Go to Javascript. I wonder how well that works..

~~~
russellsprouts
Well, the original Lua VM is written in C, so it's more like C to Go to
JavaScript.

~~~
shinymark
This description made me chuckle. It reads to me like someone was
intentionally concocting the most complex and least efficient method of
programming a computer.

I come from a game development background and my view on things is admittedly
affected by having to deal with issues related to real time efficiency.

------
etiene
Really cool! Reminds me of another awesome Lua->JS project called starlight:
[http://starlight.paulcuth.me.uk](http://starlight.paulcuth.me.uk)

------
jlebrech
I'd love to see a framework that treats client/server code as Ring 4 and Ring
5. you just have one codebase for client and server and it's up to the
programmer to decide what it can trust the client side to compute.

~~~
warpech
What's the context for "Ring 4" and "Ring 5"? Are these some multitier
architecture terms?

~~~
warpech
I suppose it has to do with
[https://en.wikipedia.org/wiki/Protection_ring](https://en.wikipedia.org/wiki/Protection_ring)

~~~
oblio
I find it kind of a funny that over-engineering lost, same as in OSI versus
TCP/IP. 7 layers vs 4, 4 rings available vs 2 rings actually used.

~~~
Elves
Funny, but the lesson is never learnt until late in life.

To paraphrase Aristotle: "Only achieve that which is sufficient".

Ironic that Lua was designed to be as simple as possible and no simpler (was
that Einstein?) and then it gets layered (laid, layed?) over ponderous systems
that it really should be replacing.

And finally, complying with the rule of three and layering (pun) upon
dijkstra's proposition: "layers should be considered evil".

Personally, in software, everything should be compiled to machine code if not
already written in it, optimised to remove function calls and loops and at run
time ensure that all data fetches control movements use the nearest memory.

------
make3
Has this been tried with emscripten and regular Lua?

~~~
shakna
Yes [0]

[0]
[https://news.ycombinator.com/item?id=5794772](https://news.ycombinator.com/item?id=5794772)
| [http://mozakai.blogspot.com.au/2013/05/lua-in-javascript-
run...](http://mozakai.blogspot.com.au/2013/05/lua-in-javascript-running-vm-
in-vm.html)

