当前位置: X-MOL 学术arXiv.cs.PL › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Generating Interactive WebSocket Applications in TypeScript
arXiv - CS - Programming Languages Pub Date : 2020-04-03 , DOI: arxiv-2004.01321
Anson Miu (Imperial College London), Francisco Ferreira (Imperial College London), Nobuko Yoshida (Imperial College London), Fangyi Zhou (Imperial College London)

Advancements in mobile device computing power have made interactive web applications possible, allowing the web browser to render contents dynamically and support low-latency communication with the server. This comes at a cost to the developer, who now needs to reason more about correctness of communication patterns in their application as web applications support more complex communication patterns. Multiparty session types (MPST) provide a framework for verifying conformance of implementations to their prescribed communication protocol. Existing proposals for applying the MPST framework in application developments either neglect the event-driven nature of web applications, or lack compatibility with industry tools and practices, which discourages mainstream adoption by web developers. In this paper, we present an implementation of the MPST framework for developing interactive web applications using familiar industry tools using TypeScript and the React.js framework. The developer can use the Scribble protocol language to specify the protocol and use the Scribble toolchain to validate and obtain the local protocol for each role. The local protocol describes the interactions of the global communication protocol observed by the role. We encode the local protocol into TypeScript types, catering for server-side and client-side targets separately. We show that our encoding guarantees that only implementations which conform to the protocol can type-check. We demonstrate the effectiveness of our approach through a web-based implementation of the classic Noughts and Crosses game from an MPST formalism of the game logic.

中文翻译:

在 TypeScript 中生成交互式 WebSocket 应用程序

移动设备计算能力的进步使交互式 Web 应用程序成为可能,允许 Web 浏览器动态呈现内容并支持与服务器的低延迟通信。这对开发人员来说是有代价的,因为 Web 应用程序支持更复杂的通信模式,他们现在需要更多地推理其应用程序中通信模式的正确性。多方会话类型 (MPST) 提供了一个框架,用于验证实现与其规定的通信协议的一致性。在应用程序开发中应用 MPST 框架的现有建议要么忽略了 Web 应用程序的事件驱动性质,要么与行业工具和实践缺乏兼容性,这阻碍了 Web 开发人员的主流采用。在本文中,我们展示了 MPST 框架的实现,用于使用熟悉的行业工具使用 TypeScript 和 React.js 框架开发交互式 Web 应用程序。开发者可以使用 Scribble 协议语言来指定协议,并使用 Scribble 工具链来验证和获取每个角色的本地协议。本地协议描述了角色观察到的全局通信协议的交互。我们将本地协议编码为 TypeScript 类型,分别满足服务器端和客户端目标。我们展示了我们的编码保证只有符合协议的实现才能进行类型检查。我们通过基于游戏逻辑的 MPST 形式主义的经典 Noughts and Crosses 游戏的基于网络的实现来证明我们方法的有效性。开发者可以使用 Scribble 协议语言来指定协议,并使用 Scribble 工具链来验证和获取每个角色的本地协议。本地协议描述了角色观察到的全局通信协议的交互。我们将本地协议编码为 TypeScript 类型,分别满足服务器端和客户端目标。我们展示了我们的编码保证只有符合协议的实现才能进行类型检查。我们通过基于游戏逻辑的 MPST 形式主义的经典 Noughts and Crosses 游戏的基于网络的实现来证明我们方法的有效性。开发者可以使用 Scribble 协议语言来指定协议,并使用 Scribble 工具链来验证和获取每个角色的本地协议。本地协议描述了角色观察到的全局通信协议的交互。我们将本地协议编码为 TypeScript 类型,分别满足服务器端和客户端目标。我们展示了我们的编码保证只有符合协议的实现才能进行类型检查。我们通过基于游戏逻辑的 MPST 形式主义的经典 Noughts and Crosses 游戏的基于网络的实现来证明我们方法的有效性。我们将本地协议编码为 TypeScript 类型,分别满足服务器端和客户端目标。我们展示了我们的编码保证只有符合协议的实现才能进行类型检查。我们通过基于游戏逻辑的 MPST 形式主义的经典 Noughts and Crosses 游戏的基于网络的实现来证明我们方法的有效性。我们将本地协议编码为 TypeScript 类型,分别满足服务器端和客户端目标。我们展示了我们的编码保证只有符合协议的实现才能进行类型检查。我们通过基于游戏逻辑的 MPST 形式主义的经典 Noughts and Crosses 游戏的基于网络的实现来证明我们方法的有效性。
更新日期:2020-04-06
down
wechat
bug