Backstage Java: making a difference in metaprogramming

  • Authors:
  • Zachary Palmer;Scott F. Smith

  • Affiliations:
  • The Johns Hopkins University, Baltimore, MD, USA;The Johns Hopkins University, Baltimore, MD, USA

  • Venue:
  • Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications
  • Year:
  • 2011

Quantified Score

Hi-index 0.00

Visualization

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.