skip to main content
research-article

Backstage Java: making a difference in metaprogramming

Published:22 October 2011Publication History
Skip Abstract Section

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.

References

  1. J. Baker and W. C. Hsieh. Maya: Multiple-dispatch syntax extension in Java. In phPLDI, pages 270--281, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. D. Batory, B. Lofaso, and Y. Smaragdakis. JTS: Tools for implementing domain-specific languages. Software Reuse, International Conference on, 0: 143, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. S. Chiba. A metaobject protocol for C+, 1995.Google ScholarGoogle Scholar
  5. Codehaus Foundation. Groovy - building AST guide, May 2010. http://groovy.codehaus.org/BuildingASTGuide.Google ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification, Third Edition. Addison-Wesley Longman, Amsterdam, 3 edition, June 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. E. Lippe and N. van Oosterom. Operation-based merging. SIGSOFT Softw. Eng. Notes, 17: 78--87, November 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. T. Mens. A state-of-the-art survey on software merging. IEEE Trans. Softw. Eng., 28: 449--462, May 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Z. Palmer and S. F. Smith. Backstage Java: Making a difference in metaprogramming. OOPSLA '11, 2011. ACM Digital Library supplemental material. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. D. J. Quinlan. ROSE: Compiler support for object-oriented frameworks. Parallel Processing Letters, 10 (2/3): 215--226, 2000.Google ScholarGoogle ScholarCross RefCross Ref
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. T. Sheard and S. P. Jones. Template meta-programming for Haskell. In ACM SIGPLAN Haskell Workshop 02, pages 1--16. ACM Press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. W. Taha and phet. al. MetaOCaml: A compiled, type-safe multi-stage programming language. http://www.metaocaml.org/.Google ScholarGoogle Scholar
  20. W. Taha and T. Sheard. MetaML and multi-stage programming with explicit annotations. Theor. Comput. Sci., 248 (1--2): 211--242, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. M. Tatsubori and S. Chiba. Programming support of design patterns with compile-time reflection, 1998.Google ScholarGoogle Scholar
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. T. L. Veldhuizen. C+ templates are turing complete. Technical report, 2003.Google ScholarGoogle Scholar
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. E. Visser. Program transformation with Stratego/XT: Rules, strategies, tools, and systems in StrategoXT 0.9, 2004.Google ScholarGoogle Scholar
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Backstage Java: making a difference in metaprogramming

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!