Sunday, September 14, 2008

Joose now works with JScript .NET

I'll start a new job soon that will involve development with .NET so I figured it might be interesting to get Joose to work with JScript .NET.

Turns out, it works! Changes to Joose itself were minimal:
  • The .NET compiler actually spotted possible errors in Joose, which were easily corrected
  • While overriding toString seems to be possible, the JSC compiler complains about it when you do it too obvious :)
There was one more hurdle that was a little harder to take, but which might be also useful for other projects that get ported to JScript .NET:
Although there is a global object in JScript .NET, it doesn't have a name so you can't easily set new properties on it. Joose, however, wants to create new global objects when you make a module or class, so it needs this functionality. Turns out, it is quite easy to make it available:
When you execute a function declared in global scope, the 'this' variable refers to the global object, so you can assign that to a variable to make it available to the outside world. Here is a example that is using the name window for the global object (just like it is called in the browser):
var window;

(function() {
window = this;
You are invited to try it out. You need to checkout Joose from SVN and then go to the directory playground/ The file test.bat will execute all the test files from the testsuite. You will need to have jsc (the JScript .NET compiler in your path) which is part of the .NET framework in your path.

There will be some crashes during the test run. These are all related to the JSON library which is used inside Joose.Storage. All other tests run though, so Joose should be very usable.
Post a Comment