Abstract
Mainstream programming languages like Java have limited support for language extensibility. Without mechanisms for syntactic abstraction, new programming styles can only be embedded in the form of libraries, limiting expressiveness. In this paper, we present Recaf, a lightweight tool for creating Java dialects; effectively extending Java with new language constructs and user defined semantics. The Recaf compiler generically transforms designated method bodies to code that is parameterized by a semantic factory (Object Algebra), defined in plain Java. The implementation of such a factory defines the desired runtime semantics. We applied our design to produce several examples from a diverse set of programming styles and two case studies: we define i) extensions for generators, asynchronous computations and asynchronous streams and ii) a Domain-Specific Language (DSL) for Parsing Expression Grammars (PEGs), in a few lines of code.
- A. Biboudis, N. Palladinos, G. Fourtounis, and Y. Smaragdakis. Streams à la carte: Extensible Pipelines with Object Algebras. In Proc. of the 29th European Conference on Object-Oriented Programming, Leibniz International Proceedings in Informatics, pages 591–613. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik, 2015.Google Scholar
- G. Bierman, C. Russo, G. Mainland, E. Meijer, and M. Torgersen. Pause ’N’ Play: Formalizing Asynchronous C#. In Proc. of the 26th European Conference on Object-Oriented Programming, ECOOP’12, pages 233–257, Berlin, Heidelberg, 2012. Springer-Verlag. Google Scholar
Digital Library
- E. Bruneton, R. Lenglet, and T. Coupaye. ASM: a code manipulation tool to implement adaptable systems. Adaptable and Extensible Component Systems, 30:19, 2002.Google Scholar
- J. Carette, O. Kiselyov, and C.-c. Shan. Finally Tagless, Partially Evaluated: Tagless Staged Interpreters for Simpler Typed Languages. J. Funct. Program., 19(5):509–543, Sept. 2009. Google Scholar
Digital Library
- S. Chiba. A Metaobject Protocol for C++. In Proc. of the 10th Annual Conference on Object-Oriented Programming Systems, Languages, and Applications, OOPSLA ’95, pages 285–299, New York, NY, USA, 1995. ACM. Google Scholar
Digital Library
- S. Chiba. Javassist–a reflection-based programming wizard for Java. In Proc. of the OOPSLA’98 Workshop on Reflective Programming in C++ and Java, volume 174, 1998.Google Scholar
- R. Clarke and O. Vitzthum. Coffee: Recent Developments. John Wiley & Sons, 2008.Google Scholar
- S. Erdweg, T. Rendel, C. Kästner, and K. Ostermann. Sugarj: Library-based syntactic language extensibility. In Proc. of the 2011 ACM International Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA ’11, pages 391–406, New York, NY, USA, 2011. ACM. Google Scholar
Digital Library
- S. Erdweg, T. van der Storm, M. Völter, L. Tratt, R. Bosman, W. R. Cook, A. Gerritsen, A. Hulshout, S. Kelly, A. Loh, G. Konat, P. J. Molina, M. Palatnik, R. Pohjonen, E. Schindler, K. Schindler, R. Solmi, V. Vergu, E. Visser, K. van der Vlist, G. Wachsmuth, and J. van der Woning. Evaluating and comparing language workbenches: Existing results and benchmarks for the future. Computer Languages, Systems & Structures, 44, Part A:24 – 47, 2015. Special issue on the 6th and 7th International Conference on Software Language Engineering (SLE 2013 and SLE 2014). Google Scholar
Digital Library
- B. Ford. Packrat parsing:: Simple, powerful, lazy, linear time, functional pearl. In Proc. of the 7th ACM SIGPLAN International Conference on Functional Programming, ICFP ’02, pages 36–47, New York, NY, USA, 2002. ACM. Google Scholar
Digital Library
- B. Ford. Parsing expression grammars: A recognition-based syntactic foundation. In Proc. of the 31st ACM SIGPLANSIGACT Symposium on Principles of Programming Languages, POPL ’04, pages 111–122, New York, NY, USA, 2004. ACM. Google Scholar
Digital Library
- P. Inostroza and T. v. d. Storm. Modular Interpreters for the Masses: Implicit Context Propagation Using Object Algebras. In Proc. of the 2015 ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences, GPCE 2015, pages 171–180, New York, NY, USA, 2015. ACM. Google Scholar
Digital Library
- G. Kiczales, J. Des Rivieres, and D. G. Bobrow. The Art of the Metaobject Protocol. MIT press, 1991. Google Scholar
Digital Library
- P. Klint, T. v. d. Storm, and J. Vinju. RASCAL: A Domain Specific Language for Source Code Analysis and Manipulation. In Proc. of the 2009 9th IEEE International Working Conference on Source Code Analysis and Manipulation, SCAM ’09, pages 168–177, Washington, DC, USA, 2009. IEEE Computer Society. Google Scholar
Digital Library
- P. J. Landin. The Next 700 Programming Languages. Commun. ACM, 9(3):157–166, Mar. 1966. Google Scholar
Digital Library
- E. Meijer. Reactive Extensions (Rx): Curing your Asynchronous Programming Blues. In ACM SIGPLAN Commercial Users of Functional Programming, page 11. ACM, 2010. Google Scholar
Digital Library
- E. Meijer, B. Beckman, and G. Bierman. LINQ: Reconciling Object, Relations and XML in the .NET Framework. In Proc. of the 2006 ACM SIGMOD International Conference on Management of Data, SIGMOD ’06, pages 706–706, New York, NY, USA, 2006. ACM. Google Scholar
Digital Library
- E. Meijer, K. Millikin, and G. Bracha. Spicing Up Dart with Side Effects. Queue, 13(3):40:40–40:59, Mar. 2015. Google Scholar
Digital Library
- N. Nystrom, M. R. Clarkson, and A. C. Myers. Polyglot: An Extensible Compiler Framework for Java. In Proc. of the 12th International Conference on Compiler Construction, CC’03, pages 138–152, Berlin, Heidelberg, 2003. Springer-Verlag. Google Scholar
Digital Library
- B. C. d. S. Oliveira and W. R. Cook. Extensibility for the Masses: Practical Extensibility with Object Algebras. In Proc. of the 26th European Conference on Object-Oriented Programming, ECOOP’12, pages 2–27, Berlin, Heidelberg, 2012. Springer-Verlag. Google Scholar
Digital Library
- B. C. d. S. Oliveira, T. van der Storm, A. Loh, and W. R. Cook. Feature–Oriented Programming with Object Algebras. In Proc. of the 27th European Conference on Object-Oriented Programming, ECOOP’13, pages 27–51, Berlin, Heidelberg, 2013. Springer-Verlag. Google Scholar
Digital Library
- T. Petricek and D. Syme. The F# Computation Expression Zoo. In Proc. of the 16th International Symposium on Practical Aspects of Declarative Languages, PADL 2014, pages 33–48, New York, NY, USA, 2014. Springer-Verlag New York, Inc. Google Scholar
Digital Library
- F. Pfenning and C. Elliott. Higher-Order Abstract Syntax. In Proc. of the ACM SIGPLAN 1988 Conference on Programming Language Design and Implementation, PLDI ’88, pages 199– 208, New York, NY, USA, 1988. ACM. Google Scholar
Digital Library
- C. Prud’homme, J.-G. Fages, and X. Lorca. Choco Documentation. TASC, INRIA Rennes, LINA CNRS UMR 6241, COSLING S.A.S., 2015.Google Scholar
- T. Rompf, N. Amin, A. Moors, P. Haller, and M. Odersky. Scala-Virtualized: Linguistic Reuse for Deep Embeddings. Higher Order Symbol. Comput., 25(1):165–207, Mar. 2012. Google Scholar
Digital Library
- T. Rompf and M. Odersky. Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. Commun. ACM, 55(6):121–130, June 2012. Google Scholar
Digital Library
- D. Syme. The F# 3.0 Language Specification, Sept. 2012.Google Scholar
- S. Tobin-Hochstadt, V. St-Amour, R. Culpepper, M. Flatt, and M. Felleisen. Languages As Libraries. In Proc. of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 132–141. ACM, 2011. Google Scholar
Digital Library
- J. Vlissides, R. Helm, R. Johnson, and E. Gamma. Design patterns: Elements of reusable object-oriented software. Addison-Wesley, 1995. Google Scholar
Digital Library
- P. Wadler. How to Replace Failure by a List of Successes. In Proc. of the Conference on Functional Programming Languages and Computer Architecture, pages 113–128, New York, NY, USA, 1985. Springer-Verlag New York, Inc. Google Scholar
Digital Library
- P. Wadler. The Expression Problem. http://homepages.inf. ed.ac.uk/wadler/papers/expression/expression.txt, Dec. 1998.Google Scholar
Index Terms
Recaf: Java dialects as libraries
Recommendations
Recaf: Java dialects as libraries
GPCE 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesMainstream programming languages like Java have limited support for language extensibility. Without mechanisms for syntactic abstraction, new programming styles can only be embedded in the form of libraries, limiting expressiveness. In this paper, we ...
Languages as libraries
PLDI '11Programming language design benefits from constructs for extending the syntax and semantics of a host language. While C's string-based macros empower programmers to introduce notational shorthands, the parser-level macros of Lisp encourage ...
Languages as libraries
PLDI '11: Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and ImplementationProgramming language design benefits from constructs for extending the syntax and semantics of a host language. While C's string-based macros empower programmers to introduce notational shorthands, the parser-level macros of Lisp encourage ...







Comments