Friday, November 07, 2008

AOP programming languages

A friend of mine (LimaCAT) asked me if there was any programming language with OO and AOP integrated.

It is a very interesting concept and I never actually considered it :>
Mostly because to me AOP belongs to the domain of software design, while OO is much more at coding level: what I mean is that AOP concepts are external to the programming language on which AOP is applied, while classes, objects and methods are IN the language.

I looked for some material about AOP+OO in programming language and there are some unexpected keywords that tend to emerge:
- metaprogramming [A Comparative Analysis of Meta-programming and Aspect-Orientation - PDF, Metalevel Facilities for Multi-Language AOP - PDF , Metaprogramming]
- homoiconicity, defined as "a property of some programming languages, in which the primary representation of programs is also a data structure in a primitive type of the language itself" [Lisp, REBOL, and Clojure are homoiconic langauges]

The relation among metaprogramming, AOP and OODesign is well explained in this article:
''... design patterns can be used as powerful meta-programming operators that modify components in order to induce aspects of computations''

On a more concrete level, some discuss the relationship between AOP and existing langauges:
- Does Ruby need AOP? where the possibility of using http://fpl.cs.depaul.edu/ajeffrey/papers/concur04.pdf instead of AOP is discussed
- there is also an interesting implementation of http://fpl.cs.depaul.edu/ajeffrey/papers/concur04.pdf (here)

Some are trying to study AOP from a langauge-theoretic view-point:
- http://fpl.cs.depaul.edu/ajeffrey/papers/concur04.pdf (PDF)
- http://fpl.cs.depaul.edu/ajeffrey/papers/concur04.pdf (discussion and PDF)




I wander if instead AOP could be seen as composition of concurrent portions of code.
Suppose I want to attach behavior before and after a method call, so that instead of having the effect of:

m();

at run-time, I will have effectively:

before(); m(); after();

I could imagine to have 2 agents (or processes) and that I'm describing them separately (the class containing the method m() being the first process and the aspect descriptor being the second), and forcing them to execute in a specific interleaving, via some synchronization mechanism.

In this case a concurrent OO langauge with coroutines (like Erlang) could perhaps be enough to implement AOP directly as an idiom of the language...

I will look into this idea asap :)

No comments:

Post a Comment