Domain-Specific Languages and Program Generation with Meta-AspectJ Shan Shan Huang, David Zook Georgia Institute of Technology and Yannis Smaragdakis University of Oregon Meta-AspectJ (MAJ) is a language for generating AspectJ programs using code templates. MAJ itself is an extension of Java, so users can interleave arbitrary Java code with AspectJ code tem- plates. MAJ is a structured meta-programming tool: a well-typed generator implies a syntactically correct generated program. MAJ promotes a methodology that combines aspect-oriented and gen- erative programming. A valuable application is in implementing small domain-specific language extensions as generators using unobtrusive annotations for syntax extension and AspectJ as a back-end. The advantages of this approach are twofold. First, the generator integrates into an existing software application much as a regular API or library, instead of as a language extension. Second, a mature language implementation is easy to achieve with little effort since AspectJ takes care of the low-level issues of interfacing with the base Java language. In addition to its practical value, MAJ offers valuable insights to meta-programming tool de- signers. It is a mature meta-programming tool for AspectJ (and, by extension, Java): a lot of emphasis has been placed on context-sensitive parsing and error-reporting. As a result, MAJ minimizes the number of meta-programming (quote/unquote) operators and uses type inference to reduce the need to remember type names for syntactic entities. Categories and Subject Descriptors: D.1.2 [Programming Techniques]: Automatic Program- ming—program synthesis, program transformation, program verification; D.3.3 [Programming Languages]: Language Constructs and Features; D.2.13 [Software Engineering]: Reusable Software General Terms: Design,Languages Additional Key Words and Phrases: meta-programming, domain-specific languages, language extensions 1. INTRODUCTION Meta-programming is the act of writing programs that generate other programs. Powerful meta-programming is essential for approaches to automating software de- velopment. Most domain-specific languages and many other software automation Authors’ address: College of Computing, Georgia Institute of Technology, Atlanta, GA 30332, USA; email:{ssh,dzook}@cc.gatech.edu; 1202 University of Oregon, Eugene, OR 97403-1202, USA; email: yannis@cs.uoregon.edu; This is an extended version of [Zook et al. 2004] also containing material from [Huang and Smaragdakis 2006]. Permission to make digital/hard copy of all or part of this material without fee for personal or classroom use provided that the copies are not made or distributed for profit or commercial advantage, the ACM copyright/server notice, the title of the publication, and its date appear, and notice is given that copying is by permission of the ACM, Inc. To copy otherwise, to republish, to post on servers, or to redistribute to lists requires prior specific permission and/or a fee. c 20YY ACM 0000-0000/20YY/0000-0001 $5.00 ACM Journal Name, Vol. V, No. N, Month 20YY, Pages 1–0??.