Ted Leung on the air: Open Source, Java, Python, and ...
It's been quite sometime since I made it to a SeaJUG meeting. Jayson Raymond, our host, mentioned that SeaJUG's 10 year anniversary is coming up, but I haven't been gone quite that long. It's just that SeaJUG is (apparently -- I'm not up on JUG lifetimes) one of the older JUGs. In fact it's been so long that I didn't even know that we were meeting in a new location. Normally I ride over with a friend who lives in Seattle, but he wasn't available, so a bunch of us from Bainbridge piled into a car and drove over.
Last night's meeting was a presentation by Ramnivas Laddad on "What's new in AOP". This was our yearly preview presentation ahead of the excellent Pacific Northwest Software Symposium. Several years ago I did a SeaJUG presentation on AspectJ, and I was curious to see how much things have changed.
There are now more syntaxes for expressing pointcuts and advice. You can have your choice of AspectJ syntax (nice because the AspectJ compiler can verify your pointcut expressions), Jave 1.5 annotations (nice because you aren't learning a special syntax, except that you are because you have to learn the mini-language for specifiying pointcuts), and even an XML based syntax (handy for instantiating abstract aspects at deployment time).
Also, you can now write pointcuts that rely on JDK 1.5 metadata. This is controversial. You get more control if you limit your pointcuts to annotations, but then you have to add annotations, which goes against the AOP idea of not having to modify the crosscut code.
The tooling has improved a lot. There's now very decent support in Eclipse (and some other IDE's), and that support does cool stuff like show you all the advised methods and so forth. There's also a history view that lets you view how aspects have been added or removed to parts of the system over time -- a nice usability improvement would be the ability to do this between revisions in the version control system.
When I gave my presentation, we had a long discussion about applications of AOP. I wish that there had been more discussion about this topic. It's easy to see the application of AOP to systems types of concerns, logging, performance testing, security, transactions, and so forth. It would be nice to see some patterns of aspect use as it relates to problem domains. Of course, the whole field is still pretty new, so it's understandable that there isn't a lot of data about this just yet. One interesting usage the was discussed was to advise constructors or factory methods as a way of injecting mock objects for use during unit testing.
I'm not doing a lot of Java these days, but I like to keep my nose in what's going on. As I was listening, I was thinking about having some of these capabilities in Python. Of course, you can do a lot of AOP style things fairly easily in Python, because various kinds of interception are easy to do. The things that I think are really missing are the pointcut expression language for expressing where interception is to take place, and whatever runtime support is needed to do the weaving. It sure would be handy...
Of course, in a language with generic functions, this is a non-problem because you'd probably have used generic functions to implement the operations in the first place. And thus, you could create a new package for say, generating UML sequence diagrams, and define all the generic functions and methods for that in that new package, without changing any of the old code. Or, you can define new node types to implement a new language feature, and include methods for all the existing operations. So, as you can see, languages with generic functions support aspectual decomposition natively, with no need for distinguished "AOP" features.
And pretty much everything else AOP has to offer can be pretty cleanly done with Lisp-style dynamic variables, so that you can shortcut parameters from one routine to another without changing the calling signatures of the routines in between.
That leaves you with the "oblivious" part, which is to say that you should be able to dynamically patch other code, which is trivial in most dynamic languages. So, the equation as I see it is:
AOP ~= generic functions + dynamic variables + monkeypatching.
I think that the AOP philosophy has gotten a bit off-track, though. The "oblivious code" is taken a little too seriously, in that it isn't really necessary in the real world to compose completely oblivious code. It more than suffices in a language with generic functions to say, "this is an operation that's going to need to be able to work with different types, or be modifiable as to criteria". For that matter, even for oblivious code, it suffices to be able to monkeypatch in a generic function to replace one that's not generic.
In other words, if I were a Smug Lisp Weenie, I'd be pointing out that Lisp has never had a real need for AOP and could do all this decades ago. Instead, I'm a Smug Python Weenie who's implemented generic functions for Python and is working on a dynamic variables package. Monkeypatching, of course, is already supported. :)
Posted by Phillip J. Eby at Thu Sep 22 09:33:23 2005
It offered a binding mechanism to wrap transparently any object to a meta-object. This meta-object could intercept any communication related to his subordinated object (I called that para-object -> the one that suffers reflection).
One interesting aspect of such meta-object protocol was that meta-objects could decide to propagate from -class or from-object into new instances created by their para-objects. What is cool about that ?
We could create a prototype system that could draw
UML Activity diagrams on-the-fly while the application was running, without any prior knowledge of the application.
Unfornatunately kaffe (upon which Guaranį was based) got a bit stuck, Oliva went to work for RedHat and the project froze in time.
It is in my TODO list to port it to Python ;o)
To learn more about it google for: Reflective Guaranį.
Senra
Posted by Rod Senra at Thu Sep 22 13:44:50 2005
I see you took the bait ;-). Anyone who's looked at the history of AOP will know that it arose from the work on metaobject protocols at PARC back in the early 90's.
As I said, the only thing that is really missing is a succinct and powerful notation for specifying the pointcuts. AspectJ's pointcut expression language is more convenient that writing a pile of generic functions, oblivious or not. Of course, it ought to be possible to provide a similar notation for a system based on generic functions.
Posted by Ted Leung at Fri Sep 23 00:00:55 2005
In other words, a pointcut in a dynamic functional language would just be a function to add a method to some set of generic functions.
Posted by Phillip J. Eby at Fri Sep 23 12:17:55 2005
Posted by Saha at Sun Dec 25 04:53:53 2005
To insert a URI, just type it -- no need to write an anchor tag.
Allowable html tags are:
<a href>
, <em>
, <i>
, <b>
, <blockquote>
, <br/>
, <p>
, <code>
, <pre>
, <cite>
, <sub>
and <sup>
.You can also use some Wiki style:
URI => [uri title]
<em> => _emphasized text_
<b> => *bold text*
Ordered list => consecutive lines starting spaces and an asterisk