Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/2993236.2993239acmconferencesArticle/Chapter ViewAbstractPublication PagesgpceConference Proceedingsconference-collections
research-article

Recaf: Java dialects as libraries

Published: 20 October 2016 Publication History

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

Recommendations

Comments

Information & Contributors

Information

Published In

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
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 20 October 2016

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. extensible languages
  2. language virtualization
  3. object algebras
  4. transformation

Qualifiers

  • Research-article

Conference

GPCE '16
Sponsor:
GPCE '16: Generative Programming: Concepts and Experiences
October 31 - November 1, 2016
Amsterdam, Netherlands

Acceptance Rates

Overall Acceptance Rate 56 of 180 submissions, 31%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)5
  • Downloads (Last 6 weeks)1
Reflects downloads up to 09 Nov 2024

Other Metrics

Citations

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media