Revised and extended version of the "Virtual Separation of Concerns" talk, prepared for the GI-Dissertationspreis colloquium at Dagstuhl and for the invited talk at Oregon State University in Corvallis.
14. Objections / Criticism
Designed in the 70th and hardly evolved since
“#ifdef considered harmful”
“#ifdef hell”
“maintenance becomes a „hit or miss‟ process”
“is difficult to determine if the code being
viewed is actually compiled into the system”
“incomprehensible source texts”
“programming errors are easy “CPP makes maintenance difficult”
to make and difficult to detect”
“source code rapidly
“preprocessor diagnostics are poor” becomes a maze”
21. Advantages
• Easy to use
• “annotate and remove”
• Already part of many languages / simple tools
• Most developers already familiar
• Flexible / Expressive
• Language-independent / Uniform
• Low Adoption Barrier
• esp. with legacy code
31. Disciplined
Annotations
#ifdef WORLD
int main() {
printf(“Hello World”);
}
#endif
int main() {
#ifdef WORLD
printf(“Hello World”);
#endif
} greet.c
printf VBYE main
Align with variability model
VWORLD
msg ε msg ε printf
Align with code structure msg
32. Disciplined Undisciplined
Annotations
#ifdef WORLD int main() {
int main() { #ifdef DYNAMIC
printf(“Hello World”); if (enabled) {
} #endif
#endif printf(“Hello World”);
#ifdef DYNAIC
int main() { }
#ifdef WORLD #endif
printf(“Hello World”); }
#endif
} int a =
#ifdef DYNAMIC
Align with variability model enabled? 3 : 4 +
#endif
Align with code structure 5;
57. 353 included header files per C file
0
8590 macros per C file
0
1387 conditional macros per C file
0
340 alternative macros per C file
0
335490 token per C file
0 2.6.33.3
X86
72 % conditional
0
58. 7665 C files (x86)
0
30 seconds per file (median)
0
85 hours total
0
4.1 % overhead (undiscipl.)
0
0
0 syntax errors 2.6.33.3
X86
61. Summary
• Problems: • Improvements:
• Separation of Concerns • Views
• Obfuscation • Visual representation
• Error-proneness • Variability-aware analysis
• Retained advantages:
• Remaining Problems:
• Easy to use
• Modular Type Checking
• Flexible
• Separate Compilation
• Language-independent • Black-box Reuse
• Low adoption barrier
“Virtual Separation of Concerns”
62. Perspective
• Preprocessors common in practice, despite criticism
• Neglected by researchers
• Tool support can address most problems
• Currently scaling to Linux
• Interim solution or serious alternative?
Give preprocessors a second chance!