This project has moved and is read-only. For the latest updates, please go here.

Running Jurassic JavaScript from C# with a hint of dynamic

Jun 30, 2011 at 5:23 AM

I created a C# library that let you access the JavaScript objects and arrays in the C# world using the dynamic syntax available in JavaScript.
So you can write, the following C# code.

dynamic jsContext = new DynamicJavascriptContext(
                          Jurassic.ScriptEngine()
                    );                                               
jsContext.message = "Hello World !";
jsContext.number = 1;
 
string script = @"
    var i = 0;
    for (i = 0; i < 5; i++)
        console.log(message + ' (' + i + ')');
    number += i;
";
 
jsContext.Run(script);
 
Console.WriteLine("number: " + jsContext.number);

See my post, and let me know your remarks.

http://frederictorres.blogspot.com/2011/06/running-javascript-from-c-with-hint-of.html

Jun 30, 2011 at 1:02 PM

Very cool!  I'd be interested in knowing what you are using this for - are you using it within another app you are building?  Or is this just a tech demo type of thing?

Jun 30, 2011 at 3:19 PM

Paul, I am a .NET developer, which is also into dynamic languages. In the past I used IronPython to extend applications, see


But since late 2010, I am 100% in JavaScript, to build stuff from the server to my iphone. I want to be able to run JavaScript and maybe CoffeeScript from C#. 

Here is one first blog about it : http://frederictorres.blogspot.com/2011/06/embedding-javascript-in-c-application.html

Another example:  A CoffeeScript compiler and run time http://www.youtube.com/watch?v=ESd_h8_vvxM

I do not have specific app where I am going to mix C# and JavaScript, but it is just a matter of time.

I wanted a more JavaScript like syntax in C#, that is why i wrote this library.

By the way Jurassic is awesome.

Jul 1, 2011 at 10:54 AM

Thanks for the kind words :-)  I wish I had more time to spend on Jurassic (it'd be cool to implement runtime time analysis, for example), but unfortunately my day job is a demanding mistress.