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.
- https://github.com/google/guava (2015-06-09).Google Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- J. Bloch. Effective Java (2Nd Edition) (The Java Series). Prentice Hall PTR, Upper Saddle River, NJ, USA, 2 edition, 2008. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- C. Elliott, S. Finne, and O. De Moor. Compiling Embedded Languages. J. Funct. Program., 13(3):455–481, May 2003. Google Scholar
Digital Library
- M. Fowler. Domain Specific Languages. Addison-Wesley Professional, 1st edition, 2010. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- P. Graham. On Lisp: Advanced Techniques for Common Lisp. Prentice-Hall, Inc., Upper Saddle River, NJ, USA, 1993. Google Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- G. Hutton. Programming in Haskell. Cambridge University Press, Jan. 2007. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- , pages 93–117, 2011.Google Scholar
- 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 Scholar
Digital Library
- T. Sheard and S. P. Jones. Template Meta-programming for Haskell. SIGPLAN Not., 37(12):60–75, Dec. 2002. Google Scholar
Digital Library
- 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 Scholar
- W. Taha and T. Sheard. MetaML and Multi-stage Programming with Explicit Annotations. Theor. Comput. Sci., 248(1-2):211–242, Oct. 2000. Google Scholar
Digital Library
- W. M. Taha. Multistage Programming: Its Theory and Applications. PhD thesis, 1999. AAI9949870. Google Scholar
Digital Library
- L. Tratt. Domain Specific Language Implementation via Compile-Time Meta-Programming. TOPLAS, 30(6):1–40, 2008. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Almost first-class language embedding: taming staged embedded DSLs
Recommendations
Almost first-class language embedding: taming staged embedded DSLs
GPCE 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesEmbedded 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 ...
CLOP: a multi-stage compiler to seamlessly embed heterogeneous code
GPCE 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesHeterogeneous programming complicates software development. We present CLOP, a platform that embeds code targeting heterogeneous compute devices in a convenient and clean way, allowing unobstructed data flow between the host code and the devices, ...
Backstage Java: making a difference in metaprogramming
OOPSLA '11: Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applicationsWe propose Backstage Java (BSJ), a Java language extension which allows algorithmic, contextually-aware generation and transformation of code. BSJ explicitly and concisely represents design patterns and other encodings by employing compile-time ...






Comments