lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 06/11/2011 16:03, Joshua Ballanco wrote:
Have you looked at Emscripten ( There's an
example of Lua running in the browser here:

If I understood correctly each project (from their description), lua2js (official name?) translates Lua code to JS code (a bit like what Xtend compiler does to Java, or lot of compilers in general do, using often C as target language), while Emscripten translated the C code of the Lua VM to JavaScript, interpreting Lua on the fly (would be like rewriting another JVM, to continue the analogy).

So, if I am not mistaken, Emscripten is able to run Lua code typed in the browser without assistance from a server, while lua2js would need to send the script to a server with a Python module to translate the code and send it back to the browser. Right? Both approaches are interesting. As I believe the Emscripten was generated (by LLVM?), it should have a complete support of Lua features, but need to run a heavy machinery, not necessarily optimized for its target language (C idioms/pattern/tricks used in the Lua code might not be optimal for JS) to run the scripts, while lua2js probably generate a lighter JS and this code can be heavily optimized by the browser's engine.

Two interesting approaches.

I recall a failed attempt, some years ago, to make Lua to run natively (or with a plugin) in browsers, but the modern approach of using JS as the assembly language of browsers is probably saner, now that we have HTML5 (canvas and other facilities).

By saner, I don't mean it is a good idea, just that we don't have a choice (no standard bytecode here), if we want high compatibility, and well, it becomes usage, given the recent progress in JS engine speed.

Philippe Lhoste
--  (near) Paris -- France
--  --  --  --  --  --  --  --  --  --  --  --  --  --