Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil...
by azakai on Thursday November 25, 2010 @10:15PM
(#1941553)
In principle it should be possible to get Rubinius to work with Emscripten - I'd be excited to see that happen. In fact it should work better than compiling a language's VM (which is what happens in the Lua demo).
But it will be hard to do without help from someone that knows Rubinius well (I don't).
Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil...
by pygy_ on Friday November 26, 2010 @06:09AM
(#1942136)
There is also a Lua frontend for the LLVM.
Lua code compiled to LLVM bytecode then to Javascript using Emscripten will most probably be faster than code interpreted on the fly in the browser, but I wonder by how much.
Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil...
by azakai on Friday November 26, 2010 @08:40PM
(#1943996)
Thanks for the feedback in the comments here!
I made a few fixes to Emscripten, and the code that was mentioned that doesn't work, should now work in the demo, for example |for x = 1,10 do print(x) end|.
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 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.
Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil...
by ajx on Friday November 26, 2010 @12:55AM
(#1941732)
another interpreted language running inside of an interpreted language... sweet. All we need now is to write a perl interpreter in Lua and then run it inside of the javascript Lua interpreter and we'll really see the scripts slow down to a crawl.
Re:Lua VM cross-compiled to JavaScript (1.4mb - takes a whil...
by draegtun on Monday December 06, 2010 @07:35AM
(#1974941)
I see its actually more than just thinking because he has a repo called "Io port to Javascript (node.js)" on github: https://github.com/stevedekorte/oia
Edit: Guess i just found it out :( http://code.google.com/p/emscripten/issues/detail?id=1
But it will be hard to do without help from someone that knows Rubinius well (I don't).
Lua code compiled to LLVM bytecode then to Javascript using Emscripten will most probably be faster than code interpreted on the fly in the browser, but I wonder by how much.
http://code.google.com/p/llvm-lua/
I made a few fixes to Emscripten, and the code that was mentioned that doesn't work, should now work in the demo, for example |for x = 1,10 do print(x) end|.
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.
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.
It's all client-side.
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...
(For those who don't know: Io is very powerful, but also very slow.)
ref: http://tech.groups.yahoo.com/group/iolanguage/message/12526