Backstage Java: making a difference in metaprogramming

We propose Backstage Java (BSJ), a Java language extension which allows algorithmic, contextually-aware generation and transformation of code. BSJ explicitly and concisely represents design patterns and other encodings by employing compile-time metaprogramming: a practice in which the programmer writes instructions which are executed over the program's AST during compilation. While compile-time metaprogramming has been successfully used in functional languages such as Template Haskell, a number of language properties (scope, syntactic structure, mutation, etc.) have thus far prevented this theory from translating to the imperative world. BSJ uses the novel approach of difference-based metaprogramming to provide an imperative programming style amenable to the Java community and to enforce that metaprograms are consistent and semantically unambiguous. To make the feasibility of BSJ metaprogramming evident, we have developed a compiler implementation and numerous working code examples.

[1]  Shan Shan Huang,et al.  Domain-specific languages and program generation with meta-AspectJ , 2008, TSEM.

[2]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[3]  Walid Taha,et al.  MetaML and multi-stage programming with explicit annotations , 2000, Theor. Comput. Sci..

[4]  Russell W. Quong,et al.  Adding Semantic and Syntactic Predicates To LL(k): pred-LL(k) , 1994, CC.

[5]  Amr Sabry,et al.  Macros as multi-stage computations: type-safe, generative, binding macros in MacroML , 2001, ICFP '01.

[6]  Shigeru Chiba,et al.  A metaobject protocol for C++ , 1995, OOPSLA.

[7]  D. Quinlan,et al.  ROSE: Compiler Support for Object-Oriented Frameworks , 1999, Parallel Process. Lett..

[8]  Ernst Lippe,et al.  Operation-based merging , 1992, SDE 5.

[9]  Tom Mens,et al.  A State-of-the-Art Survey on Software Merging , 2002, IEEE Trans. Software Eng..

[10]  Yannis Smaragdakis,et al.  JTS: tools for implementing domain-specific languages , 1998, Proceedings. Fifth International Conference on Software Reuse (Cat. No.98TB100203).

[11]  Walid Taha,et al.  Mint: Java multi-stage programming using weak separability , 2010, PLDI '10.

[12]  Daniel J. Quinlan ROSE: Compiler Support for Object-Oriented Frameworks , 2000, Parallel Process. Lett..

[13]  Michiaki Tatsubori,et al.  Programming Support of Design Patterns with Compile-time Reflection , 2000 .

[14]  James Gosling,et al.  The Java Language Specification, 3rd Edition , 2005 .

[15]  Guy L. Steele,et al.  Java(TM) Language Specification, The (3rd Edition) (Java (Addison-Wesley)) , 2005 .

[16]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[17]  Todd L. Veldhuizen,et al.  C++ Templates are Turing Complete , 2003 .

[18]  Samuel N. Kamin,et al.  Jumbo: run-time code generation for Java and its applications , 2003, International Symposium on Code Generation and Optimization, 2003. CGO 2003..

[19]  Daniel von Dincklage Making Patterns Explicit with Metaprogramming , 2003, GPCE.

[20]  Laurence Tratt,et al.  Compile-time meta-programming in a dynamically typed OO language , 2005, DLS '05.

[21]  Arch D. Robison,et al.  Impact of economics on compiler optimization , 2001, JGI '01.

[22]  Wilson C. Hsieh,et al.  Maya: multiple-dispatch syntax extension in Java , 2002, PLDI '02.

[23]  Eelco Visser,et al.  Generalized type-based disambiguation of meta programs with concrete object syntax , 2005, GPCE'05.

[24]  Todd L. Veldhuizen,et al.  Tradeoffs in metaprogramming , 2005, PEPM '06.

[25]  Eelco Visser,et al.  Program Transformation with Stratego/XT: Rules, Strategies, Tools, and Systems in Stratego/XT 0.9 , 2003, Domain-Specific Program Generation.

[26]  Tim Sheard,et al.  Accomplishments and Research Challenges in Meta-programming , 2001, SAIG.