The Return of Stream I/O

The Return of Stream I/O

The Frontend community is remarkably shifting towards functional programming, with tools like React, Redux, Immutable.js and Elm becoming mainstream. In the early years of Haskell, there were three I/O models: Monads, Continuations, and Streams. While the Monadic I/O has been established as the standard in Haskell, we are seeing the resurgence of variations of Stream I/O in Frontend, through tools like Cycle.js and Elm. In this talk we will explore the benefits and downsides of Stream I/O, and what it promises for the future.

C8dbe3c6d219999ee0ecce86a450d0e3?s=128

André Staltz

October 04, 2016
Tweet

Transcript

  1. @andrestaltz The Return of Stream I/O

  2. Cycle.js.org A functional and reactive JavaScript framework 
 for cleaner

    code
  3. None
  4. None
  5. None
  6. None
  7. None
  8. None
  9. None
  10. None
  11. None
  12. None
  13. None
  14. Haskell A pure functional programming language

  15. Haskell A pure functional programming language Logic Effects

  16. Haskell A pure functional programming language Logic Effects

  17. Logic Effects Monadic I/O Stream I/O Continuation I/O

  18. Logic Effects Monadic I/O Stream I/O Continuation I/O

  19. Logic Effects Monadic I/O

  20. None
  21. None
  22. None
  23. None
  24. Program Compiler, binary

  25. Logic Effects Stream I/O

  26. Program binary Operating System

  27. Program binary Operating System Requests "Write" msgs

  28. Program binary Operating System Requests Responses "Write" msgs "Read" msgs

  29. None
  30. None
  31. None
  32. None
  33. None
  34. None
  35. None
  36. None
  37. None
  38. Program binary Operating System Requests Responses "Write" msgs "Read" msgs

  39. None
  40. None
  41. None
  42. Reactive system versus Transformational system

  43. "A transformational system repeatedly waits for all its inputs to

    arrive, carries out some processing, and outputs the results when the processing is done." (1998)
  44. (start)
 Inputs Processing Output
 (done)

  45. Examples:
 
 Compiler
 UNIX commands

  46. "A reactive system continuously interacts with its environment, using inputs

    and outputs that are either continuous in time or discrete. The inputs and outputs are often asynchronous, meaning that they may arrive or change values unpredictably at any point in time."
  47. Input Processing Output

  48. Examples:
 
 Real-time systems User interfaces Websites Servers

  49. 1990 Reactive programs Transformational programs 2000 2010

  50. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript
  51. None
  52. None
  53. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Haskell
 Stream I/O
  54. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Monadic I/O good for 
 transformational programs
  55. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Haskell
 Monadic I/O
  56. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Multimedia
  57. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Period of confusion
  58. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Period of confusion
  59. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Shared-memory concurrency
  60. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Shared-memory concurrency
  61. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Early JavaScript
 apps
  62. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Early JavaScript
 apps
  63. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript
  64. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Asynchronous Continuous interaction
  65. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Asynchronous Continuous interaction
  66. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010 Java JavaScript Message passing
 concurrency
  67. Program binary Operating System Requests Responses Stream I/O Message passing

    Lazy lists
 Blocking
  68. Program binary Operating System Requests Responses "Stream I/O" Message passing

    Lazy lists Streams
 Blocking Asynchronous
  69. Program binary Operating System Requests Responses Message passing Streams
 Asynchronous

    Cycle.js
  70. None
  71. None
  72. None
  73. None
  74. None
  75. None
  76. None
  77. None
  78. None
  79. None
  80. None
  81. None
  82. None
  83. None
  84. None
  85. None
  86. Stream of DOM events Stream of actions Stream of state

    Stream of reducers Stream of markup to the DOM
  87. Asynchronous message passing User interfaces or any reactive system Separation

    of concerns
 Handling question-and-answer I/O Cycle.js
  88. None
  89. None
  90. None
  91. None
  92. None
  93. Elm

  94. None
  95. Elm program Elm runtime Task Result "Do this and then

    
 that and tell me the
 result"
  96. None
  97. None
  98. None
  99. None
  100. None
  101. Monadic I/O

  102. None
  103. Task: Monadic I/O Msg and Cmd: "Stream I/O" Elm

  104. Transformational 
 subprogram with Monadic I/O Reactive program
 with "Stream

    I/O" Elm
  105. Store Components State Action Flux

  106. Message passing
 +
 purely functional
 =
 "Stream I/O"?

  107. 1990 Reactive programs Transformational programs 2000 2010

  108. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010
  109. 1990 Pascal FORTRAN BASIC C Reactive programs Transformational programs 2000

    2010
  110. 1990 Pascal FORTRAN BASIC Java JavaScript Ruby C# C Reactive

    programs Transformational programs 2000 2010
  111. 1990 Pascal FORTRAN BASIC Java JavaScript Ruby C# C Reactive

    programs Transformational programs 2000 2010
  112. 1990 Pascal FORTRAN BASIC Java JavaScript Ruby C# C Reactive

    programs Transformational programs 2000 2010 Elm Elixir Clojure Dart
  113. 1990 Pascal FORTRAN BASIC Java JavaScript Ruby C# C Reactive

    programs Transformational programs 2000 2010 Elm Elixir Clojure Dart Asynchronous Message passing Event-driven
  114. Framework Concurrency Cycle.js Message passing React / Redux Message passing

    Elm Message passing Vue.js (Vuex) Message passing Angular v1 ($scope) Shared-memory ngrx Message passing
  115. Framework Paradigm Cycle.js Wannabe functional React / Redux Wannabe functional

    Elm Functional Vue.js (Vuex) OOP Angular v1 ($scope) OOP ngrx Wannabe functional
  116. The future is functional, event-driven message passing concurrent programming

  117. Thank you 
 #