Ted Leung on the air
Ted Leung on the air: Open Source, Java, Python, and ...
Wed, 21 Sep 2005
SeaJUG 9/20/2005

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...

[21:45] | [computers/programming/java] | # | TB | F | G | 5 Comments | Other blogs commenting on this post
A good example of domain-based AOP is a compiler's AST: you want to perform various operations on it, like pretty-printing it, generating code for various backends, type-annotating it, interpreting it etc.  If you design all those operations in to start, it's not AOP, but if you have to add in new methods to all the AST classes to implement a new operation, that's a crosscut.

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

You can subscribe to an RSS feed of the comments for this blog: RSS Feed for comments

Add a comment here:

You can use some HTML tags in the comment text:
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





Remember my info?

twl JPG


Ted Leung FOAF Explorer

I work at the Open Source Applications Foundation (OSAF).
The opinions expressed here are entirely my own, not those of my employer.

Creative Commons License
This work is licensed under a Creative Commons License.

Now available!
Professional XML Development with Apache Tools : Xerces, Xalan, FOP, Cocoon, Axis, Xindice
Technorati Profile
PGP Key Fingerprint
My del.icio.us Bookmarks
My Flickr Photos

RSS 2.0 xml GIF
Comments (RSS 2.0) xml GIF
Atom 0.3 feed
Feedburner'ed RSS feed

< September 2005 >
     1 2 3
4 5 6 7 8 910


Macintosh Tips and Tricks

Blogs nearby
geourl PNG

/ (1567)
  books/ (33)
  computers/ (62)
    hardware/ (15)
    internet/ (58)
      mail/ (11)
      microcontent/ (58)
      weblogs/ (174)
        pyblosxom/ (36)
      www/ (25)
    open_source/ (145)
      asf/ (53)
      osaf/ (32)
        chandler/ (35)
        cosmo/ (1)
    operating_systems/ (16)
      linux/ (9)
        debian/ (15)
        ubuntu/ (2)
      macosx/ (101)
        tips/ (25)
      windows_xp/ (4)
    programming/ (156)
      clr/ (1)
      dotnet/ (13)
      java/ (71)
        eclipse/ (22)
      lisp/ (34)
      python/ (86)
      smalltalk/ (4)
      xml/ (18)
    research/ (1)
    security/ (4)
    wireless/ (1)
  culture/ (10)
    film/ (8)
    music/ (6)
  education/ (13)
  family/ (17)
  gadgets/ (24)
  misc/ (47)
  people/ (18)
  photography/ (25)
    pictures/ (12)
  places/ (3)
    us/ (0)
      wa/ (2)
        bainbridge_island/ (17)
        seattle/ (13)
  skating/ (6)
  society/ (20)

[Valid RSS]

del.icio.us linkblog



Listed on BlogShares

Locations of visitors to this page
Where are visitors to this page?

pyblosxom GIF