Compiling Embedded Languages

  • Conal Elliott
  • Sigbjørn Finne
  • Oege de Moor
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 1924)


Functional languages are particularly well-suited to the im- plementation of interpreters for domain-specific embedded languages (DSELs). We describe an implemented technique for producing optimiz- ing compilers for DSELs, based on Kamin’s idea of DSELs for program generation. The technique uses a data type of syntax for basic types, a set of smart constructors that perform rewriting over those types, some code motion transformations, and a back-end code generator. Domain- specific optimization results from chains of rewrites on basic types. New DSELs are defined directly in terms of the basic syntactic types, plus host language functions and tuples. This definition style makes compil- ers easy to write and, in fact, almost identical to the simplest embedded interpreters. We illustrate this technique with a language Pan for the computationally intensive domain of image synthesis and manipulation.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Oege de Moor and Ganesh Sittampalam. Generic program transformation. In Proceedings of the third International Summer School on Advanced Functional Programming, Springer Lecture Notes in Computer Science, 1999. Scholar
  2. 2.
    Conal Elliott. A Pan image gallery.
  3. 3.
    Conal Elliott. An embedded modeling language approach to interactive 3D and multimedia animation. IEEE Transactions on Software Engineering, 25(3):291–308, May/June 1999. Special Section: Domain-Specific Languages (DSL). Scholar
  4. 4.
    Conal Elliott. Functional images, unpublished, March 2000.
  5. 5.
    Conal Elliott, Sigbjørn Finne, and Oege de Moor. Compiling embedded languages (extended version). Technical report, Microsoft Research, May 2000. ID=MSR-TR-2000-52.
  6. 6.
    Matteo Frigo. A fast Fourier transform compiler. In Proceedings of the ACM SIGPLAN’99 Conference on Programming Language Design and Implementation, pages 169–180, 1999.
  7. 7.
    John Hatcliff, Torben Mogensen, and Peter Thiemann, editors. Partial Evaluation: Practice and Theory, volume 1706. Springer-Verlag, 1999.Google Scholar
  8. 8.
    Paul Hudak. Modular domain specific languages and tools. In P. Devanbu and J. Poulin,editors, Proceedings: Fifth International Conference on Software Reuse, pages 134–142. IEEE Computer Society Press, 1998.Google Scholar
  9. 9.
    Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice Hall In-ternational, International Series in Computer Science, June 1993.
  10. 10.
    Samuel Kamin. Standard ML as a meta-programming language. Technical report, University of Illinois at Urbana-Champaign, September 1996. Scholar
  11. 11.
    Samuel Kamin and David Hyatt. A special-purpose language for picture-drawing. In USENIX, editor, Proceedings of the Conference on Domain-Specific Lan-guages, October 15–17, 1997, Santa Barbara, California, pages 297–310, 1997.
  12. 12.
    Peter J. Landin. The next 700 programming languages. Communications of the ACM, 9(3):157–164, March 1966. Originally presented at the Proceedings of the ACM Programming Language and Pragmatics Conference, August 8–12, 1965.MATHCrossRefGoogle Scholar
  13. 13.
    Daan Leijen and Erik Meijer. Domain specific embedded compilers. In 2nd Conference on Domain-Specific Languages (DSL), Austin TX, USA, October 1999. USENIX.
  14. 14.
    Walid Taha and Tim Sheard. MetaML and multi-stage programming with explicit annotations. Journal of Theoretical Computer Science, 2000. To appear.
  15. 15.
    GHC Team. The Glasgow Haskell compiler.
  16. 16.
    Todd Veldhuizen. Expression templates. C++ Report, 7(5):26–31, June 1995. Reprinted in C++ Gems, ed. Stanley Lippman.
  17. 17.
    Todd Veldhuizen. C++ templates as partial evaluation. In Workshop on Partial Evaluation and Semantics-Based Program Manipulation (PEPM’99). ACM Sigplan, 1999.

Copyright information

© Springer-Verlag Berlin Heidelberg 2000

Authors and Affiliations

  • Conal Elliott
    • 1
  • Sigbjørn Finne
    • 1
  • Oege de Moor
    • 2
  1. 1.Microsoft ResearchRedmondUSA
  2. 2.Oxford University Computing Laboratory Wolfson BuildingOxfordEngland

Personalised recommendations