Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aspect Oriented Programming in C++ - Current supported alternatives

Tags:

c++

aop

I have used AspectJ before for Java, and I recently have thought about checking which possibilities exist for the C++ language.

I heard about AspectC++, but unlike AspectJ, AspectC++ seems to be abandoned in the sense that the latest release dates from 21.12.2005, according to their website.

I wonder if there are any more recent alternatives currently being used or developed nowadays, and which are still supported and having continuous updates and evolution, and also if any of such alternatives happen to have some sort of integration plugin for easier use within the Eclipse IDE.

In the event that there aren't, are there some most problematic limitations from AspectC++ that I should be aware of before considering to use it?

Thanks in advance.

like image 554
Luis Miguel Serrano Avatar asked Nov 16 '10 23:11

Luis Miguel Serrano


2 Answers

AspectC++ was a worthy try but university projects don't often continue because the products tend not to be robust, the original academics lose interest and the graduate students that build it move on. That appeared to be case when I wrote this answer in 2010. To my surprise in 2017, AspectC++ still seems to have active development. If you want just aspects for C++, this is probably worth a look.

Aspect-oriented programming is a just a special kind of program transformation ("find places that match this condition ('pointcut') and do this to the code at that place"). So, if you have a program transformation tool, you can emulate AOP pretty easily. To do transformation on C++ you need a strong C++ front end and as well as ability to transform and regenerate code. OpenC++ was a project to do C++ transformations, where the transformations are coded purely as procedural AST-walks with procedural AST modifications. A particular issue had to do with which dialect of C++ was handled by OpenC++; in particular, I'm not sure OpenC++ handled templates or full common dialects (GCC, MS) of C+; however I have no direct experience with it, just a keen aficionado of such tools.

Our DMS Software Reengineering Toolkit is a general purpose program transformation parameterized by language definitions. It has robust definitions for GCC and MS dialects of C++. You can implement program transformations procedurally as OpenC++ does, or more conveniently you can write source-to-source pattern-directed transformations (or more usually, mix these to achieve complex effects). DMS has been used to carry out massive restructuring of large scale C++ codes (see Case study: Re-engineering C++ component models via automatic program transformation ). DMS is actively maintained, but it is commercial.

EDIT March, 2015: Now does C++14 in GCC and MS dialects.

EDIT July 2017: Now does C++17 in GCC and MS dialects.

like image 113
Ira Baxter Avatar answered Nov 11 '22 14:11

Ira Baxter


comp.lang.c++ convo I was in a couple years ago lead to something interesting I never actually tried myself: http://groups.google.com/group/comp.lang.c++/browse_thread/thread/c5fd9337577b0bdf/1c639d8b6b3c0985?hl=en&ie=UTF-8&q=comp.lang.c%2B%2B+noah+roberts+aspect+oriented+template#1c639d8b6b3c0985

like image 41
Edward Strange Avatar answered Nov 11 '22 14:11

Edward Strange