skip to main content
10.1145/2661136.2661140acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Multi-Tier Functional Reactive Programming for the Web

Published:14 October 2014Publication History

ABSTRACT

The development of robust and efficient interactive web applications is challenging, because developers have to deal with multiple programming languages, asynchronous events, propagating data and events between clients and servers, data consistency and much more. Several approaches for (partly) addressing these challenges have been proposed. Two relevant ones are (1) multi-tier languages and (2) functional reactive programming (FRP). Multi-tier programming languages support the development of client and server in a single language, and hide much of the complexity related to distribution. FRP offers the right abstractions to make event-driven programming convenient, safe and composable. However, existing web frameworks and programming languages exploit the benefits of both approaches separately, for example by restricting the use of FRP to the client side.

We propose multi-tier FRP for the Web, a novel approach to writing web applications that deeply integrates FRP and multi-tier languages, and where the whole is greater than the sum of its parts. In multi-tier FRP, the developer programs server and client together as an FRP application composed of behaviors (signals) and events. He/she chooses explicitly where the boundary between server and client is crossed. To make our approach more concrete and provide evidence of its potential, this paper presents a concrete design and implementation of a multi-tier FRP API for the web in the programming language Scala, using an embedded JavaScript DSL that makes Scala usable as a multi-tier language. This allows us to present initial evidence of the benefits of the multi-tier FRP approach on example applications, and to experiment with possible answers to the remaining questions. Concretely, we show possible solutions for problems like exposing client identity on the server and efficiently pre-loading clients with the latest application state. Our results show that multi-tier FRP is a promising, declarative, yet practical way of writing web applications.

References

  1. E. Bainomugisha, A. L. Carreton, T. Van Cutsem, S. Mostinckx, and W. De Meuter. A survey on reactive programming. ACM Computing Surveys, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. G. Bazerman. Hackage: jmacro: Quasiquotation library for programmatic generation of Javascript code. http://hackage.haskell.org/package/jmacro-0.1, 2009. (Visited on 3/19/2014).Google ScholarGoogle Scholar
  3. G. Bazerman. Hackage: jmacro-rpc: JSON-RPC clients and servers using JMacro, and evented client-server FRP. http://hackage.haskell.org/package/jmacro-rpc-0.2, 2012. (Visited on 03/19/2014).Google ScholarGoogle Scholar
  4. J. Bracker and A. Gill. Sunroof: A monadic DSL for generating JavaScript. In PADL, volume 8324 of LNCS, pages 65--80. Springer International Publishing, 2014.Google ScholarGoogle Scholar
  5. A. L. Carreton, S. Mostinckx, T. Van Cutsem, and W. De Meuter. Loosely-coupled distributed reactive programming in mobile ad hoc networks. In ICT, pages 41--60. Springer, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. A. Chlipala. The Ur/Web programming language family. online, 2013. URL http://impredicative.com/ur/.Google ScholarGoogle Scholar
  7. E. Cooper, S. Lindley, P. Wadler, and J. Yallop. Links: Web programming without tiers. In FMCO, volume 4709 of LNCS, pages 266--296. Springer Berlin Heidelberg, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. E. Czaplicki. Elm: Concurrent FRP for functional GUIs. Master's thesis, Harvard, 2012.Google ScholarGoogle Scholar
  9. E. Czaplicki and S. Chong. Asynchronous functional reactive programming for GUIs. In PLDI, pages 411--422. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. S. Doeraene. Scala.js: Type-directed interoperability with dynamically typed languages. Technical Report EPFL-REPORT-190834, EPFL, 2013.Google ScholarGoogle Scholar
  11. C. Elliott. Push-pull functional reactive programming. In Haskell Symposium, pages 25--36. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. C. Elliott and P. Hudak. Functional reactive animation. In ICFP, pages 263--273. ACM, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Facebook. React - a JavaScript library for building user interfaces. http://facebook.github.io/react/, 2013. (Visited on 03/19/2014).Google ScholarGoogle Scholar
  14. Google. Google web toolkit. online, 2006. URL http://www.gwtproject.org/.Google ScholarGoogle Scholar
  15. Google. AngularJS superheroic JavaScript MVW framework. http://angularjs.org/, 2010. (Visited on 03/19/2014).Google ScholarGoogle Scholar
  16. N. Gugenheim. reactive-web. http://scalareactive.org/, 2011. (Visited on 03/19/2014).Google ScholarGoogle Scholar
  17. A. Guha, C. Saftoiu, and S. Krishnamurthi. The essence of JavaScript. In ECOOP, pages 126--150. Springer, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. A. Jeffrey. Functional reactive programming with liveness guarantees. In ICFP, pages 233--244. ACM, 2013. . Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. G. Kossakowski, N. Amin, T. Rompf, and M. Odersky. JavaScript as an embedded DSL. In ECOOP, pages 409--434. Springer-Verlag, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. J. Liberty and P. Betts. Reactive extensions for JavaScript. In Programming Reactive Extensions and LINQ, pages 111--124. Springer, 2011.Google ScholarGoogle ScholarCross RefCross Ref
  21. I. Maier and M. Odersky. Higher-order reactive programming with incremental lists. In ECOOP, pages 707--731. Springer, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. A. Margara and G. Salvaneschi. We have a DREAM: distributed reactive programming with consistency guarantees. In ICDES, pages 142--153. ACM, 2014. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. E. Meijer. Reactive extensions (Rx): curing your asynchronous programming blues. In CUFP, page 11. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. L. A. Meyerovich, A. Guha, J. Baskin, G. H. Cooper, M. Greenberg, A. Bromfield, and S. Krishnamurthi. Flapjax: A programming language for Ajax applications. In OOPSLA, pages 1--20. ACM, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. A. Milicevic, D. Jackson, M. Gligoric, and D. Marinov. Model-based, event-driven programming paradigm for interactive web applications. In Onward!, pages 17--36. ACM, 2013. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. B. Mizerany. Sinatra. http://www.sinatrarb.com/, 2007. (Visited on 03/19/2014).Google ScholarGoogle Scholar
  27. MLstate. The Opa framework for JavaScript. http://opalang.org/, 2007. (Visited on 03/19/2014).Google ScholarGoogle Scholar
  28. M. Neubauer and P. Thiemann. From sequential programs to multi-tier applications by program transformation. In POPL, pages 221--232. ACM, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. B. C. Oliveira, A. Moors, and M. Odersky. Type classes as objects and implicits. In OOPSLA, pages 341--360. ACM, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. Paananen. baconjs/bacon.js. https://github.com/baconjs/bacon.js, 2012. (Visited on 03/19/2014).Google ScholarGoogle Scholar
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. J. Rudolph and M. Doenitz. spray - REST/HTTP for your Akka/Scala actors. http://spray.io/, 2012. (Visited on 03/19/2014).Google ScholarGoogle Scholar
  33. G. Salvaneschi, J. Drechsler, and M. Mezini. Towards distributed reactive programming. In ICC, pages 226--235. Springer, 2013.Google ScholarGoogle ScholarCross RefCross Ref
  34. G. Schmidt, M. DeBergalis, and N. Martin. Meteor. https://www.meteor.com/, 2011. (Visited on 03/19/2014).Google ScholarGoogle Scholar
  35. M. Serrano and C. Queinnec. A multi-tier semantics for Hop. Higher-Order & Symbolic Computation, 23(4):409--431, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. M. Serrano, E. Gallesio, and F. Loitsch. Hop: a language for programming the web 2.0. In OOPSLA Companion, pages 975--985, 2006.Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. F. Yang, J. Shanmugasundaram, M. Riedewald, and J. Gehrke. Hilda: A high-level language for data-drivenweb applications. In ICDE, pages 32--32, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Multi-Tier Functional Reactive Programming for the Web

        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
        • Published in

          cover image ACM Conferences
          Onward! 2014: Proceedings of the 2014 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software
          October 2014
          332 pages
          ISBN:9781450332101
          DOI:10.1145/2661136

          Copyright © 2014 ACM

          Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 14 October 2014

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article

          Acceptance Rates

          Onward! 2014 Paper Acceptance Rate16of35submissions,46%Overall Acceptance Rate40of105submissions,38%

          Upcoming Conference

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader