Multi-Tier Functional Reactive Programming for the Web

Multi-Tier Functional Reactive Programming for the Web
复制标题

Web 的多层函数响应式编程

DOI:
10.1145/2661136.2661140
复制
发表时间:
2014
期刊:
Proceedings of the 2014 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software
影响因子:
--
通讯作者:
Frank Piessens
Frank Piessens
中科院分区:
--
文献类型:
--
作者:
Bob Reynders;Dominique Devriese;Frank Piessens

文献摘要

被引文献

相似文献

开发健壮而高效的交互式Web应用程序是具有挑战性的,因为开发人员必须处理多种编程语言、异步事件、在客户端和服务器之间传播数据和事件、数据一致性等等。已经提出了几种(部分)应对这些挑战的方法。两个相关的是(1)多层语言和(2)函数反应式编程(FRP)。多层编程语言支持使用单一语言开发客户端和服务器,并隐藏了与分发相关的大部分复杂性。FRP提供了正确的抽象,使事件驱动编程变得方便、安全和可组合。然而,现有的Web框架和编程语言分别利用了这两种方法的好处,例如,通过将FRP的使用限制在客户端。我们提出了一种用于Web的多层FRP,这是一种深度集成FRP和多层语言的Web应用程序编写新方法,其中整体大于部分之和。在多层FRP中,开发人员将服务器和客户端编程为由行为(信号)和事件组成的FRP应用程序。他/她明确选择在哪里跨越服务器和客户端之间的边界。为了使我们的方法更加具体,并为其潜力提供证据,本文给出了一个用编程语言Scala实现的多层FRP Web API的具体设计和实现,它使用了一个嵌入的JavaScript DSL,使Scala可以作为一种多层语言使用。这使我们能够提供多层FRP方法在示例应用程序上的好处的初步证据,并试验其余问题的可能答案。具体地说,我们展示了可能的解决方案,用于解决在服务器上暴露客户端身份以及高效地预加载客户端的最新应用程序状态等问题。我们的结果表明,多层FRP是一种很有前途的、声明性的、但实用的Web应用程序编写方法。
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.