News for hackers. Stuff that matters.
Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil... by fbcocq on Friday November 26, 2010 @12:52AM (#1941730)
It breaks for input as simple as "for x = 1,10 do print(x) end". It's a shame I can't use Lua for browser scripting instead of JS.
Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil... by ay on Friday November 26, 2010 @04:59AM (#1942036)
http://code.matthewwild.co.uk/ljs/

This is Lua's bytecode interpreter in pure javascript.

When I tried it a few weeks ago it lacked some bytecodes - but when I bolted the code to interpret them on I was able to run some compiled Lua code. Maybe you find it interesting.

Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil... by azakai on Friday November 26, 2010 @12:53PM (#1942837)
I put up the demo after seeing that some simple stuff worked, like

x = 10 print(x+25)

etc., but I didn't test the compiled interpreter a lot more. Probably the statement you tried doesn't work because some stdlib function needs to be implemented. If people are really interested in getting this to work, we can probably figure it out, it will take some effort though.

Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil... by silentbicycle on Friday November 26, 2010 @01:02AM (#1941738)
I tried "for k,v in pairs(_G) do print("->", k,v) end" (I was curious what is and isn't sandboxed) and it just gave me an error.
Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil... by pufuwozu on Friday November 26, 2010 @01:15AM (#1941748)
There's no sandbox. This is the Lua virtual machine, compiled to LLVM bitcode with llvm-gcc/clang and then compiled to JavaScript with emscripten.

It's all client-side.

Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil... by nl on Friday November 26, 2010 @06:18AM (#1942151)
I don't think (s)he was implying it was using a plugin or anything.

An occasional feature of other languages-in-Javascript is some kind of sandboxing for security - eg the Valija Javascript subset that runs in the Caja sandbox (which in turn is implemented in Javascript): http://code.google.com/p/google-caja/wiki/SubsetRelationship...

Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil... by silentbicycle on Friday November 26, 2010 @09:35AM (#1942446)
Yes. Rather, I meant, which libraries were available. I figured that it'd at least have the core stdlib; that was just my first step exploring. It's a bad sign that the first statement I tried didn't work, though.