Re: LuaJIT and WebAssembly

  • From: Daurnimator <quae@xxxxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 18 Apr 2017 10:00:36 +1000

On 18 April 2017 at 03:29, Paul Kaletta <pk@xxxxxxxxxxxxxxx> wrote:

If LuaJIT's fast interpreter was ported to WASM, LuaJIT (the language) would
become available in the browser.

LuaJIT the language is just Lua 5.1 with bits borrowed from 5.2 and 5.3.
Plus the ffi (which don't make sense in a browser context).

For Lua in the browser, the way is paved with the (sometimes still
twitching) corpses of past projects.
  - https://github.com/daurnimator/lua.vm.js
  - http://moonshinejs.org/
  - http://starlight.paulcuth.me.uk/
  - https://github.com/logiceditor-com/lua5.1.js
  - https://github.com/creationix/brozula/
  - https://github.com/fiatjaf/glua
  - http://code.matthewwild.co.uk/ljs
  - https://github.com/mherkender/lua.js

Usually the biggest missing piece is exposing objects to the DOM, this
isn't possible while not reusing the JS garbage collector, which hence
requires using native JS objects to represent lua objects.
The newest project (which I've been helping with)
https://github.com/giann/fengari is a ;(manual) translation of the Lua
5.3 VM to javascript, while using native objects. This allows for
proper lua coroutine control flow, while also allowing full interop
with javascript (and hence the DOM). This means you can write a
library in lua and use it from JS, or in JS and use it from lua.

Other related posts: