

Developing a Lua VM in JavaScript - inm
http://skillsmatter.com/podcast/ajax-ria/developing-a-lua-vm-in-javascript

======
jrogers65
Layer 1 - assembly to get the system to boot and communicate with hardware.

Layer 2 - C to schedule tasks, manage memory, provide filesystem support.

Layer 3 - C/C++ to provide a graphical user interface framework.

Layer 4 - C/C++ to render web pages.

Layer 6 - C/C++ to implement a Javascript VM.

Layer 7 - Javascript to implement a Lua interpreter.

Layer 8 - Game engine written in Lua.

Layer 9 - Game specific code written in Lua.

I wonder how much bang per Mhz this setup provides.

~~~
azakai
These layers aren't literal, though. For example, the JS VM can generate
native machine code that can run just as fast as the assembly in layer 1. It's
literally in the same language. (It won't be as fast always, of course, but in
some cases it will.)

Also, there is no reason Lua in JS could not run at similar speed to JS, if
the translation from Lua to JS is efficient enough. Whether that is possible
depends on how close Lua and JS semantics are. That could also be at least
partially achieved by using a Lua VM that has a JIT, and implementing a JIT
backend that emits JS. Such an approach could be quite fast.

~~~
otibom
There's always emscriptem

<https://github.com/kripken/emscripten>

------
cmwelsh
I would be interested to see the author's thoughts on Lua.js, translating Lua
into semi-equivalent JavaScript:

<https://github.com/mherkender/lua.js>

Or is this more of an educational than practical workshop?

------
EastLondonCoder
Disclaimer, I work on the project. Not so much the vm as the game engine part.
The game engine is a Lua api but implemented in the host language. In this
case js but we have a obj-c iOS implementation as well. For our use case the
bottleneck is not the Lua interpreter but graphics rendering. The system is
currently live and you can see it working if you go to www.jackpotjoy.com with
an iPad user agent. If you have any specific questions I'd be happy to answer
them.

------
corysama
Similar project that converts specifically the LuaJIT bytecode to JS

<https://github.com/creationix/brozula>

