Live data from Hacker News

Duktape: an embeddable JavaScript engine

duktape.org

31–40 of 44 posts

Re: Duktape: an embeddable JavaScript engine

#31
post #24
post #13

Earlier quoted context omitted.

Qt already uses JS in the form of QtQuick with quite a bit of success. JS using a prototypal system means that it can emulate almost any other OOP trivially (while the reverse is much harder). I prefer embedding lisp, but I realize that most developers don't know that language family (which mostly defeats the point of an embedded scripting language). JS seems to be the closest widely-known languages have come to this…

Do you happen to know an embeddable Lisp that can easily bind to C++ objects (rather like AngelScript or luabind)? I too would mostly rather a Lisp, but doing all the plumbing sucks .

If Lua's semantics are acceptable, you can make a loader that runs your Lisp in Lua. This is probably less effort than it sounds like. Moonscript is a decent example of a mostly expression-oriented language as a Lua loader, so it should be simple to make it read a Lisp instead.

Re: Duktape: an embeddable JavaScript engine

#32
post #7
post #6

This looks really cool. I always wanted a small embeddable JS engine with a C interface. And it looks like you modelled the C API after the Lua C API? That is what I wanted as well. Here are some related projects I saved links to. I think there were a few others. http://code.google.com/p/tiny-js/ http://adaptive-enterprises.com/~d/software/see/ http://sourceforge.net/projects/njs/ v8 is an obvious open source impleme…

JavaScriptCore (the engine from WebKit) also has a very simple C interface (and I've seen it embedded by people as a static library without serious difficulty).

It's also got a really expressive and transparent Objective-C interface, if you happen to be writing iOS/OS X apps.

There's a nice overview here: http://blog.bignerdranch.com/3784-javascriptcore-and-ios-7/

Re: Duktape: an embeddable JavaScript engine

#33
post #19

Bloody wonderful! I'm quite pleased to see a compact and reasonable C interface for a JS engine--v8 can go eat a bag of rocks.

Agreed. I really like the engineering behind V8, but the interface is such a pain to work with. I actually switched my game from C++ to the JVM so I could use Rhino.

> I actually switched my game from C++ to the JVM so I could use Rhino.

Would you mind elaborating a bit what makes v8 tedious to work with?

Re: Duktape: an embeddable JavaScript engine

#34

Is size the main selling point? 4 years ago or so, I integrated SpiderMonkey into a C++ program with relative ease; it has an easy to understand C API and no dependencies.

I'd say the combination of being small, easily embeddable and having a liberal license make it attractive.

Re: Duktape: an embeddable JavaScript engine

#35

Is size the main selling point? 4 years ago or so, I integrated SpiderMonkey into a C++ program with relative ease; it has an easy to understand C API and no dependencies.

I'd say the combination of being small, easily embeddable and having a liberal license make it attractive.

SpiderMonkey is easily embeddable like I said. The Mozilla Public License is less liberal than BSD/MIT, but for most practical purposes it's the same.

It's not tiny though (for an underbelly feeling, I found an old binary Windows build online of about 800kb).

Looking at the current SpiderMonkey docs, things look like they've only improved. Back in the day, I just took SpiderMonkey from the "js" subdirectory of the Firefox repo. They split it off and documented build steps since then.

I'm not saying there's no space for contenders here, but don't underestimate the quality of what's out there already. SpiderMonkey really is remarkably easy to interface with.

Re: Duktape: an embeddable JavaScript engine

#36

Earlier quoted context omitted.

I'd say the combination of being small, easily embeddable and having a liberal license make it attractive.

SpiderMonkey is easily embeddable like I said. The Mozilla Public License is less liberal than BSD/MIT, but for most practical purposes it's the same. It's not tiny though (for an underbelly feeling, I found an old binary Windows build online of about 800kb). Looking at the current SpiderMonkey docs, things look like they've only improved. Back in the day, I just took SpiderMonkey from the "js" subdirectory of the Fi…

After a quick glance it also seems that newer versions of SpiderMonkey only offer a C++ API, so you can't embed it anymore into C apps without some glue code. I checked out jsapi.h in SpiderMonkey24 - maybe some trick is needed to use SM from C?

Re: Duktape: an embeddable JavaScript engine

#37

The idea is good, I remember that other projects like Avidemux integrate QtScript or Spidermonkey for scripting. Has anybody experience, how the integration overhead is? Looks as this could be integrated very simply. The problem is, that it is in alpha stage and how stable and complete is it currently?

Integration is very easy (check out the examples in their git repo), but this is still alpha quality software - there are known limitations, e.g. the one I ran into is that a large JS expression involving function calls might make Duktape run out of bytecode registers.

Re: Duktape: an embeddable JavaScript engine

#40

Awesome. This is exactly what I wanted. Hopefully now I can make a standalone statically linked version jslint, lessjs, etc, so I can use them as part of my workflow without needing the whole flipping Node stack installed...

This would be amazing.. svgo and less are the only two things between us and a node-free environment - would love to not have to install/deal with npm.
Post reply on HN