Virtual Separation of Concerns - A Second Chance for Preprocessors.
Sven Apel, Christian Kästner · The Journal of Object Technology · 2009
Conditional compilation with preprocessors like cpp is a simple but effective means to implement variability.By annotating code fragments with #ifdef and #endif directives, different program variants with or without these fragments can be created, which can be used (among others) to implement software product lines.Although, preprocessors are frequently used in practice, they are often criticized for their negative effect on code quality and maintainability.In contrast to modularized implementations, for example using components or aspects, preprocessors neglect separation of concerns, are prone to introduce subtle errors, can entirely obfuscate the source code, and limit reuse.Our aim is to rehabilitate the preprocessor by showing how simple tool support can address these problems and emulate some benefits of modularized implementations.At the same time we emphasize unique benefits of preprocessors, like simplicity and language independence.Although we do not have a definitive answer on how to implement variability, we want highlight opportunities to improve preprocessors and encourage research toward novel preprocessor-based approaches.1 Historically, cpp has been designed for meta-programming.Of its three capabilities, file inclusion (#include), macros (#define), and conditional compilation (#ifdef ), we focus only on conditional compilation, which is routinely used to implement variability.There are many preprocessors that provide similar facilities.For example, for Java ME, the preprocessors Antenna (http://antenna.sf.net) is often used; the developers of Java's Swing library developed their own preprocessor Munge (http://weblogs.java.net/blog/tball/archive/munge/doc/Munge. html); the languages Fortran and Erlang have their own preprocessors; some browsers support conditional compilation in JavaScript; and conditional compilation is a language feature in C#, Visual Basic, D, PL/SQL, Adobe Flex, and others.