skip to main content
10.1145/3611096.3611101acmotherconferencesArticle/Chapter ViewAbstractPublication PagesisstaConference Proceedingsconference-collections
research-article

A Graph-Based Formal Semantics of Reactive Programming from First Principles

Published: 16 October 2023 Publication History

Abstract

In recent years, stream processing has become the de facto paradigm to process any kind of real-time data in many kinds of applications. Different libraries, frameworks and techniques exists which aim to make it easy to build stream processing applications in many modern programming languages...Libraries such as Reactive Extensions, Akka Streams, or web frameworks such as React and Vue are all based on the idea of data streams that model the flow of data in applications. To the best of our knowledge, there exist no formalism which captures the essential core semantics of these approaches in a straightforward, easy to understand, manner: namely its graph-based program structure and the way how values propagate through this graph. In this paper, we present Karcharias, a formalisation of reactive programming – a model that shares many core ideas found in the various aforementioned libraries and frameworks – that is built from first principles. Instead of extending an existing language with a graph-based stream processing framework, and formalising this integrated language, we formalised the reactive programming paradigm without relying on a base language (such as the λ -calculus). Using our formalism, we show how reactive programs (and thus, stream-based programs in general) need a way to construct a graph and to propagate events through that graph, even in the absence of a base language.

References

[1]
N. I. Adams, D. H. Bartley, G. Brooks, R. K. Dybvig, D. P. Friedman, R. Halstead, C. Hanson, C. T. Haynes, E. Kohlbecker, D. Oxley, K. M. Pitman, G. J. Rozas, G. L. Steele, G. J. Sussman, M. Wand, and H. Abelson. 1998. Revised5 Report on the Algorithmic Language Scheme. SIGPLAN Not. 33, 9 (Sept. 1998), 26–76. https://doi.org/10.1145/290229.290234
[2]
Patrick Bahr, Christian Uldal Graulund, and Rasmus Ejlers Møgelberg. 2021. Diamonds are not forever: liveness in reactive programming with guarded recursion. Proc. ACM Program. Lang. 5, POPL (2021), 1–28. https://doi.org/10.1145/3434283
[3]
Engineer Bainomugisha, Andoni Lombide Carreton, Tom Van Cutsem, Stijn Mostinckx, and Wolfgang De Meuter. 2013. A survey on reactive programming. ACM Comput. Surv. 45, 4 (2013), 52:1–52:34. https://doi.org/10.1145/2501654.2501666
[4]
Andoni Lombide Carreton, Stijn Mostinckx, Tom Van Cutsem, and Wolfgang De Meuter. 2010. Loosely-Coupled Distributed Reactive Programming in Mobile Ad Hoc Networks. In Objects, Models, Components, Patterns, 48th International Conference, TOOLS 2010, Málaga, Spain, June 28 - July 2, 2010. Proceedings(Lecture Notes in Computer Science, Vol. 6141), Jan Vitek (Ed.). Springer, 41–60. https://doi.org/10.1007/978-3-642-13953-6_3
[5]
Guerric Chupin and Henrik Nilsson. 2019. Functional Reactive Programming, restated. In Proceedings of the 21st International Symposium on Principles and Practice of Programming Languages, PPDP 2019, Porto, Portugal, October 7-9, 2019, Ekaterina Komendantskaya (Ed.). ACM, 7:1–7:14. https://doi.org/10.1145/3354166.3354172
[6]
Gregory H. Cooper and Shriram Krishnamurthi. 2006. Embedding Dynamic Dataflow in a Call-by-Value Language. In Programming Languages and Systems, 15th European Symposium on Programming, ESOP 2006, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2006, Vienna, Austria, March 27-28, 2006, Proceedings(Lecture Notes in Computer Science, Vol. 3924), Peter Sestoft (Ed.). Springer, 294–308. https://doi.org/10.1007/11693024_20
[7]
Antony Courtney. 2001. Frappé: Functional Reactive Programming in Java. In Practical Aspects of Declarative Languages, Third International Symposium, PADL 2001, Las Vegas, Nevada, USA, March 11-12, 2001, Proceedings(Lecture Notes in Computer Science, Vol. 1990), I. V. Ramakrishnan (Ed.). Springer, 29–44. https://doi.org/10.1007/3-540-45241-9_3
[8]
Evan Czaplicki and Stephen Chong. 2013. Asynchronous functional reactive programming for GUIs. In ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI ’13, Seattle, WA, USA, June 16-19, 2013, Hans-Juergen Boehm and Cormac Flanagan (Eds.). ACM, 411–422. https://doi.org/10.1145/2491956.2462161
[9]
N.G de Bruijn. 1972. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagationes Mathematicae (Proceedings) 75, 5 (1972), 381–392. https://doi.org/10.1016/1385-7258(72)90034-0
[10]
Sam Van den Vonder, Thierry Renaux, Bjarno Oeyen, Joeri De Koster, and Wolfgang De Meuter. 2020. Tackling the Awkward Squad for Reactive Programming: The Actor-Reactor Model. In 34th European Conference on Object-Oriented Programming, ECOOP 2020, November 15-17, 2020, Berlin, Germany (Virtual Conference)(LIPIcs, Vol. 166), Robert Hirschfeld and Tobias Pape (Eds.). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 19:1–19:29. https://doi.org/10.4230/LIPIcs.ECOOP.2020.19
[11]
Joscha Drechsler, Ragnar Mogk, Guido Salvaneschi, and Mira Mezini. 2018. Thread-safe reactive programming. Proc. ACM Program. Lang. 2, OOPSLA (2018), 107:1–107:30. https://doi.org/10.1145/3276477
[12]
Conal Elliott and Paul Hudak. 1997. Functional Reactive Animation. In Proceedings of the 1997 ACM SIGPLAN International Conference on Functional Programming (ICFP ’97), Amsterdam, The Netherlands, June 9-11, 1997, Simon L. Peyton Jones, Mads Tofte, and A. Michael Berman (Eds.). ACM, 263–273. https://doi.org/10.1145/258948.258973
[13]
Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex. MIT Press, London, England.
[14]
Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. 1993. The Essence of Compiling with Continuations. In Proceedings of the ACM SIGPLAN’93 Conference on Programming Language Design and Implementation (PLDI), Albuquerque, New Mexico, USA, June 23-25, 1993, Robert Cartwright (Ed.). ACM, 237–247. https://doi.org/10.1145/155090.155113
[15]
Daniel Ignatoff, Gregory H. Cooper, and Shriram Krishnamurthi. 2006. Crossing State Lines: Adapting Object-Oriented Frameworks to Functional Reactive Languages. In Functional and Logic Programming, 8th International Symposium, FLOPS 2006, Fuji-Susono, Japan, April 24-26, 2006, Proceedings(Lecture Notes in Computer Science, Vol. 3945), Masami Hagiya and Philip Wadler (Eds.). Springer, 259–276. https://doi.org/10.1007/11737414_18
[16]
Wolfgang Jeltsch. 2014. Categorical Semantics for Functional Reactive Programming with Temporal Recursion and Corecursion. In Proceedings 5th Workshop on Mathematically Structured Functional Programming, MSFP@ETAPS 2014, Grenoble, France, 12 April 2014(EPTCS, Vol. 153), Paul Blain Levy and Neel Krishnaswami (Eds.). 127–142. https://doi.org/10.4204/EPTCS.153.9
[17]
Christopher T King. 2008. An axiomatic semantics for functional reactive programming. Ph. D. Dissertation. Worcester Polytechnic Institute.
[18]
Neelakantan R. Krishnaswami and Nick Benton. 2011. Ultrametric Semantics of Reactive Programs. In Proceedings of the 26th Annual IEEE Symposium on Logic in Computer Science, LICS 2011, June 21-24, 2011, Toronto, Ontario, Canada. IEEE Computer Society, 257–266. https://doi.org/10.1109/LICS.2011.38
[19]
Adriaan Leijnse. 2020. An introduction to Denotative Continuous Spacetime Programming. https://2020.splashcon.org/details/rebls-2020-papers/8/An-Introduction-to-Denotative-Continuous-Spacetime-Programming-Work-in-Progress-
[20]
Hai Liu and Paul Hudak. 2007. Plugging a Space Leak with an Arrow. Electron. Notes Theor. Comput. Sci. 193 (2007), 29–45. https://doi.org/10.1016/j.entcs.2007.10.006
[21]
Ingo Maier and Martin Odersky. 2012. Deprecating the Observer Pattern with Scala.React. (2012), 20 pages. http://infoscience.epfl.ch/record/176887
[22]
Erik Meijer. 2010. Reactive Extensions (Rx): Curing Your Asynchronous Programming Blues. In ACM SIGPLAN Commercial Users of Functional Programming (Baltimore, Maryland) (CUFP ’10). Association for Computing Machinery, New York, NY, USA, Article 11, 1 pages. https://doi.org/10.1145/1900160.1900173
[23]
Leo A. Meyerovich, Arjun Guha, Jacob P. Baskin, Gregory H. Cooper, Michael Greenberg, Aleks Bromfield, and Shriram Krishnamurthi. 2009. Flapjax: a programming language for Ajax applications. In Proceedings of the 24th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2009, October 25-29, 2009, Orlando, Florida, USA, Shail Arora and Gary T. Leavens (Eds.). ACM, 1–20. https://doi.org/10.1145/1640089.1640091
[24]
Henrik Nilsson, Antony Courtney, and John Peterson. 2002. Functional Reactive Programming, Continued. In Proceedings of the 2002 ACM SIGPLAN Workshop on Haskell (Pittsburgh, Pennsylvania) (Haskell ’02). Association for Computing Machinery, New York, NY, USA, 51–64. https://doi.org/10.1145/581690.581695
[25]
Bjarno Oeyen, Sam Van den Vonder, and Wolfgang De Meuter. 2020. Reactive sorting networks. In REBLS 2020: Proceedings of the 7th ACM SIGPLAN International Workshop on Reactive and Event-Based Languages and Systems, Virtual Event, USA, November 16, 2020. ACM, 38–50. https://doi.org/10.1145/3427763.3428316
[26]
Bjarno Oeyen, Sam Van den Vonder, and Wolfgang De Meuter. 2021. Trampoline variables: a general method for state accumulation in reactive programming. In REBLS 2021: Proceedings of the 8th ACM SIGPLAN International Workshop on Reactive and Event-Based Languages and Systems, Chicago, IL, USA, 18 October 2021, Louis Mandel (Ed.). ACM, 27–40. https://doi.org/10.1145/3486605.3486787
[27]
Ross Paterson. 2001. A New Notation for Arrows. In Proceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming (ICFP ’01), Firenze (Florence), Italy, September 3-5, 2001, Benjamin C. Pierce (Ed.). ACM, 229–240. https://doi.org/10.1145/507635.507664
[28]
Ivan Perez, Manuel Bärenz, and Henrik Nilsson. 2016. Functional reactive programming, refactored. In Proceedings of the 9th International Symposium on Haskell, Haskell 2016, Nara, Japan, September 22-23, 2016, Geoffrey Mainland (Ed.). ACM, 33–44. https://doi.org/10.1145/2976002.2976010
[29]
Guido Salvaneschi, Gerold Hintz, and Mira Mezini. 2014. REScala: bridging between object-oriented and functional style in reactive applications. In 13th International Conference on Modularity, MODULARITY ’14, Lugano, Switzerland, April 22-26, 2014, Walter Binder, Erik Ernst, Achille Peternier, and Robert Hirschfeld (Eds.). ACM, 25–36. https://doi.org/10.1145/2577080.2577083
[30]
Kensuke Sawada and Takuo Watanabe. 2016. Emfrp: a functional reactive programming language for small-scale embedded systems. In Companion Proceedings of the 15th International Conference on Modularity, Málaga, Spain, March 14 - 18, 2016, Lidia Fuentes, Don S. Batory, and Krzysztof Czarnecki (Eds.). ACM, 36–44. https://doi.org/10.1145/2892664.2892670
[31]
Neil Sculthorpe and Henrik Nilsson. 2009. Safe functional reactive programming through dependent types. In Proceeding of the 14th ACM SIGPLAN international conference on Functional programming, ICFP 2009, Edinburgh, Scotland, UK, August 31 - September 2, 2009, Graham Hutton and Andrew P. Tolmach (Eds.). ACM, 23–34. https://doi.org/10.1145/1596550.1596558
[32]
Kazuhiro Shibanai and Takuo Watanabe. 2018. Distributed functional reactive programming on actor-based runtime. In Proceedings of the 8th ACM SIGPLAN International Workshop on Programming Based on Actors, Agents, and Decentralized Control, AGERE!@SPLASH 2018, Boston, MA, USA, November 5, 2018, Joeri De Koster, Federico Bergenti, and Juliana Franco (Eds.). ACM, 13–22. https://doi.org/10.1145/3281366.3281370
[33]
Artur Sterz, Matthias Eichholz, Ragnar Mogk, Lars Baumgärtner, Pablo Graubner, Matthias Hollick, Mira Mezini, and Bernd Freisleben. 2021. ReactiFi: Reactive Programming of Wi-Fi Firmware on Mobile Devices. Art Sci. Eng. Program. 5, 2 (2021), 4. https://doi.org/10.22152/programming-journal.org/2021/5/4
[34]
Typesafe, inc.[n. d.]. Akka: Build concurrent, distributed, and resilient message-driven applications for Java and scala. https://akka.io/
[35]
Zhanyong Wan and Paul Hudak. 2000. Functional reactive programming from first principles. In Proceedings of the 2000 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), Vancouver, Britith Columbia, Canada, June 18-21, 2000, Monica S. Lam (Ed.). ACM, 242–252. https://doi.org/10.1145/349299.349331
[36]
Zhanyong Wan, Walid Taha, and Paul Hudak. 2002. Event-Driven FRP. In Practical Aspects of Declarative Languages, 4th International Symposium, PADL 2002, Portland, OR, USA, January 19-20, 2002, Proceedings(Lecture Notes in Computer Science, Vol. 2257), Shriram Krishnamurthi and C. R. Ramakrishnan (Eds.). Springer, 155–172. https://doi.org/10.1007/3-540-45587-6_11
[37]
Tian Zhao, Adam Berger, and Yonglun Li. 2020. Asynchronous monad for reactive IoT programming. In REBLS 2020: Proceedings of the 7th ACM SIGPLAN International Workshop on Reactive and Event-Based Languages and Systems, Virtual Event, USA, November 16, 2020. ACM, 25–37. https://doi.org/10.1145/3427763.3428314

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Other conferences
FTfJP '22: Proceedings of the 24th ACM International Workshop on Formal Techniques for Java-like Programs
June 2022
41 pages
ISBN:9798400707841
DOI:10.1145/3611096
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 the author(s) 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].

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 16 October 2023

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. Operational Semantics
  2. Reactive Programming

Qualifiers

  • Research-article
  • Research
  • Refereed limited

Funding Sources

Conference

FTfJP '22

Acceptance Rates

Overall Acceptance Rate 51 of 75 submissions, 68%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 20
    Total Downloads
  • Downloads (Last 12 months)13
  • Downloads (Last 6 weeks)0
Reflects downloads up to 30 Jan 2025

Other Metrics

Citations

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

HTML Format

View this article in HTML Format.

HTML Format

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media