skip to main content
research-article

An optimizing compiler for a purely functional web-application language

Published:29 August 2015Publication History
Skip Abstract Section

Abstract

High-level scripting languages have become tremendously popular for development of dynamic Web applications. Many programmers appreciate the productivity benefits of automatic storage management, freedom from verbose type annotations, and so on. While it is often possible to improve performance substantially by rewriting an application in C or a similar language, very few programmers bother to do so, because of the consequences for human development effort. This paper describes a compiler that makes it possible to have most of the best of both worlds, coding Web applications in a high-level language but compiling to native code with performance comparable to handwritten C code. The source language is Ur/Web, a domain-specific, purely functional, statically typed language for the Web. Through a coordinated suite of relatively straightforward program analyses and algebraic optimizations, we transform Ur/Web programs into almost-idiomatic C code, with no garbage collection, little unnecessary memory allocation for intermediate values, etc. Our compiler is in production use for commercial Web sites supporting thousands of users, and microbenchmarks demonstrate very competitive performance versus mainstream tools.

References

  1. V. Balat. Ocsigen: typing Web interaction with Objective Caml. In Proc. ML Workshop, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. V. Balat, J. Vouillon, and B. Yakobowski. Experience report: Ocsigen, a Web programming framework. In Proc. ICFP, pages 311–316. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. H. Cejtin, S. Jagannathan, and S. Weeks. Flow-directed closure conversion for typed languages. In Proc. ESOP, pages 56–71. Springer-Verlag, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. J. Cheney, S. Lindley, and P. Wadler. A practical theory of languageintegrated query. In Proc. ICFP, pages 403–416. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. A. Chlipala. Ur: Statically-typed metaprogramming with type-level record computation. In Proc. PLDI, pages 122–133. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. A. Chlipala. Ur/Web: A simple model for programming the Web. In Proc. POPL, pages 153–165. ACM, 2015. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. E. Cooper, S. Lindley, P. Wadler, and J. Yallop. Links: Web programming without tiers. In Proc. FMCO, pages 266–296, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. D. Coutts, R. Leshchinskiy, and D. Stewart. Stream fusion: From lists to streams to nothing at all. In Proc. ICFP, pages 315–326. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. S. Ducasse, A. Lienhard, and L. Renggli. Seaside – a multiple control flow Web application framework. In European Smalltalk User Group – Research Track, 2004.Google ScholarGoogle Scholar
  10. C. Elliott and P. Hudak. Functional reactive animation. In Proc. ICFP, pages 263–273, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Elsman and N. Hallenberg. Web programming with SMLserver. In Proc. PADL, pages 74–91. Springer-Verlag, January 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. M. Fluet and S. Weeks. Contification using dominators. In Proc. ICFP, pages 2–13. ACM, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. J. Garrigue. Code reuse through polymorphic variants. In Proc. Workshop on Foundations of Software Engineering, 2000.Google ScholarGoogle Scholar
  14. S. Krishnamurthi, P. W. Hopkins, J. McCarthy, P. T. Graunke, G. Pettyjohn, and M. Felleisen. Implementation and use of the PLT Scheme Web Server. Higher Order Symbol. Comput., 20(4):431–460, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. F. Loitsch and M. Serrano. Hop client-side compilation. In Proc. TFL, 2007.Google ScholarGoogle Scholar
  16. D. MacQueen. Modules for Standard ML. In Proc. LFP, pages 198– 207. ACM, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. S. Peyton Jones. Call-pattern specialisation for Haskell programs. In Proc. ICFP, pages 327–337. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. S. L. Peyton Jones and D. Lester. A modular fully-lazy lambda lifter in Haskell. Softw. Pract. Exper., 21(5):479–506, May 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. S. L. Peyton Jones and A. L. M. Santos. A transformation-based optimiser for Haskell. Sci. Comput. Program., 32(1-3):3–47, Sept. 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S. L. Peyton Jones and P. Wadler. Imperative functional programming. In Proc. POPL, pages 71–84. ACM, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. B. C. Pierce. Higher-order polymorphism. In Types and Programming Languages, chapter 30. MIT Press, 2002.Google ScholarGoogle Scholar
  22. J. C. Reynolds. Types, abstraction and parametric polymorphism. In IFIP Congress, pages 513–523, 1983.Google ScholarGoogle Scholar
  23. M. Serrano. Hop, a fast server for the diffuse web. In Proc. COORDINATION, pages 1–26. Springer-Verlag, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. M. Serrano, E. Gallesio, and F. Loitsch. Hop, a language for programming the Web 2.0. In Proc. DLS, 2006.Google ScholarGoogle Scholar
  25. M. Tofte and J.-P. Talpin. Region-based memory management. Inf. Comput., 132(2):109–176, Feb. 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. P. Wadler. Deforestation: Transforming programs to eliminate trees. In Proc. ESOP, pages 344–358. Springer-Verlag, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. P. Wadler and S. Blott. How to make ad-hoc polymorphism less ad hoc. In Proc. POPL, pages 60–76. ACM, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. M. Wand. Type inference for record concatenation and multiple inheritance. Information and Computation, 93(1), 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. S. Weeks. Whole-program compilation in MLton. In Proc. ML Workshop, pages 1–1. ACM, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. L. Ziarek, S. Weeks, and S. Jagannathan. Flattening tuples in an SSA intermediate representation. Higher Order Symbol. Comput., 21(3): 333–358, Sept. 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. An optimizing compiler for a purely functional web-application language

      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

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 50, Issue 9
        ICFP '15
        September 2015
        436 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2858949
        • Editor:
        • Andy Gill
        Issue’s Table of Contents
        • cover image ACM Conferences
          ICFP 2015: Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming
          August 2015
          436 pages
          ISBN:9781450336697
          DOI:10.1145/2784731

        Copyright © 2015 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 29 August 2015

        Check for updates

        Qualifiers

        • research-article

      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!