Thursday, July 9, 2009

Some Server JS

Javscript on the serverside,.. it's happening; I'm drawn in by its beauty.

My workplace requires I base our web applications on a Microsoft product foundation. Not that I've got anything against Microsoft (I don't like vendor lock-in, but even so..), I just more prefer some of the non Microsoft founded languages ~ I'm a dynamic language fan. C# and friends are great, but they aren't as vendor neutral yet (I am looking forward to playing with more of the Iron** products they pushing out now; very interesting combo.)

What I love about Javsacript: It tends to be platform, vendor and pretty much all round - neutral. It's a dynamic, flexible and powerful syntax. I'm sold on it. Even better when it comes to web apps, now I'm playing with JS on the clientside and serverside; The consistency is awesome.

I've started building my take-over-the-world-its-so-powerful-framework; and it's in Javscript; On a Microsoft platform... [Awkward silence]

It's still all quite new to me, and I can't quite believe its working so well in our work context. I've basically setup a platform neutral interface of JS objects. I then create all application and framework objects above that. Below the interface sits a layer to allow all of the above to run on the MS JScript engine.



One thing (large thing) I haven't addressed is the ServerJS standard that's in formulation. Someday,.. but for now I'm just playing around. For example; I can now execute code on the server that looks something like this:

function getUsers(type) {
return $(['getUsers', 'usertype=' + type], function() {
var s = {
title: 'Users of Type: ' + type,
data: new Array()
};
db.query('select * from grv_user').each(function(o) {
s.data.push(o);
});
return s;
});
}


This example function prepares a response object (that will be JSON'ized), reads a list of data from the default database, and handles caching of this result in a tag based cache.

I'm personally quite happy with my new playground; I can squeeze a lot of functionality into a few lines. (Not that that's the point, but my RSI appreciates it). The serverside framework I've put in place includes a stripped version of the MooTools Framework. Fabulous!
Post a Comment