[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Fengari: Why we rewrote Lua in JS
- From: Hisham <h@...>
- Date: Wed, 26 Jul 2017 20:07:24 -0300
On 26 July 2017 at 19:42, Jakub Jirutka <jakub@jirutka.cz> wrote:
> I know about LuLPeg, but I’ve used LPeg just as an example. I’m interesting
> about general support of Lua/C modules. Is it currently somehow possible?
The motivations one uses Lua/C modules are either for extra speed, or
for interfacing with existing libraries. For the first motivation,
going through Emscripten and then the Lua/C API and run the whole
thing on top of JS would probably be slower than writing a module
directly in Lua; the approach for critical speed would be to write
something in JavaScript instead and go through Fengari's Lua/JS API.
For the second motivation, I suppose most existing libraries one would
want to interact with in a browser would be existing JS libraries, and
not C libraries. For a lot of C libraries, it wouldn't make sense to
port them into the browser, but for those that can be compiled into JS
libraries via Emscripten, I suppose one can bind them to Lua via the
Lua/JS API, but the binding module needs to be rewritten (from C to
JS).
The linked article mentions that the approach of compiling Lua C code
into the browser via Emscripten makes you end up with two garbage
collectors. For this reason, simply building both a C library and its
Lua/C binding with Emscripten and expecting them to work with Fengari
doesn't sound feasible. But the approach I described above, in which
the C library is compiled into JS and a Lua/JS binding is
custom-written for it, does (unless I'm missing something—the Fengari
authors will surely correct me if that's the case).
-- Hisham
> Jakub
>
> On 27. Jul 2017, at 0:23, Charles Heywood <vandor2012@gmail.com> wrote:
>
> I'm not sure about using Emscripten, but there is LuLPeg which is mostly
> compatible with LPeg - enough that MoonScript can be compiled with it.
>
> On Wed, Jul 26, 2017 at 1:10 PM Jakub Jirutka <jakub@jirutka.cz> wrote:
>>
>> Hi Benoit,
>>
>> Fengari is really awesome project, thank you and daurnimator very much for
>> it!
>>
>> I have one question. How about Lua/C modules? Is it currently possible to
>> compile e.g. LPeg into JS using Emscripten and use with Fengari?
>>
>> Jakub
>>
>> On 26. Jul 2017, at 14:34, Benoit Giannangeli <giann008@gmail.com> wrote:
>>
>> Hi there,
>>
>> Fengari is a project me and daurnimator have been working on the past
>> months which aims to bring Lua to the browser.
>>
>> Here is the introductory article for it:
>> http://lua.space/webdev/why-we-rewrote-lua-in-js
>>
>> --
>> Benoit Giannangeli
>>
>> https://github.com/giann
>>
>>
> --
> --
> Ryan <vandor2012@gmail.com>
> Software Developer / System Administrator
> https://hashbang.sh
>
>