Abstract
Embedded domain specific languages (EDSLs) are used to represent special-purpose code in a general-purpose language and they are used for applications like vector calculations and run-time code generation. Often, code in an EDSL is compiled to a target (e.g. GPU languages, JVM bytecode, assembly, JavaScript) and needs to interface with other code that is available at that level but uses other data representations or calling conventions. We present an approach for safely making available such APIs in a typed EDSL, guaranteeing correct conversions between data representations and the respect for calling conventions. When the code being interfaced with is the result of static compilation of host language code, we propose a way to auto-generate the needed boilerplate using meta-programming. We instantiate our technique with JavaScript as the target language, JS-Scala as the EDSL, Scala.js as the static compiler and Scala macros to generate the boilerplate, but our design is more generally applicable. We provide evidence of usefulness of our approach through a prototype implementation that we have applied in a non-trivial code base.
- M. Blume. No-Longer-Foreign: Teaching an ML compiler to speak C “natively”. ENTCS, pages 36–52, 2001.Google Scholar
- M. M. T. Chakravarty. C → HASKELL, or Yet Another Interfacing Tool. In IFL, pages 131–148. Springer-Verlag, 2000. Google Scholar
Digital Library
- S. Doeraene. Scala.js: Type-Directed Interoperability with Dynamically Typed Languages. Technical Report EPFL-REPORT-190834, EPFL, 2013.Google Scholar
- Google. Google web toolkit. online, 2006. URL http://gwtproject.org/. G. Kossakowski, N. Amin, T. Rompf, and M. Odersky. JavaScript as an embedded DSL. In ECOOP, pages 409–434. Springer-Verlag, 2012. Google Scholar
Digital Library
- Microsoft. Typescript. online, 2012. URL http://www.typescriptlang.org/. B. Reynders, D. Devriese, and F. Piessens. Multi-Tier Functional Reactive Programming for the Web. In Onward!, pages 55–68. ACM, 2014. Google Scholar
Digital Library
- T. Rompf and M. Odersky. Lightweight modular staging: A pragmatic approach to runtime code generation and compiled DSLs. In GPCE, pages 127–136. ACM, 2010. Google Scholar
Digital Library
- Introduction Safe Boundary APIs Transformation Case Study: MT-FRP in Scala Future Work Related WorkGoogle Scholar
Index Terms
Generating safe boundary APIs between typed EDSLs and their environments
Recommendations
Generating safe boundary APIs between typed EDSLs and their environments
GPCE 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesEmbedded domain specific languages (EDSLs) are used to represent special-purpose code in a general-purpose language and they are used for applications like vector calculations and run-time code generation. Often, code in an EDSL is compiled to a target ...
Expressive and strongly type-safe code generation
PPDP '17: Proceedings of the 19th International Symposium on Principles and Practice of Declarative ProgrammingMeta-programs are programs that generate other programs, but in weakly type-safe systems, type-checking a meta-program only establishes its own type safety, and generated programs need additional type-checking after generation. Strong type safety of a ...
LibDSL: a library for developing embedded domain specific languages in d via template metaprogramming
GPCE '14This paper presents a library called LibDSL that helps the implementer of an embedded domain specific language (EDSL) effectively develop it in D language. The LibDSL library accepts as input some kinds of ``specifications'' of the EDSL that the ...






Comments