Jint (Javascript interpreter) chosen for Moose.
We've chosen Jint as the Javascript interpreter for the Moose. What's this for?, you ask? Think of it this way.. you know how web browsers fetch web pages and show them, well, the Moose fetches web pages and speaks them. Web browsers like Internet Explorer, Mozilla Firefox, Safari, Opera, Chrome, etc.. all have Javascript abilities. So the Moose should too. And what will the Moose do with javascript?
It'll be different than what webpages do. (It's obviously not for making animated buttons or dynamic clickable links.)
Speaking a whole webpage would be horrible. They contain too much garbage. So the garbage has to be scraped away, leaving behind only the interesting text.
The Moose provides a lot of different ways to extract interesting stuff out of webpages. Easy ways and hard ways. Programming in Javascript to scrape a webpage is a hard way, but it gives total flexibility. So if there are web scraping tasks that the Easy ways can't handle, then Moose users can ask a Javascript programmer to write them a little script to do the scraping.
The reason I chose javascript, is exactly because it is a very common language, and it would be easy for a user to find a computer geek who knows javascript. I'm not expecting users to learn javascript themselves.
For quite a while, I thought that SpiderMonkey's javascript interpreter looked pretty good. But I think we ultimately chose Jint because it looks like we can fully embed it entirely into the Moose app, and not need a separate DLL... athough during the development phases, we will keep jint.dll and antlr.dll as loaded DLLs.
Our requirements of a Javascript interpreter are: Fully Unicode capable with a great string manipulation library. Embeddable in C# apps and able to call our C# objects and methods and .NET 4 system calls. A little multi-threading safety is also going to be useful. We don't need "just-in-time" compiling of our scripts, because they'll be quite brief.
Forgive this stuff below.. I pasted in an email my coder sent me, showing examples of Jint's String-Handling abilities. Until I find a better place to store this, I just pasted it in here. I'll move it to be better place in the future.
var c = "a b c".split(' '); // ["a","b","c"]
assert(3, c.length);
assert("a", c[0]);
assert("b", c[1]);
assert("c", c[2]);
var c = "a b c".split(/\s/); // ["a","b","c"]
assert(3, c.length);
assert("a", c[0]);
assert("b", c[1]);
assert("c", c[2]);
assert('bc', 'abcd'.substring(1, 3));
assert('cd', 'abcd'.substring(2));
assert('abcd', 'abcd'.substring());
assert(0, ''.length);
assert(1, 'a'.length);
assert(4, 'abcd'.length);
assert('a', 'abcd'[0]);
assert('d', 'abcd'[3]);
assert('2a11b', 1 + 1 + 'a' + 1 + 1 + 'b');
assert('©', '\xA9'); // Latin-1 Hex encoding
assert('©', '\251'); // Latin-1 Octal encoding
assert(65, 'ABC'.charCodeAt(0));
assert(66, 'ABC'.charCodeAt(1));
assert(67, 'ABC'.charCodeAt(2));
assert(NaN, 'ABC'.charCodeAt(3));
assert(55296, '\uD800\uDBFF'.charCodeAt(0));
assert(56319, '\uD800\uDBFF'.charCodeAt(1));
assert(1, '1' - '0');
assert('number', typeof ('1' - '0'));
var value = 12345;
value = String(12345);
assert('a2345', value.replace(/1/, 'a'));
assert(3, "canal".lastIndexOf("a"));
assert(1, "canal".lastIndexOf("a", 2));
assert(-1, "canal".lastIndexOf("a", 0));
assert(-1, "canal".lastIndexOf("x"));
assert("morning is upon u", "The morning is upon us.".slice(4, -2));
assert("morning is upon us.", "The morning is upon us.".slice(4));
assert(".", "The morning is upon us.".slice(-1));
assert(-1, 'a'.localeCompare('b'));
assert(1, 'b'.localeCompare('a'));
assert(0, 'a'.localeCompare('a'));
s1 = "Oh "
s2 = "what a beautiful "
s3 = "mornin'."
s4 = s1.concat(s2, s3);
assert("Oh what a beautiful mornin'.", s4);
assert(0, "Blue Whale".indexOf("Blue"));
assert(-1, "Blue Whale".indexOf("Blute"));
assert(5, "Blue Whale".indexOf("Whale", 0));
assert(5, "Blue Whale".indexOf("Whale", 5));
assert(9, "Blue Whale".indexOf("", 9));
assert(10, "Blue Whale".indexOf("", 10));
assert(10, "Blue Whale".indexOf("", 11));
// String.match tests
assert(true, "gib melson".match(/^\w+/) ? true : false );
assert(false, "#$$%#".match(/^\w+/) ? true : false );
assert('hello', 'hello world'.match('hello').toString());
assert('undefined', undefined + '');
var name = "over there";
assert(5, name.search("there"));
assert(0, name.search("over"));
assert(-1, name.search("should return -1"));
What were the alternatives to Jint? wikipedia has a good list of ECMAScript engines. The true alternatives for a C# windows app are: javascriptdotnet using V8 ( and Spidermonkey, except that it seems to be C++ and not C# ).
If IronJS were real, I'd look at it, but how can an F# app be embedded in C#?
If multi-threading becomes essential, I'll look at Lua for .net, Lua for .net, but it would need to have a great Unicode string library.
August 17, 2013 update. In the time elapsed since Feb 2011, when this post was created, some new Javascript engines have become available. This project is starting from scratch, so we're picking a new javascript. Today I learned about "Jurassic", and apparently IronJS is working now, Jint might have some bugs, node.js is on servers. I'll investigate further, keeping in mind that I am looking for a very feature-rich string library.