lua-users home
lua-l archive

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


The reason I started (but never finished) brozula was to play around writing a luajit byte interpreter.  But there is no technical reason that a full lua runtime can't be implemented in browser _javascript_.

While working on brozula, I tried a few techniques and I'm confident that a full-featured lua runtime complete with coroutines is not only possible, but will be fast enough for most uses.  (The trick to get good speed is to JIT _javascript_ code on the fly and let the browser's JIT engine chew on that.)  I was able to get over 3 million runs per second of the following lua program:

local data = {"This", "is", "a", "stream?"}
local index = 1
 
print("before")
while data[index] do
print(data[index])
index = index + 1
end
print("after")
The best DOM interface I've come up with so far is allowing lua to call JS functions directly and doing a best effort to translate.  For example, I have to store references to how a function was last looked up (to know the "this" value in js)

I was able to port my dombuilder.js library to lua and run it mostly successfully. https://github.com/creationix/brozula/blob/master/widgets/dombuilder.lua

The really time consuming part is finishing the implementation and building proper dev tools.  The built-in tools are _javascript_-centric and not much good for debugging lua code.  Either the abstraction is leaky (debugging at the JS level) or someone needs to write new dev tools that work at the lua level.  This can be done, but it's more work than I am able to do without some form of sponsorship.

-Tim Caswell



On Wed, Jan 2, 2013 at 2:16 PM, Javier Guerra Giraldez <javier@guerrag.com> wrote:
On Wed, Jan 2, 2013 at 1:05 PM, Tim Mensch <tim-lua-l@bitgems.com> wrote:
> In my opinion, HTML5 is the only cross-platform GUI API that is even halfway
> decent on all platforms. Qt is the next contender

depressing but quite true.  that's why a Lua-DOM bridge can be so
useful regardless of how widely deployed any underlying technology is.
 Extra points if it runs 'real Lua' (or LuaJIT) and doesn't involve
JS.

--
Javier