Abstract
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.
- J. Baker and W. C. Hsieh. Maya: Multiple-dispatch syntax extension in Java. In phPLDI, pages 270--281, 2002. Google Scholar
Digital Library
- D. Batory, B. Lofaso, and Y. Smaragdakis. JTS: Tools for implementing domain-specific languages. Software Reuse, International Conference on, 0: 143, 1998. Google Scholar
Digital Library
- M. Bravenboer, R. Vermaas, J. Vinju, and E. Visser. Generalized type-based disambiguation of meta programs with concrete object syntax. In Proceedings of the Fourth International Conference on Generative Programming and Component Engineering (GPCE'05), volume 3676 of Lecture Notes in Computer Science, pages 157--172. Springer, 2005. Google Scholar
Digital Library
- S. Chiba. A metaobject protocol for C+, 1995.Google Scholar
- Codehaus Foundation. Groovy - building AST guide, May 2010. http://groovy.codehaus.org/BuildingASTGuide.Google Scholar
- E. Gamma, R. Helm, R. Johnson, and J. M. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley Professional, 1 edition, November 1994. Google Scholar
Digital Library
- S. E. Ganz, A. Sabry, and W. Taha. Macros as multi-stage computations: Type-safe, generative, binding macros in MacroML. In MacroML. In the International Conference on Functional Programming (ICFP '01, pages 74--85. ACM Press, 2001. Google Scholar
Digital Library
- J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification, Third Edition. Addison-Wesley Longman, Amsterdam, 3 edition, June 2005. Google Scholar
Digital Library
- S. S. Huang, D. Zook, and Y. Smaragdakis. Domain-specific languages and program generation with Meta-AspectJ. ACM Trans. Softw. Eng. Methodol., 18: 6:1--6:32, November 2008. Google Scholar
Digital Library
- S. Kamin, L. Clausen, and A. Jarvis. Jumbo: Run-time code generation for Java and its applications. In CGO '03: Proceedings of the international symposium on Code generation and optimization, pages 48--56, Washington, DC, USA, 2003. IEEE Computer Society. Google Scholar
Digital Library
- E. Lippe and N. van Oosterom. Operation-based merging. SIGSOFT Softw. Eng. Notes, 17: 78--87, November 1992. Google Scholar
Digital Library
- T. Mens. A state-of-the-art survey on software merging. IEEE Trans. Softw. Eng., 28: 449--462, May 2002. Google Scholar
Digital Library
- Z. Palmer and S. F. Smith. Backstage Java: Making a difference in metaprogramming. OOPSLA '11, 2011. ACM Digital Library supplemental material. Google Scholar
Digital Library
- T. J. Parr and R. W. Quong. Adding semantic and syntactic predicates to LL(k): pred-LL(k). In Computational Complexity, pages 263--277. Springer-Verlag, 1994. Google Scholar
Digital Library
- D. J. Quinlan. ROSE: Compiler support for object-oriented frameworks. Parallel Processing Letters, 10 (2/3): 215--226, 2000.Google Scholar
Cross Ref
- A. D. Robison. Impact of economics on compiler optimization. In Proceedings of the 2001 joint ACM-ISCOPE conference on Java Grande, JGI '01, pages 1--10, New York, NY, USA, 2001. ACM. Google Scholar
Digital Library
- T. Sheard. Accomplishments and research challenges in meta-programming. In SAIG 2001: Proceedings of the Second International Workshop on Semantics, Applications, and Implementation of Program Generation, pages 2--44, London, UK, 2001. Springer-Verlag. Google Scholar
Digital Library
- T. Sheard and S. P. Jones. Template meta-programming for Haskell. In ACM SIGPLAN Haskell Workshop 02, pages 1--16. ACM Press, 2002. Google Scholar
Digital Library
- W. Taha and phet. al. MetaOCaml: A compiled, type-safe multi-stage programming language. http://www.metaocaml.org/.Google Scholar
- W. Taha and T. Sheard. MetaML and multi-stage programming with explicit annotations. Theor. Comput. Sci., 248 (1--2): 211--242, 2000. Google Scholar
Digital Library
- M. Tatsubori and S. Chiba. Programming support of design patterns with compile-time reflection, 1998.Google Scholar
- L. Tratt. Compile-time meta-programming in a dynamically typed oo language. In Proceedings of the 2005 symposium on Dynamic languages, DLS '05, pages 49--63, New York, NY, USA, 2005. ACM. Google Scholar
Digital Library
- T. L. Veldhuizen. C+ templates are turing complete. Technical report, 2003.Google Scholar
- T. L. Veldhuizen. Tradeoffs in metaprogramming. In PEPM '06: Proceedings of the 2006 ACM SIGPLAN symposium on Partial evaluation and semantics-based program manipulation, pages 150--159, New York, NY, USA, 2006. ACM. Google Scholar
Digital Library
- E. Visser. Program transformation with Stratego/XT: Rules, strategies, tools, and systems in StrategoXT 0.9, 2004.Google Scholar
- D. von Dincklage. Making patterns explicit with metaprogramming. In GPCE '03: Proceedings of the 2nd international conference on Generative programming and component engineering, pages 287--306, New York, NY, USA, 2003. Springer-Verlag New York, Inc. Google Scholar
Digital Library
- E. Westbrook, M. Ricken, J. Inoue, Y. Yao, T. Abdelatif, and W. Taha. Mint: Java multi-stage programming using weak separability. In ACM SIGPLAN 2010 Conference on Programming Language Design and Implementation (PLDI '10), June 2010. Google Scholar
Digital Library
Index Terms
Backstage Java: making a difference in metaprogramming
Recommendations
Backstage Java: making a difference in metaprogramming
OOPSLA '11: Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applicationsWe 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 ...
MorphScala: safe class morphing with macros
SCALA '14: Proceedings of the Fifth Annual Scala WorkshopThe goal of this paper is to design an easy type-safe metaprogramming API for Scala to capture generative metaprogramming tasks that depend on existing definitions to generate others, by writing meta-code as close as possible to regular Scala code.
...
Sound type-dependent syntactic language extension
POPL '16: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesSyntactic language extensions can introduce new facilities into a programming language while requiring little implementation effort and modest changes to the compiler. It is typical to desugar language extensions in a distinguished compiler phase after ...







Comments