skip to main content
research-article

Almost first-class language embedding: taming staged embedded DSLs

Published:26 October 2015Publication History
Skip Abstract Section

Abstract

Embedded domain-specific languages (EDSLs), inheriting a general-purpose language's features as well as look-and-feel, have traditionally been second-class or rather non-citizens in terms of host-language design. This makes sense when one regards them to be on the same level as traditional, non-EDSL library interfaces. However, this equivalence only applies to the simplest of EDSLs. In this paper we illustrate why this is detrimental when moving on to EDSLs that employ staging, i.e. program reification, by example of various issues that affect authors and users alike. We believe that if EDSLs are to be considered a reliable, language-like interface abstraction, they require exceptional attention and design scrutiny. Instead of unenforceable conventions, we advocate the acceptance of EDSLs as proper, i.e. almost first-class, citizens while retaining most advantages of pure embeddings. As a small step towards this goal, we present a pragmatic framework prototype for Java. It is based on annotations that explicate and document membership to explicit EDSL entities. In a nutshell, our framework identifies (annotated) method calls and field accesses as EDSL terms and dynamically constructs an abstract-syntax representation, which is eventually passed to a semantics-defining back end implemented by the EDSL author.

References

  1. https://github.com/google/guava (2015-06-09).Google ScholarGoogle Scholar
  2. O. S. Bagge, K. T. Kalleberg, M. Haveraaen, and E. Visser. Design of the CodeBoost Transformation System for Domain-Specific Optimisation of C++ Programs. In D. Binkley and P. Tonella, editors, Third International Workshop on Source Code Analysis and Manipulation (SCAM 2003), pages 65–75, Amsterdam, The Netherlands, Sept. 2003. IEEE Computer Society Press.Google ScholarGoogle Scholar
  3. D. Batory, B. Lofaso, and Y. Smaragdakis. JTS: Tools for Implementing Domain-Specific Languages. In Proceedings of the 5th International Conference on Software Reuse, ICSR ’98, pages 143–153, Washington, DC, USA, 1998. IEEE Computer Society. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J. Bloch. Effective Java (2Nd Edition) (The Java Series). Prentice Hall PTR, Upper Saddle River, NJ, USA, 2 edition, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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
  6. S. Chiba. Load-Time Structural Reflection in Java. In E. Bertino, editor, ECOOP 2000 — Object-Oriented Programming, volume 1850 of Lecture Notes in Computer Science, pages 313–336. Springer Berlin Heidelberg, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. K. Czarnecki, J. T. O’Donnell, J. Striegnitz, and W. Taha. DSL implementation in MetaOCaml. In C. Lengauer, D. Batory, C. Consel, and M. Odersky, editors, Domain-Specific Program Generation, volume 3016 of Lecture Notes in Computer Science, pages 51–72. Springer Berlin Heidelberg, 2004.Google ScholarGoogle Scholar
  8. C. Elliott, S. Finne, and O. De Moor. Compiling Embedded Languages. J. Funct. Program., 13(3):455–481, May 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. M. Fowler. Domain Specific Languages. Addison-Wesley Professional, 1st edition, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. S. Freeman and N. Pryce. Evolving an Embedded Domain-specific Language in Java. In Companion to the 21st ACM SIGPLAN Symposium on Object-oriented Programming Systems, Languages, and Applications, OOPSLA ’06, pages 855–865, New York, NY, USA, 2006. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. P. G. Giarrusso, K. Ostermann, M. Eichberg, R. Mitschke, T. Rendel, and C. Kästner. Reify Your Collection Queries for Modularity and Speed! In Proceedings of the 12th Annual International Conference on Aspect-oriented Software Development, AOSD ’13, pages 1–12, New York, NY, USA, 2013. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J. Gibbons and N. Wu. Folding Domain-specific Languages: Deep and Shallow Embeddings. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming, ICFP ’14, pages 339–347, New York, NY, USA, 2014. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. P. Graham. On Lisp: Advanced Techniques for Common Lisp. Prentice-Hall, Inc., Upper Saddle River, NJ, USA, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. S. Guyer and C. Lin. Broadway: A Compiler for Exploiting the Domain-Specific Semantics of Software Libraries. Proceedings of the IEEE, 93(2):342–357, Feb. 2005.Google ScholarGoogle ScholarCross RefCross Ref
  16. P. Hudak. Modular Domain Specific Languages and Tools. In Proceedings of the 5th International Conference on Software Reuse, ICSR ’98, pages 134–142, Washington, DC, USA, 1998. IEEE Computer Society. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. G. Hutton. Programming in Haskell. Cambridge University Press, Jan. 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. K. Ichikawa and S. Chiba. Composable User-defined Operators That Can Express User-defined Literals. In Proceedings of the 13th International Conference on Modularity, MODULARITY ’14, pages 13–24, New York, NY, USA, 2014. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. V. Jovanovic, A. Shaikhha, S. Stucki, V. Nikolaev, C. Koch, and M. Odersky. Yin-Yang: Concealing the Deep Embedding of DSLs. In Proceedings of the 2014 International Conference on Generative Programming: Concepts and Experiences, GPCE 2014, pages 73–82, New York, NY, USA, 2014. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. G. A. Kildall. A Unified Approach to Global Program Optimization. In Proceedings of the 1st Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL ’73, pages 194–206, New York, NY, USA, 1973. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. C. Omar, D. Kurilova, L. Nistor, B. Chung, A. Potanin, and J. Aldrich. Safely Composable Type-Specific Languages. In R. Jones, editor, ECOOP 2014 - Object-Oriented Programming, volume 8586 of Lecture Notes in Computer Science, pages 105–130. Springer Berlin Heidelberg, 2014.Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. T. Rompf, N. Amin, A. Moors, P. Haller, and M. Odersky. Scala-Virtualized: linguistic reuse for deep embeddings. Higher-Order and Symbolic Computation, 25(1):165–207, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. T. Rompf, K. J. Brown, H. Lee, A. K. Sujeeth, M. Jonnalagedda, N. Amin, G. Ofenbeck, A. Stojanov, Y. Klonatos, M. Dashti, C. Koch, M. Püschel, and K. Olukotun. Go Meta! A Case for Generative Programming and DSLs in Performance Critical Systems. In T. Ball, R. Bodik, S. Krishnamurthi, B. S. Lerner, and G. Morrisett, editors, 1st Summit on Advances in Programming Languages (SNAPL 2015), volume 32 of Leibniz International Proceedings in Informatics (LIPIcs), pages 238–261, Dagstuhl, Germany, 2015. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik.Google ScholarGoogle Scholar
  24. T. Rompf and M. Odersky. Lightweight Modular Staging: A Pragmatic Approach to Runtime Code Generation and Compiled DSLs. In Proceedings of the Ninth International Conference on Generative Programming and Component Engineering, GPCE ’10, pages 127–136, New York, NY, USA, 2010. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. T. Rompf, A. K. Sujeeth, K. J. Brown, H. Lee, H. Chafi, and K. Olukotun. Surgical Precision JIT Compilers. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’14, pages 41–52, New York, NY, USA, 2014. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. T. Rompf, A. K. Sujeeth, H. Lee, K. J. Brown, H. Chafi, M. Odersky, and K. Olukotun. Building-Blocks for Performance Oriented DSLs. In Proceedings IFIP Working Conference on Domain-Specific Languages, DSL 2011, Bordeaux, France, 6-8th September 2011.Google ScholarGoogle ScholarCross RefCross Ref
  27. , pages 93–117, 2011.Google ScholarGoogle Scholar
  28. M. Scherr and S. Chiba. Implicit Staging of EDSL Expressions: A Bridge between Shallow and Deep Embedding. In R. Jones, editor, ECOOP 2014 – Object-Oriented Programming, volume 8586 of Lecture Notes in Computer Science, pages 385–410. Springer Berlin Heidelberg, 2014.Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. T. Sheard and S. P. Jones. Template Meta-programming for Haskell. SIGPLAN Not., 37(12):60–75, Dec. 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. Svenningsson and E. Axelsson. Combining Deep and Shallow Embedding for EDSL. In H.-W. Loidl and R. Peña, editors, Trends in Functional Programming, volume 7829 of Lecture Notes in Computer Science, pages 21–36. Springer Berlin Heidelberg, 2013.Google ScholarGoogle Scholar
  31. W. Taha and T. Sheard. MetaML and Multi-stage Programming with Explicit Annotations. Theor. Comput. Sci., 248(1-2):211–242, Oct. 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. W. M. Taha. Multistage Programming: Its Theory and Applications. PhD thesis, 1999. AAI9949870. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. L. Tratt. Domain Specific Language Implementation via Compile-Time Meta-Programming. TOPLAS, 30(6):1–40, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. E. Westbrook, M. Ricken, J. Inoue, Y. Yao, T. Abdelatif, and W. Taha. Mint: Java Multi-stage Programming Using Weak Separability. In Proceedings of the 2010 ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’10, pages 400–411, New York, NY, USA, 2010. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. H. Xu. EriLex: An Embedded Domain Specific Language Generator. In J. Vitek, editor, Objects, Models, Components, Patterns, volume 6141 of Lecture Notes in Computer Science, pages 192–212. Springer Berlin Heidelberg, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Almost first-class language embedding: taming staged embedded DSLs

    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

    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!