Re:Duktape: an embeddable JavaScript engine
by mempko on Thursday December 04, 2014 @03:08PM
(#8701330)
seems the C interface is modelled after Lua. Is there any inspiration there?
[ Parent
| on HN ]
Re:Duktape: an embeddable JavaScript engine
by bodyfour on Thursday December 04, 2014 @03:42PM
(#8701495)
Yes, very much so. If you've embedded lua before it's very easy to do the same with duktape. A few conventions are different -- for instance stack indicies are 0-based instead of 1-based (mirroring the difference in JS vs Lua) and some of the strategies for interfacing with native-code objects is different (JS prototypes aren't exact analogues to Lua metatables, etc)
Re:Duktape: an embeddable JavaScript engine
by macournoyer on Thursday December 04, 2014 @03:14PM
(#8701365)
Pretty sure. The instruction layout is also inspired by Lua: https://github.com/svaarala/duktape/blob/master/src/duk_js_b...
Here's Lua: https://github.com/lua/lua/blob/master/src/lopcodes.h#L13-L2...
Re:Duktape: an embeddable JavaScript engine
by svaarala on Thursday December 04, 2014 @08:07PM
(#8702616)
Absolutely, the original motivation was to have a Lua-like implementation for Javascript.
Re:Duktape: an embeddable JavaScript engine
by creationix on Friday December 05, 2014 @10:57AM
(#8705105)
And thank you! I've wanted this for years, but haven't yet gotten up the courage to actually tackle it. ES5.1 is big and ES6 is massive.
Re:Duktape: an embeddable JavaScript engine
by Aldo_MX on Friday December 05, 2014 @01:38PM
(#8706023)
I really want to applaud your effort. Are you accepting donations?
Re:Duktape: an embeddable JavaScript engine
by svaarala on Saturday December 06, 2014 @05:07AM
(#8708854)
Thanks! At the moment no, but send me an e-mail if you use Duktape somewhere :)
Re:Duktape: an embeddable JavaScript engine
by weeksie on Thursday December 04, 2014 @03:15PM
(#8701371)
I immediately thought of Lua as well. A fine choice, Lua has the best C FFI I've ever worked with. I love everything about this.
Re:Duktape: an embeddable JavaScript engine
by cheez on Thursday December 04, 2014 @03:23PM
(#8701418)
Does Lua work well with multiple threads?
Re:Duktape: an embeddable JavaScript engine
by haberman on Thursday December 04, 2014 @04:06PM
(#8701634)
Lua has full support for creating multiple interpreter instances (ie. there are no global variables, and it's totally re-entrant). But interpreter instances are not thread-safe. So the way to support multiple threads is to have completely independent interpreters running in different threads.
Re:Duktape: an embeddable JavaScript engine
by sharkbot on Thursday December 04, 2014 @06:54PM
(#8702421)
You can make a Lua interpreter thread safe by adding a GIL. There is implicit support for this in the code: the interpreter invokes lua_lock/lua_unlock at the proper places, the default Lua implementation just has them NOP'd out. Adding the thread primitives is up to you, however.
Re:Duktape: an embeddable JavaScript engine
by chii on Thursday December 04, 2014 @11:00PM
(#8702958)
when you have multiple threads, isn't the idea to share data between threads? I haven't really worked with embedded lua before - does lua help with that?
Re:Duktape: an embeddable JavaScript engine
by cheez on Thursday December 04, 2014 @04:52PM
(#8701905)
Thanks. Any idea as to the footprint of these instances?
Re:Duktape: an embeddable JavaScript engine
by mempko on Thursday December 04, 2014 @05:27PM
(#8702101)
I use this approach in Fire★ (http://www.firestr.com). Lua vm instances are tiny. There is a reason lua is used even in systems like nintendo DS