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.
- E. Bainomugisha, A. L. Carreton, T. Van Cutsem, S. Mostinckx, and W. De Meuter. A survey on reactive programming. ACM Computing Surveys, 2012. Google ScholarDigital Library
- 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 Scholar
- 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 Scholar
- 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 Scholar
- 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 ScholarDigital Library
- A. Chlipala. The Ur/Web programming language family. online, 2013. URL http://impredicative.com/ur/.Google Scholar
- 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 ScholarDigital Library
- E. Czaplicki. Elm: Concurrent FRP for functional GUIs. Master's thesis, Harvard, 2012.Google Scholar
- E. Czaplicki and S. Chong. Asynchronous functional reactive programming for GUIs. In PLDI, pages 411--422. ACM, 2013. Google ScholarDigital Library
- S. Doeraene. Scala.js: Type-directed interoperability with dynamically typed languages. Technical Report EPFL-REPORT-190834, EPFL, 2013.Google Scholar
- C. Elliott. Push-pull functional reactive programming. In Haskell Symposium, pages 25--36. ACM, 2009. Google ScholarDigital Library
- C. Elliott and P. Hudak. Functional reactive animation. In ICFP, pages 263--273. ACM, 1997. Google ScholarDigital Library
- Facebook. React - a JavaScript library for building user interfaces. http://facebook.github.io/react/, 2013. (Visited on 03/19/2014).Google Scholar
- Google. Google web toolkit. online, 2006. URL http://www.gwtproject.org/.Google Scholar
- Google. AngularJS superheroic JavaScript MVW framework. http://angularjs.org/, 2010. (Visited on 03/19/2014).Google Scholar
- N. Gugenheim. reactive-web. http://scalareactive.org/, 2011. (Visited on 03/19/2014).Google Scholar
- A. Guha, C. Saftoiu, and S. Krishnamurthi. The essence of JavaScript. In ECOOP, pages 126--150. Springer, 2010. Google ScholarDigital Library
- A. Jeffrey. Functional reactive programming with liveness guarantees. In ICFP, pages 233--244. ACM, 2013. . Google ScholarDigital Library
- G. Kossakowski, N. Amin, T. Rompf, and M. Odersky. JavaScript as an embedded DSL. In ECOOP, pages 409--434. Springer-Verlag, 2012. Google ScholarDigital Library
- J. Liberty and P. Betts. Reactive extensions for JavaScript. In Programming Reactive Extensions and LINQ, pages 111--124. Springer, 2011.Google ScholarCross Ref
- I. Maier and M. Odersky. Higher-order reactive programming with incremental lists. In ECOOP, pages 707--731. Springer, 2013. Google ScholarDigital Library
- A. Margara and G. Salvaneschi. We have a DREAM: distributed reactive programming with consistency guarantees. In ICDES, pages 142--153. ACM, 2014. Google ScholarDigital Library
- E. Meijer. Reactive extensions (Rx): curing your asynchronous programming blues. In CUFP, page 11. ACM, 2010. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- B. Mizerany. Sinatra. http://www.sinatrarb.com/, 2007. (Visited on 03/19/2014).Google Scholar
- MLstate. The Opa framework for JavaScript. http://opalang.org/, 2007. (Visited on 03/19/2014).Google Scholar
- M. Neubauer and P. Thiemann. From sequential programs to multi-tier applications by program transformation. In POPL, pages 221--232. ACM, 2005. Google ScholarDigital Library
- B. C. Oliveira, A. Moors, and M. Odersky. Type classes as objects and implicits. In OOPSLA, pages 341--360. ACM, 2010. Google ScholarDigital Library
- J. Paananen. baconjs/bacon.js. https://github.com/baconjs/bacon.js, 2012. (Visited on 03/19/2014).Google Scholar
- 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 ScholarDigital Library
- J. Rudolph and M. Doenitz. spray - REST/HTTP for your Akka/Scala actors. http://spray.io/, 2012. (Visited on 03/19/2014).Google Scholar
- G. Salvaneschi, J. Drechsler, and M. Mezini. Towards distributed reactive programming. In ICC, pages 226--235. Springer, 2013.Google ScholarCross Ref
- G. Schmidt, M. DeBergalis, and N. Martin. Meteor. https://www.meteor.com/, 2011. (Visited on 03/19/2014).Google Scholar
- M. Serrano and C. Queinnec. A multi-tier semantics for Hop. Higher-Order & Symbolic Computation, 23(4):409--431, 2010. Google ScholarDigital Library
- M. Serrano, E. Gallesio, and F. Loitsch. Hop: a language for programming the web 2.0. In OOPSLA Companion, pages 975--985, 2006.Google ScholarDigital Library
- 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 ScholarDigital Library
Index Terms
- Multi-Tier Functional Reactive Programming for the Web
Recommendations
Functional reactive programming, refactored
Haskell '16Functional Reactive Programming (FRP) has come to mean many things. Yet, scratch the surface of the multitude of realisations, and there is great commonality between them. This paper investigates this commonality, turning it into a mathematically ...
Functional reactive programming, continued
Haskell '02: Proceedings of the 2002 ACM SIGPLAN workshop on HaskellFunctional Reactive Programming (FRP) extends a host programming language with a notion of time flow. Arrowized FRP (AFRP) is a version of FRP embedded in Haskell based on the arrow combinators. AFRP is a powerful synchronous dataflow programming ...
Monadic functional reactive programming
Haskell '13: Proceedings of the 2013 ACM SIGPLAN symposium on HaskellFunctional Reactive Programming (FRP) is a way to program reactive systems in functional style, eliminating many of the problems that arise from imperative techniques. In this paper, we present an alternative FRP formulation that is based on the notion ...
Comments