Jint 2.0

After 6 months of hard work and wife complaints I have finished to rewrite Jint.

Source code: https://github.com/sebastienros/jint

Nuget package: https://www.nuget.org/packages/Jint

What is Jint ?

Jint is a JavaScript interpreter for .NET. This means you can take any JavaScript code and run it from your own .NET application. You could use it to let your users script your application domain, or to let them configure their application, run custom code in your CMS on specific events, test your JavaScript code, ...

How to use Jint ?

Here is how:

var engine = new Engine();
engine.Execute(@"
    function add(x, y) {
        return x + y;
    }
    var z = add(3, 2);
");

var z = engine.GetValue("z");
Console.WriteLine(z); // -> 5

There are obviously more features but I will let you look at the project itself to discover them. One of them is the ability to use a CLI (Command Line Interface) to execute JavaScript, and reuse .NET classes in it.

Why a re-write ?

I have created the first release in 2009, helped by one of my colleagues at that time, and another open source developer who liked the project. The main issues with this first version were the key pillars of the new version:

  • Ship as a PCL to support other .NET platforms like Windows Phone, Windows RT, Xamarin, ...
  • Be compliant with ECMA 5.1 specifications
  • Don't rely on Antlr for the parsing
  • Better architecture for maintainability and code simplicity

Next

My next goal will be to migrate RavenDB to use the new version. Should be pretty easy and come with several benefits, first being for them to deal with fewer JavaScript bugs, better performance and better .NET interoperability.

2 Comments

Add a Comment