Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/2814270.2814279acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Scrap your boilerplate with object algebras

Published: 23 October 2015 Publication History

Abstract

Traversing complex Abstract Syntax Trees (ASTs) typically requires large amounts of tedious boilerplate code. For many operations most of the code simply walks the structure, and only a small portion of the code implements the functionality that motivated the traversal in the first place. This paper presents a type-safe Java framework called Shy that removes much of this boilerplate code. In Shy object algebras are used to describe complex and extensible AST structures. Using Java annotations Shy generates generic boilerplate code for various types of traversals. For a concrete traversal, users of Shy can then inherit from the generated code and override only the interesting cases. Consequently, the amount of code that users need to write is significantly smaller. Moreover, traversals using the Shy framework are also much more structure shy, becoming more adaptive to future changes or extensions to the AST structure. To prove the effectiveness of the approach, we applied Shy in the implementation of a domain-specific questionnaire language. Our results show that for a large number of traversals there was a significant reduction in the amount of user-defined code.

Supplementary Material

Auxiliary Archive (p127-zhang-s.zip)
The auxiliary material provides the artifact supporting paper "Scrap Your Boilerplate with Object Algebras". Source code and some instructions of using the library are available in the compressed file. URL to GitHub repository: https://github.com/JasonCHU/SYBwithOA

References

[1]
M. D. Adams and T. M. DuBuisson. Template your boilerplate: Using Template Haskell for efficient generic programming. In Proceedings of the 2012 ACM SIGPLAN Haskell symposium, Haskell ’12, pages 13–24, 2012.
[2]
G. M. Bierman, E. Meijer, and W. Schulte. The essence of data access in comega. In ECOOP, 2005.
[3]
P. Borovansk`y, C. Kirchner, H. Kirchner, P.-E. Moreau, and M. Vittek. ELAN: A logical framework based on computational systems. Electronic Notes in Theoretical Computer Science, 4:35–50, 1996.
[4]
M. Bravenboer and E. Visser. Guiding visitors: Separating navigation from computation. Technical Report UU-CS- 2001-42, Institute of Information and Computing Sciences, Utrecht University, 2001.
[5]
B. Chadwick and K. Lieberherr. Weaving generic programming and traversal performance. In AOSD’10, 2010.
[6]
N. de Bruijn. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagationes Mathematicae (Proceedings), 75(5):381–392, 1972.
[7]
S. Erdweg, T. van der Storm, M. Völter, M. Boersma, R. Bosman, W. R. Cook, A. Gerritsen, A. Hulshout, S. Kelly, A. Loh, et al. The state of the art in language workbenches. In Software Language Engineering. Springer, 2013.
[8]
E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-oriented Software. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1995. ISBN 0-201-63361-2.
[9]
M. Gouseti, C. Peters, and T. v. d. Storm. Extensible language implementation with Object Algebras (short paper). In GPCE’14, 2014.
[10]
J. Hannemann and G. Kiczales. Design pattern implementation in Java and aspectJ. In OOPSLA ’02, 2002.
[11]
R. Lammel and S. P. Jones. Scrap your boilerplate: A practical design pattern for generic programming. In TLDI’03, 2003.
[12]
R. Lämmel and S. P. Jones. Scrap more boilerplate: Reflection, zips, and generalised casts. In ICFP ’04, 2004.
[13]
R. Lämmel and S. P. Jones. Scrap your boilerplate with class: Extensible generic functions. In ICFP ’05, 2005.
[14]
R. Lämmel and J. Visser. Typed combinators for generic traversal. In Practical Aspects of Declarative Languages, pages 137–154. Springer, 2002.
[15]
R. Lämmel, J. Visser, and J. Kort. Dealing with large bananas. In J. Jeuring, editor, Workshop on Generic Programming, Ponte de Lima, July 2000. Technical Report UU-CS- 2000-19, Universiteit Utrecht.
[16]
R. Lämmel, E. Visser, and J. Visser. Strategic programming meets adaptive programming. In AOSD ’03, 2003.
[17]
K. J. Lieberherr. Adaptive Object Oriented Software: The Demeter Method with Propagation Patterns. PWS Publishing, 1996.
[18]
M. E. Nordberg. Variations on the visitor pattern, 1996.
[19]
B. C. d. S. Oliveira and W. R. Cook. Extensibility for the masses, practical extensibility with object algebras. In ECOOP ’12, 2012.
[20]
B. C. d. S. Oliveira, M. Wang, and J. Gibbons. The visitor pattern as a reusable, generic, type-safe component. In OOPSLA’08, 2008.
[21]
B. C. d. S. Oliveira, T. van der Storm, A. Loh, and W. R. Cook. Feature-oriented programming with object algebras. In ECOOP ’13, 2013.
[22]
D. Orleans and K. J. Lieberherr. DJ: Dynamic adaptive programming in Java. In Reflection 2001. Springer-Verlag, 2001.
[23]
J. Palsberg and C. B. Jay. The essence of the visitor pattern. In COMPSAC’98, 1998.
[24]
T. Rendel, J. I. Brachthäuser, and K. Ostermann. From object algebras to attribute grammars. In OOPSLA ’14, 2014.
[25]
M. G. J. van den Brand, P. Klint, and J. J. Vinju. Term rewriting with traversal functions. ACM Trans. Softw. Eng. Methodol., 12(2):152–190, Apr. 2003.
[26]
E. Visser and Z.-e.-A. Benaissa. A core language for rewriting. Electronic Notes in Theoretical Computer Science, 15: 422–441, 1998.
[27]
E. Visser, Z.-e.-A. Benaissa, and A. Tolmach. Building program optimizers with rewriting strategies. In ICFP’98, 1998.
[28]
J. Visser. Visitor combination and traversal control. In OOPSLA ’01, 2001.
[29]
P. Wadler. The Expression Problem. Email, Nov. 1998.
[30]
Discussion on the Java Genericity mailing list.
[31]
P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In POPL ’89, 1989.

Cited By

View all
  • (2021)Characterizing the Usage, Evolution and Impact of Java Annotations in PracticeIEEE Transactions on Software Engineering10.1109/TSE.2019.291051647:5(969-986)Online publication date: 1-May-2021
  • (2020)Annotation practices in Android apps2020 IEEE 20th International Working Conference on Source Code Analysis and Manipulation (SCAM)10.1109/SCAM51674.2020.00020(132-142)Online publication date: Sep-2020
  • (2018)One tool, many languages: language-parametric transformation with incremental parametric syntaxProceedings of the ACM on Programming Languages10.1145/32764922:OOPSLA(1-28)Online publication date: 24-Oct-2018
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
OOPSLA 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications
October 2015
953 pages
ISBN:9781450336895
DOI:10.1145/2814270
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 50, Issue 10
    OOPSLA '15
    October 2015
    953 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/2858965
    • Editor:
    • Andy Gill
    Issue’s Table of Contents
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: 23 October 2015

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Java
  2. Object algebras
  3. adaptive object-oriented programming
  4. boilerplate code

Qualifiers

  • Research-article

Funding Sources

Conference

SPLASH '15
Sponsor:

Acceptance Rates

Overall Acceptance Rate 268 of 1,244 submissions, 22%

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)7
  • Downloads (Last 6 weeks)1
Reflects downloads up to 14 Dec 2024

Other Metrics

Citations

Cited By

View all
  • (2021)Characterizing the Usage, Evolution and Impact of Java Annotations in PracticeIEEE Transactions on Software Engineering10.1109/TSE.2019.291051647:5(969-986)Online publication date: 1-May-2021
  • (2020)Annotation practices in Android apps2020 IEEE 20th International Working Conference on Source Code Analysis and Manipulation (SCAM)10.1109/SCAM51674.2020.00020(132-142)Online publication date: Sep-2020
  • (2018)One tool, many languages: language-parametric transformation with incremental parametric syntaxProceedings of the ACM on Programming Languages10.1145/32764922:OOPSLA(1-28)Online publication date: 24-Oct-2018
  • (2017)Type-safe modular parsingProceedings of the 10th ACM SIGPLAN International Conference on Software Language Engineering10.1145/3136014.3136016(2-13)Online publication date: 23-Oct-2017
  • (2016)Compositional Language Engineering Using Generated, Extensible, Static Type-Safe VisitorsProceedings of the 12th European Conference on Modelling Foundations and Applications - Volume 976410.1007/978-3-319-42061-5_5(67-82)Online publication date: 6-Jul-2016
  • (2019)Instructed late bindingProceedings of the 23rd Pan-Hellenic Conference on Informatics10.1145/3368640.3368644(135-142)Online publication date: 28-Nov-2019

View Options

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