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 preloading clients with the latest application state. Our results Permission to make digital show that multi-tier FRP is a promising, declarative, yet practical way of writing web applications.
Web applications are inherently distributed, and not just because their client and server counterparts run on networked systems. Web applications are written in multiple programming languages and as multiple programs: the server and client programs. In an effort to lower the complexity of the web, multi-tier programming was proposed. In multi-tier programming languages the language and its tooling give support to create web applications as a whole, one program is written in one language.Web applications are also inherently asynchronous. On the server, they constantly process several client requests and in the browser they constantly have to react to input, be it from the user or a server. A technique that can be applied to make such programs easier to understand is functional reactive programming. A functional programming model that models an interactive program as compositions between two primitives, behaviors and events.Developing web applications requires dealing with their distributed nature and the natural asynchronicity of user input and network communication. For facilitating this, different researchers have explored the combination of a multi-tier programming language and functional reactive programming. However, existing proposals take his approach only part of the way. Some parts of the application remain imperative, do not consider network traffic overhead of incremental data, compatibility with common APIs like XMLHttpRequest etc., or they do not consider glitches across network communication (or do but introduce locking or overhead)In this paper, we present Gavial: a design and practical implementation of multi-tier FRP that allows constructing a web application as a functionally reactive program. We propose a novel integration of existing techniques such as solutions to bootstrapping web applications, recursive behaviors for web interfaces, asynchronous FRP and incremental behaviors. As well as novel support for tiered glitch freedom, a compromise between performance and glitch-free evaluation of the distributed FRP program, and a three-tiered system suitable for request-response-style applications as well as user-to-user applications. Gavial automatically runs in request-response (XMLHttpRequest) mode or in websocket mode.After applying a number of old and new ideas to create a practical multi-tier FRP implementation in Gavial, we demonstrate it by building an example and show that it can in fact deal realistically with important practical aspects of building web applications. At the same time, we retain the declarative nature of FRP, where behaviors and events have an intuitive, compositional semantics and a clear dependency structure. ACM CCS 2012Listing 2 Delayed DBehavior object DBehavior { def delayed[A](db: ⇒ DBehavior[A]): Behavior[A] }Returning to CircleRoyale, a type Player represents a player's position, and whether he is alive, attacking or dead. The svg method produces the player's circle and optionally the attacking circle as SVG elements. case class Player(position: Vec2D, attacking: ...
Abstract. Many types of software are inherently event-driven ranging from web applications to embedded devices and traditionally, such applications are implemented using imperative callbacks. An alternative approach to writing such programs is functional reactive programming (FRP). FRP offers abstractions to make event-driven programming convenient, safe and composable, but they come at a price. FRP behaviors cannot efficiently deal with larger, incrementally constructed values such as a collection of messages or a list of connected devices. Since these situations occur naturally, it hinders the use of FRP. We report on a new FRP primitive: 'incremental behavior'. We show that the semantics fit within existing FRP semantics and that their API can be used as a foundation for more ad-hoc solutions, such as incremental collections and discrete behaviors. Finally, we present benchmarks that demonstrate the advantages of incremental behaviors in terms of reduced computation time and bandwidth.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.
hi@scite.ai
10624 S. Eastern Ave., Ste. A-614
Henderson, NV 89052, USA
Copyright © 2024 scite LLC. All rights reserved.
Made with 💙 for researchers
Part of the Research Solutions Family.