Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/3446804.3446854acmconferencesArticle/Chapter ViewAbstractPublication PagesccConference Proceedingsconference-collections
research-article

Communication-safe web programming in TypeScript with routed multiparty session types

Published: 27 February 2021 Publication History

Abstract

Modern web programming involves coordinating interactions between browser clients and a server. Typically, the interactions in web-based distributed systems are informally described, making it hard to ensure correctness, especially communication safety, i.e. all endpoints progress without type errors or deadlocks, conforming to a specified protocol.
We present STScript, a toolchain that generates TypeScript APIs for communication-safe web development over WebSockets, and RouST, a new session type theory that supports multiparty communications with routing mechanisms. STScript provides developers with TypeScript APIs generated from a communication protocol specification based on RouST. The generated APIs build upon TypeScript concurrency practices, complement the event-driven style of programming in full-stack web development, and are compatible with the Node.js runtime for server-side endpoints and the React.js framework for browser-side endpoints.
RouST can express multiparty interactions routed via an intermediate participant. It supports peer-to-peer communication between browser-side endpoints by routing communication via the server in a way that avoids excessive serialisation. RouST guarantees communication safety for endpoint web applications written using STScript APIs.
We evaluate the expressiveness of STScript for modern web programming using several production-ready case studies deployed as web applications.

References

[1]
Davide Ancona, Viviana Bono, Mario Bravetti, Joana Campos, Giuseppe Castagna, Pierre-Malo Deniélou, Simon J. Gay, Nils Gesbert, Elena Giachino, Raymond Hu, Einar Broch Johnsen, Francisco Martins, Viviana Mascardi, Fabrizio Montesi, Rumyana Neykova, Nicholas Ng, Luca Padovani, Vasco T. Vasconcelos, and Nobuko Yoshida. 2016. Behavioral Types in Programming Languages. Found. Trends Program. Lang. 3, 2-3 ( July 2016 ), 95-230. htps://doi.org/10.1561/2500000031
[2]
Gavin Bierman, Martín Abadi, and Mads Torgersen. 2014. Understanding TypeScript. In ECOOP 2014-Object-Oriented Programming, Richard Jones (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 257-281.
[3]
Luís Caires and Jorge A. Pérez. 2016. Multiparty Session Types Within a Canonical Binary Theory, and Beyond. In Formal Techniques for Distributed Objects, Components, and Systems, Elvira Albert and Ivan Lanese (Eds.). Springer International Publishing, Cham, 74-95.
[4]
Marco Carbone, Sam Lindley, Fabrizio Montesi, Carsten Sc huermann, and Philip Wadler. 2016. Coherence Generalises Duality: a logical explanation of multipart y session types. In CONCUR'16 (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 59 ). Schloss Dagstuhl, 33 : 1-33 : 15.
[5]
Marco Carbone and Fabrizio Montesi. 2013. Deadlock-Freedom-byDesign: Multiparty Asynchronous Global Programming. In Proceedings of the 40th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (Rome, Italy) (POPL '13). Association for Computing Machinery, New York, NY, USA, 263-274. htps://doi.org/ 10.1145/2429069.2429101
[6]
Marco Carbone, Fabrizio Montesi, Carsten Schormann, and Nobuko Yoshida. 2015. Multiparty Session Types as Coherence Proofs. In CONCUR 2015 (LIPIcs, Vol. 42 ). Schloss Dagstuhl, 412-426.
[7]
David Castro, Raymond Hu, Sung-Shik Jongmans, Nicholas Ng, and Nobuko Yoshida. 2019. Distributed Programming Using Roleparametric Session Types in Go: Statically-typed Endpoint APIs for Dynamically-instantiated Communication Structures. Proc. ACM Program. Lang. 3, POPL, Article 29 ( Jan. 2019 ), 30 pages. htps: //doi.org/10.1145/3290342
[8]
Ezra Cooper, Sam Lindley, Philip Wadler, and Jeremy Yallop. 2007. Links: Web Programming Without Tiers. In Formal Methods for Components and Objects, Frank S. de Boer, Marcello M. Bonsangue, Susanne Graf, and Willem-Paul de Roever (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 266-296.
[9]
Mario Coppo, Mariangiola Dezani-Ciancaglini, Nobuko Yoshida, and Luca Padovani. 2016. Global progress for dynamically interleaved multiparty sessions. MSCS 26, 2 ( 2016 ), 238-302. htps://doi.org/10. 1017/S0960129514000188
[10]
Romain Demangeon, Kohei Honda, Raymond Hu, Rumyana Neykova, and Nobuko Yoshida. 2015. Practical interruptible conversations: distributed dynamic verification with multiparty session types and Python. Formal Methods in System Design 46, 3 (Jun 2015 ), 197-225. htps://doi.org/10.1007/s10703-014-0218-8
[11]
Pierre-Malo Deniélou and Nobuko Yoshida. 2013. Multiparty Compatibility in Communicating Automata: Characterisation and Synthesis of Global Session Types. In 40th International Colloquium on Automata, Languages and Programming (LNCS, Vol. 7966 ). Springer, 174-186. a full version: htp://arxiv.org/abs/1304. 1902.
[12]
Ian Fette and Alexey Melnikov. 2011. The WebSocket Protocol. RFC 6455. RFC Editor. 1-71 pages. htps://www.rfc-editor. org/info/rfc6455
[13]
Simon Fowler. 2020. Model-View-Update-Communicate: Session Types Meet the Elm Architecture. In 34th European Conference on ObjectOriented Programming (ECOOP 2020 ) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 166 ), Robert Hirschfeld and Tobias Pape (Eds.). Schloss Dagstuhl-Leibniz-Zentrum für Informatik, Dagstuhl, Germany, 14 : 1-14 : 28. htps://doi.org/10.4230/LIPIcs.ECOOP. 2020.14
[14]
Kohei Honda, Vasco T. Vasconcelos, and Makoto Kubo. 1998. Language primitives and type discipline for structured communication-based programming. In Programming Languages and Systems, Chris Hankin (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg, 122-138.
[15]
Kohei Honda, Nobuko Yoshida, and Marco Carbone. 2016. Multiparty Asynchronous Session Types. J. ACM 63 ( 2016 ), 1-67. Issue 1-9. htps://doi.org/10.1145/2827695
[16]
Raymond Hu. 2017. Distributed Programming Using Java APIs Generated from Session Types. Behavioural Types: from Theory to Tools ( 2017 ), 287-308.
[17]
Raymond Hu and Nobuko Yoshida. 2016. Hybrid Session Verification through Endpoint API Generation. In 19th International Conference on Fundamental Approaches to Software Engineering (LNCS, Vol. 9633 ). Springer, Berlin, Heidelberg, 401-418. htps://doi.org/10.1007/978-3-662-49665-7_24
[18]
Raymond Hu and Nobuko Yoshida. 2017. Explicit Connection Actions in Multiparty Session Types. In Fundamental Approaches to Software Engineering, Marieke Huisman and Julia Rubin (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 116-133.
[19]
Hans Hüttel, Ivan Lanese, Vasco T. Vasconcelos, Luís Caires, Marco Carbone, Pierre-Malo Deniélou, Dimitris Mostrous, Luca Padovani, António Ravara, Emilio Tuosto, Hugo Torres Vieira, and Gianluigi Zavattaro. 2016. Foundations of Session Types and Behavioural Contracts. ACM Comput. Surv. 49, 1, Article 3 ( 2016 ). htps://doi.org/10. 1145/2873052
[20]
Jonathan King, Nicholas Ng, and Nobuko Yoshida. 2019. Multiparty Session Type-safe Web Development with Static Linearity. In Proceedings Programming Language Approaches to Concurrency-and Communication-cEntric Software, Prague, Czech Republic, 7th April 2019 (Electronic Proceedings in Theoretical Computer Science, Vol. 291 ), Francisco Martins and Dominic Orchard (Eds.). Open Publishing Association, 35-46. htps://doi.org/10.4204/EPTCS.291.4
[21]
Dimitrios Kouzapas, Ornela Dardha, Roly Perera, and Simon J. Gay. 2016. Typechecking Protocols with Mungo and StMungo. In Proceedings of the 18th International Symposium on Principles and Practice of Declarative Programming (Edinburgh, United Kingdom) (PPDP '16). Association for Computing Machinery, New York, NY, USA, 146-159. htps://doi.org/10.1145/2967973.2968595
[22]
Anson Miu, Francisco Ferreira, Nobuko Yoshida, and Fangyi Zhou. 2021. Communication-Safe Web Programming in TypeScript with Routed Multiparty Session Types. htps://doi.org/10.5281/zenodo.4399900
[23]
Fabrizio Montesi. 2016. Process-aware web programming with Jolie. Science of Computer Programming 130 ( 2016 ), 69-96. htps://doi.org/ 10.1016/j.scico. 2016. 05.002
[24]
Rumyana Neykova, Raymond Hu, Nobuko Yoshida, and Fahd Abdeljallal. 2018. A Session Type Provider: Compile-time API Generation of Distributed Protocols with Refinements in F#. In Proceedings of the 27th International Conference on Compiler Construction (Vienna, Austria) ( CC 2018). ACM, New York, NY, USA, 128-138. htps://doi.org/10.1145/3178372.3179495
[25]
Nicholas Ng, Jose G.F. Coutinho, and Nobuko Yoshida. 2015. Protocols by Default: Safe MPI Code Generation based on Session Types. In CC 2015 (LNCS, Vol. 9031 ). Springer, 212-232.
[26]
Benjamin C. Pierce. 2002. Types and Programming Languages (1st ed.). The MIT Press.
[27]
PureScript. 2020. purescript/purescript. PureScript. Accessed on 10th August 2020.
[28]
Alceste Scalas, Ornela Dardha, Raymond Hu, and Nobuko Yoshida. 2017. A Linear Decomposition of Multiparty Sessions for Safe Distributed Programming. In 31st European Conference on Object-Oriented Programming (ECOOP 2017 ) (Leibniz International Proceedings in Informatics (LIPIcs), Vol. 74 ), Peter Müller (Ed.). Schloss Dagstuhl-LeibnizZentrum fuer Informatik, Dagstuhl, Germany, 24 : 1-24 : 31. htps: //doi.org/10.4230/LIPIcs.ECOOP. 2017.24
[29]
Alceste Scalas and Nobuko Yoshida. 2019. Less is More: Multiparty Session Types Revisited. Proc. ACM Program. Lang. 3, POPL, Article 30 ( Jan. 2019 ), 29 pages. htps://doi.org/10.1145/3290343
[30]
Scribble Authors. 2015. Scribble: Describing Multi Party Protocols. htp://www.scribble.org/.
[31]
António Ravara Simon Gay (Ed.). 2017. Behavioural Types: from Theory to Tools. River Publisher. htps://www.riverpublishers.com/research_details. php?book_id=439
[32]
The Jolie Team. 2020. Jolie Programming Language-Oficial Website. htps://jolie-lang.org/. Accessed on 11th November 2020.
[33]
Nobuko Yoshida, Raymond Hu, Rumyana Neykova, and Nicholas Ng. 2014. The Scribble Protocol Language. In 8th International Symposium on Trustworthy Global Computing-Volume 8358 ( Buenos Aires, Argentina) ( TGC 2013 ). Springer-Verlag, Berlin, Heidelberg, 22-41. htps://doi.org/10.1007/978-3-319-05119-2_3
[34]
Fangyi Zhou, Francisco Ferreira, Raymond Hu, Rumyana Neykova, and Nobuko Yoshida. 2020. Statically Verified Refinements for Multiparty Protocols. Proc. ACM Program. Lang. 4, OOPSLA, Article 148 ( Nov. 2020 ), 30 pages. htps://doi.org/10.1145/3428216

Cited By

View all
  • (2024)Behavioural Types for Heterogeneous Systems (Position Paper)Electronic Proceedings in Theoretical Computer Science10.4204/EPTCS.401.4401(37-48)Online publication date: 6-Apr-2024
  • (2024)Discourje: Run-Time Verification of Communication Protocols in Clojure — Live at LastFormal Methods10.1007/978-3-031-71177-0_11(158-166)Online publication date: 13-Sep-2024
  • (2024)Less is More RevisitedThe Practice of Formal Methods10.1007/978-3-031-66673-5_14(268-291)Online publication date: 4-Sep-2024
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
CC 2021: Proceedings of the 30th ACM SIGPLAN International Conference on Compiler Construction
March 2021
164 pages
ISBN:9781450383257
DOI:10.1145/3446804
  • General Chair:
  • Aaron Smith,
  • Program Chairs:
  • Delphine Demange,
  • Rajiv Gupta
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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 27 February 2021

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. API generation
  2. TypeScript
  3. WebSocket
  4. deadlock freedom
  5. session types
  6. web programming

Qualifiers

  • Research-article

Funding Sources

  • EPSRC

Conference

CC '21
Sponsor:

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)29
  • Downloads (Last 6 weeks)1
Reflects downloads up to 08 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Behavioural Types for Heterogeneous Systems (Position Paper)Electronic Proceedings in Theoretical Computer Science10.4204/EPTCS.401.4401(37-48)Online publication date: 6-Apr-2024
  • (2024)Discourje: Run-Time Verification of Communication Protocols in Clojure — Live at LastFormal Methods10.1007/978-3-031-71177-0_11(158-166)Online publication date: 13-Sep-2024
  • (2024)Less is More RevisitedThe Practice of Formal Methods10.1007/978-3-031-66673-5_14(268-291)Online publication date: 4-Sep-2024
  • (2024)Programming Language Implementations with Multiparty Session TypesActive Object Languages: Current Research Trends10.1007/978-3-031-51060-1_6(147-165)Online publication date: 29-Jan-2024
  • (2023)Verifying Reliable Network Components in a Distributed Separation Logic with Dependent Separation ProtocolsProceedings of the ACM on Programming Languages10.1145/36078597:ICFP(847-877)Online publication date: 30-Aug-2023
  • (2023)Intrinsically Typed Sessions with Callbacks (Functional Pearl)Proceedings of the ACM on Programming Languages10.1145/36078547:ICFP(711-739)Online publication date: 30-Aug-2023
  • (2023)Hybrid Multiparty Session Types: Compositionality for Protocol Specification through Endpoint ProjectionProceedings of the ACM on Programming Languages10.1145/35860317:OOPSLA1(112-142)Online publication date: 6-Apr-2023
  • (2023)Multiparty Session Typing in Java, DeductivelyTools and Algorithms for the Construction and Analysis of Systems10.1007/978-3-031-30820-8_3(19-27)Online publication date: 20-Apr-2023
  • (2022)Deadlock-free asynchronous message reordering in rust with multiparty session typesProceedings of the 27th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming10.1145/3503221.3508404(246-261)Online publication date: 2-Apr-2022
  • (2022)ST4MP: A Blueprint of Multiparty Session Typing for Multilingual ProgrammingLeveraging Applications of Formal Methods, Verification and Validation. Verification Principles10.1007/978-3-031-19849-6_26(460-478)Online publication date: 17-Oct-2022
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media