I wanted a very simple framework more like Sinatra than Rails. Something that make very easy to put together some simple Restful websites.
A year ago or so IronJS came around and even when the project is going strong, is still in flux. I have great hopes for it and keep an eye on the project since the performance benchmarks are really good. IronJS is implemented in F# and runs in the DLR.
I though about writing my own implementation but then I woke up and realize how stupid that idea was.
Five months ago I found Jint. Jint is implemented in C# using ANTlr for the parser and runs in the CLR not the DLR. I took it for a ride, wrote some test and a very simple proof of concept against it. It proved to be what I was looking for.
Extending the engine.
I wanted to be able to use some of my favorite libraries while writing code for Luca. For example, I wanted to have the extensions to the language provided by prototype.js at the tip of my hand.
I started doing that but I have some problems with the way Jint was interpreting the code.
I got the source for Jint to debug these problems. I found a bug in Jint in the way it dealt with the .substr method, so I wrote a few test and fixed it.
In doing so I got to understand how Jint works and an idea started to take form.
Instead of rely on external js files to extend the language why not to extend Jint itself.
I wanted those extensions to be available all the time and make them part of the engine maked more sense than load an interpret some js files each time.
I wanted to have those extensions to JS separate from the Jint core. I created two new overload constructors that take an IList of IExtensionRegister.
The list of registers is passed on time to the JsGlobal context that expose them as a property.
IExtensionRegister is a new interface that comes with a default implementation as an abstract class.
This implementation will scan the assembly, find all the classes that implement the new IExtension interface and register them in an Extensions property.
IExtension is as well a very simple interface.
This is the implementation of IExtensionRegister include in the Assembly that implements some of the prototype extensions.
And here the code to extend the Array object. I removed the actual implementation of the extensions since there is nothing really interested there.
Finally I need to modify the Constructor object for the type, in this case the JsArrayConstructor.
I want to abstract this last part a bit more, so I dont have to modify all the constructor objects.
Returning dynamic objects.
With an engine in place is time to take a look at how to interact with the asp.net pipeline and IIS. But that is coming in a future post.