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.
v8 is an obvious open source implementation, because it's packaged separately (and used in node.js), but its API is C++ and relatively complex. For a lot of applications, it's overkill.
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).
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.
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.
C/C++ is great for low-level and performance sensitive code, but at the cost of ease of use and a potentially slow compile-test-debug cycle. For instance, in a game engine, the Physics and graphics rendering are usually done in C++. But for the rest, you get more bang-for-your-buck with a higher-level language.
Mindshare
Other high-level languages can do the same thing. In fact, Lua and Guile were designed for this exact purpose. But Javascript works well and Javascript programmers are much easier to find. And if, say, you want your users to start writing plug-ins for your application, you'll have more success with a language they're more likely to know.
Performance
Thanks to the great Javascript JIT compilers, you'll probably take a smaller performance hit than with other high-level languages you might choose.
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.
Lua is nice, no doubt about it, but it isn't better in every aspect.
Libraries count. Developer mindshare counts.
It's the same rationale as having so many modern languages that compile to Java. Java itself may not be that great, but man, there sure are a lot of useful libraries for it. Same with Javascript.
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.
Why does the readme say "liberal license" when the license file is in fact "MIT license" Why hide the fact that it is under the MIT license? Why is there a folder called licenses and why does it contain an unfilled in license (Copyright (c) <year> <copyright holders>)?
MIT is considered by most to be a "liberal license", and phrasing it that way makes for better marketing than stating the exact type of license in a "Features" section.
The additional license is for another project (murmurhash2).
If this is embedded in C++ I feel like you would be manipulating objects in the JavaScript scripts. JavaScript has OOP bolted on and it is not nearly as nice as Lua or similar alternatives. Why would a developer embed a JavaScript engine compared to something already existing?
I wouldn't describe JavaScript's OOP as bolted on. It's just a different kind of OOP - prototype based rather than class based. You could argue that Lua is more "bolted on OOP" since there are quite a few different libraries that build OOP for it.
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 ideal, so I'm quite happy with the prospects of using it.
The point is not, if a language is superior or has the better "OOP" quality. People tend to use what they know and JS is currently one of the "in" languages.
What is the benefit, if your scripting language is the price-winner from Harvard Business school or something else, but nobody knows it and wants to learn it. So many (good) languages have passed away, nearly unnoticed.
One of the big attractions of Java and JavaScript: The syntax. The C/C++ like syntax was and is just in fashion ... even when it is criticized by many. But everybody knows it and everybody (it seems) like it.
[+] [-] chubot|12 years ago|reply
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 implementation, because it's packaged separately (and used in node.js), but its API is C++ and relatively complex. For a lot of applications, it's overkill.
[+] [-] saurik|12 years ago|reply
[+] [-] deckiedan|12 years ago|reply
[+] [-] cmicali|12 years ago|reply
[+] [-] PythonicAlpha|12 years ago|reply
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?
[+] [-] brassybadger|12 years ago|reply
[+] [-] bichiliad|12 years ago|reply
[+] [-] Pitarou|12 years ago|reply
C/C++ is great for low-level and performance sensitive code, but at the cost of ease of use and a potentially slow compile-test-debug cycle. For instance, in a game engine, the Physics and graphics rendering are usually done in C++. But for the rest, you get more bang-for-your-buck with a higher-level language.
Mindshare
Other high-level languages can do the same thing. In fact, Lua and Guile were designed for this exact purpose. But Javascript works well and Javascript programmers are much easier to find. And if, say, you want your users to start writing plug-ins for your application, you'll have more success with a language they're more likely to know.
Performance
Thanks to the great Javascript JIT compilers, you'll probably take a smaller performance hit than with other high-level languages you might choose.
[+] [-] jffry|12 years ago|reply
[+] [-] swah|12 years ago|reply
[+] [-] sitkack|12 years ago|reply
[+] [-] skrebbel|12 years ago|reply
[+] [-] brassybadger|12 years ago|reply
[+] [-] igl|12 years ago|reply
[+] [-] Turing_Machine|12 years ago|reply
Libraries count. Developer mindshare counts.
It's the same rationale as having so many modern languages that compile to Java. Java itself may not be that great, but man, there sure are a lot of useful libraries for it. Same with Javascript.
[+] [-] angersock|12 years ago|reply
I'm quite pleased to see a compact and reasonable C interface for a JS engine--v8 can go eat a bag of rocks.
[+] [-] eropple|12 years ago|reply
[+] [-] icefox|12 years ago|reply
[+] [-] drgath|12 years ago|reply
The additional license is for another project (murmurhash2).
[+] [-] bsilvereagle|12 years ago|reply
[+] [-] yetfeo|12 years ago|reply
[+] [-] hajile|12 years ago|reply
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 ideal, so I'm quite happy with the prospects of using it.
[+] [-] PythonicAlpha|12 years ago|reply
What is the benefit, if your scripting language is the price-winner from Harvard Business school or something else, but nobody knows it and wants to learn it. So many (good) languages have passed away, nearly unnoticed.
One of the big attractions of Java and JavaScript: The syntax. The C/C++ like syntax was and is just in fashion ... even when it is criticized by many. But everybody knows it and everybody (it seems) like it.
[+] [-] rmrfrmrf|12 years ago|reply
[+] [-] PaulFreund|12 years ago|reply
[+] [-] NAFV_P|12 years ago|reply
[0] http://www.salon.com/1998/10/13/feature_269/
[+] [-] edwinyzh|12 years ago|reply
[+] [-] Doctor_Fegg|12 years ago|reply
[+] [-] dottrap|12 years ago|reply
[+] [-] userbinator|12 years ago|reply
http://code.google.com/p/tiny-js/ (~2kLOC)
http://code.google.com/p/quad-wheel/