EVF: An Extensible and Expressive Visitor Framework for Programming Language Reuse

Authors Weixin Zhang, Bruno C. d. S. Oliveira



PDF
Thumbnail PDF

File

LIPIcs.ECOOP.2017.29.pdf
  • Filesize: 0.75 MB
  • 32 pages

Document Identifiers

Author Details

Weixin Zhang
Bruno C. d. S. Oliveira

Cite AsGet BibTex

Weixin Zhang and Bruno C. d. S. Oliveira. EVF: An Extensible and Expressive Visitor Framework for Programming Language Reuse. In 31st European Conference on Object-Oriented Programming (ECOOP 2017). Leibniz International Proceedings in Informatics (LIPIcs), Volume 74, pp. 29:1-29:32, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2017)
https://doi.org/10.4230/LIPIcs.ECOOP.2017.29

Abstract

Object Algebras are a design pattern that enables extensibility, modularity, and reuse in mainstream object-oriented languages such as Java. The theoretical foundations of Object Algebras are rooted on Church encodings of datatypes, which are in turn closely related to folds in functional programming. Unfortunately, it is well-known that certain programs are difficult to write, and may incur performance penalties when using Church-encodings/folds. This paper presents EVF: an extensible and expressive Java Visitor framework. The visitors supported by EVF generalize Object Algebras and enable writing programs using a generally recursive style rather than folds. The use of such generally recursive style enables users to more naturally write programs, which would otherwise require contrived workarounds using a fold-like structure. EVF visitors retain the type-safe extensibility of Object Algebras. The key advance in EVF is a novel technique to support extensible external visitors. Extensible external visitors are able to control traversals with direct access to the data structure being traversed, allowing dependent operations to be defined modularly without the need of advanced type system features. To make EVF practical, the framework employs annotations to automatically generate large amounts of boilerplate code related to visitors and traversals. To illustrate the applicability of EVF we conduct a case study, which refactors a large number of non-modular interpreters from the “Types and Programming Languages” (TAPL) book. Using EVF we are able to create a modular software product line (SPL) of the TAPL interpreters, enabling sharing of large portions of code and features. The TAPL software product line contains several modular operations, which would be non-trivial to define with standard Object Algebras.
Keywords
  • Visitor Pattern
  • Object Algebras
  • Modularity
  • Domain-Specific Languages

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Sven Apel, Christian Kastner, and Christian Lengauer. Featurehouse: Language-independent, automated software composition. In Proceedings of the 31st International Conference on Software Engineering, 2009. Google Scholar
  2. Sven Apel, Thomas Leich, Marko Rosenmüller, and Gunter Saake. Featurec++: on the symbiosis of feature-oriented and aspect-oriented programming. In International Conference on Generative Programming and Component Engineering, 2005. Google Scholar
  3. Don Batory. Feature-oriented programming and the ahead tool suite. In Proceedings of the 26th International Conference on Software Engineering, 2004. Google Scholar
  4. Don Batory and Bart J. Geraci. Composition validation and subjectivity in genvoca generators. IEEE Transactions on Software Engineering, 23(2):67-82, 1997. Google Scholar
  5. Corrado Böhm and Alessandro Berarducci. Automatic synthesis of typed λ-programs on term algebras. Theoretical Computer Science, 39:135-154, 1985. Google Scholar
  6. Peter Buchlovsky and Hayo Thielecke. A type-theoretic reconstruction of the visitor pattern. Electronic Notes in Theoretical Computer Science, 155:309-329, 2006. Google Scholar
  7. Jacques Carette, Oleg Kiselyov, and Chung-chieh Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming, 19(05):509-543, 2009. Google Scholar
  8. Alonzo Church. A set of postulates for the foundation of logic I. Annals of Mathematics, 33:346-366, 1932. Google Scholar
  9. Martin Churchill, Peter D. Mosses, and Paolo Torrini. Reusable components of semantic specifications. In Proceedings of the 13th International Conference on Modularity, 2014. Google Scholar
  10. Paul Clements and Linda Northrop. Software product lines. Addison-Wesley,, 2002. Google Scholar
  11. Mario Coppo, Mariangiola Dezani-Ciancaglini, and Betti Venneri. Functional characters of solvable terms. Mathematical Logic Quarterly, 27(2-6):45-58, 1981. Google Scholar
  12. Benjamin Delaware, Bruno C. d. S. Oliveira, and Tom Schrijvers. Meta-theory à la carte. In Proceedings of the 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 2013. Google Scholar
  13. Sven Efftinge and Markus Völter. oAW xText: A framework for textual DSLs. In Workshop on Modeling Symposium at Eclipse Summit, 2006. Google Scholar
  14. Sebastian Erdweg, Paolo G Giarrusso, and Tillmann Rendel. Language composition untangled. In Proceedings of the Twelfth Workshop on Language Descriptions, Tools, and Applications, 2012. Google Scholar
  15. Sebastian Erdweg, Tijs Van Der Storm, Markus Völter, Meinte Boersma, Remi Bosman, William R Cook, Albert Gerritsen, Angelo Hulshout, Steven Kelly, Alex Loh, et al. The state of the art in language workbenches. In International Conference on Software Language Engineering, 2013. Google Scholar
  16. Erik Ernst. Family polymorphism. In European Conference on Object-Oriented Programming, 2001. Google Scholar
  17. Rémi Forax, Etienne Duris, and Gilles Roussel. Reflection-based implementation of java extensions: the double-dispatch use-case. In Proceedings of the 2005 ACM symposium on Applied computing, 2005. Google Scholar
  18. Martin Fowler. Language workbenches: The killer-app for domain specific languages, 2005. http://martinfowler.com/articles/languageWorkbench.html. Google Scholar
  19. Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns : Elements of Reusable Object-Oriented Software. Addisson-Wesley, 1994. Google Scholar
  20. Maria Gouseti, Chiel Peters, and Tijs van der Storm. Extensible language implementation with object algebras. In Proceedings of the 2014 International Conference on Generative Programming: Concepts and Experiences, 2014. Google Scholar
  21. Christian Grothoff. Walkabout revisited: The runabout. In European Conference on Object-Oriented Programming, 2003. Google Scholar
  22. Robert Heim, Pedram Mir Seyed Nazari, Bernhard Rumpe, and Andreas Wortmann. Compositional language engineering using generated, extensible, static type-safe visitors. In European Conference on Modelling Foundations and Applications, 2016. Google Scholar
  23. Ralf Hinze. Generics for the masses. Journal of Functional Programming, 16(4-5), 2006. Google Scholar
  24. Christian Hofer and Klaus Ostermann. Modular domain-specific language components in scala. In Proceedings of the 9th International Conference on Generative Programming and Component Engineering, 2010. Google Scholar
  25. Christian Hofer, Klaus Ostermann, Tillmann Rendel, and Adriaan Moors. Polymorphic embedding of dsls. In Proceedings of the 7th international conference on Generative programming and component engineering, 2008. Google Scholar
  26. Graham Hutton. A tutorial on the universality and expressiveness of fold. Journal of Functional Programming, 9(4):355-372, 1999. Google Scholar
  27. Pablo Inostroza and Tijs van der Storm. Modular interpreters for the masses. In Proceedings of the 2015 International Conference on Generative Programming: Concepts and Experiences, 2015. Google Scholar
  28. Christian Kästner, Sven Apel, and Klaus Ostermann. The road to feature modularity? In Proceedings of the 15th International Software Product Line Conference, Volume 2, 2011. Google Scholar
  29. Lennart C.L. Kats and Eelco Visser. The spoofax language workbench: Rules for declarative specification of languages and ides. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications, 2010. Google Scholar
  30. Paul Klint. A meta-environment for generating programming environments. ACM Transactions on Software Engineering and Methodology (TOSEM), 1993. Google Scholar
  31. Shriram Krishnamurthi, Matthias Felleisen, and Daniel P Friedman. Synthesizing object-oriented and functional design to promote re-use. In Proceedings of the 12th European Conference on Object-Oriented Programming, 1998. Google Scholar
  32. Ralf Lämmel, Joost Visser, and Jan Kort. Dealing with large bananas. In Johan Jeuring, editor, Workshop on Generic Programming, Ponte de Lima, July 2000. Technical Report UU-CS-2000-19, Universiteit Utrecht. Google Scholar
  33. Roberto E Lopez-Herrejon, Don Batory, and William Cook. Evaluating support for features in advanced modularization technologies. In European Conference on Object-Oriented Programming, 2005. Google Scholar
  34. Nax Paul Mendler. Inductive types and type constraints in the second-order lambda calculus. Annals of pure and Applied logic, 51(1-2):159-172, 1991. Google Scholar
  35. Peter D Mosses. Modular structural operational semantics. The Journal of Logic and Algebraic Programming, 60:195-228, 2004. Google Scholar
  36. Peter D Mosses. Component-based semantics. In Proceedings of the 8th international workshop on Specification and verification of component-based systems, 2009. Google Scholar
  37. Peter D. Mosses and Mark J. New. Implicit propagation in structural operational semantics. Electronic Notes in Theoretical Computer Science, 229(4):49-66, August 2009. Google Scholar
  38. Martin E Nordberg III. Variations on the visitor pattern. Ann Arbor, 1996. Google Scholar
  39. Martin Odersky and Matthias Zenger. Independently extensible solutions to the expression problem. In The 12th International Workshop on Foundations of Object-Oriented Languages, 2005. Google Scholar
  40. Bruno C. d. S. Oliveira. Modular visitor components. In Proceedings of the 23rd European Conference on Object-Oriented Programming, 2009. Google Scholar
  41. Bruno C. d. S. Oliveira and William R. Cook. Extensibility for the masses: Practical extensibility with object algebras. In Proceedings of the 26th European Conference on Object-Oriented Programming, 2012. Google Scholar
  42. Bruno C. d. S. Oliveira, Ralf Hinze, and Andres Löh. Extensible and modular generics for the masses. Trends in Functional Programming, 7:199-216, 2006. Google Scholar
  43. Bruno C. d. S. Oliveira, Tijs van der Storm, Alex Loh, and William R. Cook. Feature-oriented programming with object algebras. In Proceedings of the 27th European Conference on Object-Oriented Programming, 2013. Google Scholar
  44. Bruno C. d. S. Oliveira, Meng Wang, and Jeremy Gibbons. The visitor pattern as a reusable, generic, type-safe component. In Proceedings of the 2008 ACM International Conference on Object Oriented Programming Systems Languages and Applications, 2008. Google Scholar
  45. Jens Palsberg and C. Barry Jay. The essence of the visitor pattern. In Proceedings of the 22nd International Computer Software and Applications Conference, 1998. Google Scholar
  46. Michel Parigot. Recursive programming with proofs. Theoretical Computer Science, 94(2):335-356, 1992. Google Scholar
  47. Benjamin C Pierce. Types and programming languages. MIT press, 2002. Google Scholar
  48. Garrel Pottinger. A type assignment for the strongly normalizable λ-terms. To HB Curry: essays on combinatory logic, lambda calculus and formalism, pages 561-577, 1980. Google Scholar
  49. Casper Bach Poulsen and Peter D Mosses. Generating specialized interpreters for modular structural operational semantics. In International Symposium on Logic-Based Program Synthesis and Transformation, 2013. Google Scholar
  50. Tillmann Rendel, Jonathan Immanuel Brachthäuser, and Klaus Ostermann. From object algebras to attribute grammars. In Proceedings of the 2014 ACM International Conference on Object-Oriented Programming Systems Languages and Applications, 2014. Google Scholar
  51. John C Reynolds. The coherence of languages with intersection types. In International Symposium on Theoretical Aspects of Computer Software, 1991. Google Scholar
  52. Wouter Swierstra. Data types à la carte. Journal of functional programming, 18(04):423-436, 2008. Google Scholar
  53. Mads Torgersen. The expression problem revisited - four new solutions using generics. In Proceedings of the 18th European Conference on Object-Oriented Programming, 2004. Google Scholar
  54. Edoardo Vacchi and Walter Cazzola. Neverlang: A framework for feature-oriented language development. Computer Languages, Systems &Structures, 43:1-40, 2015. Google Scholar
  55. Vlad Vergu, Pierre Neron, and Eelco Visser. Dynsem: A dsl for dynamic semantics specification. In 26th International Conference on Rewriting Techniques and Applications, 2015. Google Scholar
  56. Eelco Visser. Stratego: A language for program transformation based on rewriting strategies system description of stratego 0.5. In International Conference on Rewriting Techniques and Applications, 2001. Google Scholar
  57. Joost Visser. Visitor combination and traversal control. In Proceedings of the 2001 ACM International Conference on Object-Oriented Programming Systems Languages and Applications, 2001. Google Scholar
  58. John Vlissides. Visitor in frameworks. C++ Report, 11(10):40-46, 1999. Google Scholar
  59. Philip Wadler. The Expression Problem. Email, November 1998. Discussion on the Java Genericity mailing list. Google Scholar
  60. Yanlin Wang and Bruno C. d. S. Oliveira. The expression problem, trivially! In Proceedings of the 15th International Conference on Modularity, 2016. Google Scholar
  61. Yanlin Wang, Haoyuan Zhang, Bruno C d S Oliveira, and Marco Servetto. Classless java. In Proceedings of the 2016 ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences, 2016. Google Scholar
  62. Haoyuan Zhang, Zewei Chu, Bruno C. d. S. Oliveira, and Tijs van der Storm. Scrap your boilerplate with object algebras. In Proceedings of the 2015 ACM International Conference on Object-Oriented Programming Systems Languages and Applications, 2015. Google Scholar
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail