Scripting Java
Rickard writes about a recent implemenation that combines Javascript and his Aspect Oriented Programming (AOP) system.
One interesting thing here is that while all the objects are AOP objects, implemented with dynamic proxies that have a bunch of interfaces, the weak typing of JavaScript comes in handy since there's no need for casting in the above script. Typically you'd have to have a cast for the result of portlets.get(i), and for the "node" object, and for the result of getContentLayout(), but not here. This makes it very easy to script AOP objects.I've been playing around with this idea, wondering what the extreme benefits would be. Javascript's weak typing is a great convenience, however could there be more? There are two approaches that I can think of. The first, is to use Javascript at the outer layer of a system, just as described above. The second, is to use Javascript as the core object model. The advantage of which is that all objects are dynamic, dynamic in the sense of the Adaptive Object Model (AOM) style. Now, the AOP feature may be that you may dynamically add aspects on the fly, possibly in a manner that is completely oblivious to the programmer.
I mean, there were discussion earlier about weather or not aspect definitions should be described in XML or Java. Well how about describing it in Javascript, its perfectly acceptable behavior, after all doesn't mozilla use Javascript to describe preferences? Its interesting to think of the different possibilities!
Javascript gets no respect. Maybe soon it will change? In some ways it's unfortunate that the word "scripting" is used for Javascript and others like Perl, Python, etc. Unlike the others, Javascript knows and deals with Java natively. Perl and Python have to stand on their own with their own libraries.
As for AOP, Javascript based one will be my choice over XML based ones.
7:56:31 AM #
Copyright 2003 Jay Han
Theme Design by Bryan Bell