skip to main content
article

Recaf: Java dialects as libraries

Published:20 October 2016Publication History
Skip Abstract Section

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.

References

  1. 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 ScholarGoogle Scholar
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle Scholar
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle Scholar
  7. R. Clarke and O. Vitzthum. Coffee: Recent Developments. John Wiley & Sons, 2008.Google ScholarGoogle Scholar
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. G. Kiczales, J. Des Rivieres, and D. G. Bobrow. The Art of the Metaobject Protocol. MIT press, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. P. J. Landin. The Next 700 Programming Languages. Commun. ACM, 9(3):157–166, Mar. 1966. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. E. Meijer. Reactive Extensions (Rx): Curing your Asynchronous Programming Blues. In ACM SIGPLAN Commercial Users of Functional Programming, page 11. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. E. Meijer, K. Millikin, and G. Bracha. Spicing Up Dart with Side Effects. Queue, 13(3):40:40–40:59, Mar. 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. C. Prud’homme, J.-G. Fages, and X. Lorca. Choco Documentation. TASC, INRIA Rennes, LINA CNRS UMR 6241, COSLING S.A.S., 2015.Google ScholarGoogle Scholar
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. D. Syme. The F# 3.0 Language Specification, Sept. 2012.Google ScholarGoogle Scholar
  28. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  29. J. Vlissides, R. Helm, R. Johnson, and E. Gamma. Design patterns: Elements of reusable object-oriented software. Addison-Wesley, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. P. Wadler. The Expression Problem. http://homepages.inf. ed.ac.uk/wadler/papers/expression/expression.txt, Dec. 1998.Google ScholarGoogle Scholar

Index Terms

  1. Recaf: Java dialects as libraries

      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

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 52, Issue 3
        GPCE '16
        March 2017
        212 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/3093335
        Issue’s Table of Contents
        • cover image ACM Conferences
          GPCE 2016: Proceedings of the 2016 ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences
          October 2016
          212 pages
          ISBN:9781450344463
          DOI:10.1145/2993236

        Copyright © 2016 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 20 October 2016

        Check for updates

        Qualifiers

        • article

      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!