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)
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