The Return of Stream I/O @andrestaltz Cycle.js.org A functional and - - PowerPoint PPT Presentation

the return of stream i o
SMART_READER_LITE
LIVE PREVIEW

The Return of Stream I/O @andrestaltz Cycle.js.org A functional and - - PowerPoint PPT Presentation

The Return of Stream I/O @andrestaltz Cycle.js.org A functional and reactive JavaScript framework for cleaner code Haskell A pure functional programming language Haskell A pure functional programming language Logic Effects Haskell A


slide-1
SLIDE 1

@andrestaltz

The Return of Stream I/O

slide-2
SLIDE 2

Cycle.js.org

A functional and reactive JavaScript framework 
 for cleaner code

slide-3
SLIDE 3
slide-4
SLIDE 4
slide-5
SLIDE 5
slide-6
SLIDE 6
slide-7
SLIDE 7
slide-8
SLIDE 8
slide-9
SLIDE 9
slide-10
SLIDE 10
slide-11
SLIDE 11
slide-12
SLIDE 12
slide-13
SLIDE 13
slide-14
SLIDE 14

Haskell

A pure functional programming language

slide-15
SLIDE 15

Haskell

A pure functional programming language Logic Effects

slide-16
SLIDE 16

Haskell

A pure functional programming language Logic Effects

slide-17
SLIDE 17

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

slide-18
SLIDE 18

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

slide-19
SLIDE 19

Logic Effects Monadic I/O

slide-20
SLIDE 20
slide-21
SLIDE 21
slide-22
SLIDE 22
slide-23
SLIDE 23
slide-24
SLIDE 24

Program Compiler, binary

slide-25
SLIDE 25

Logic Effects Stream I/O

slide-26
SLIDE 26

Program binary Operating System

slide-27
SLIDE 27

Program binary Operating System

Requests "Write" msgs

slide-28
SLIDE 28

Program binary Operating System

Requests Responses "Write" msgs "Read" msgs

slide-29
SLIDE 29
slide-30
SLIDE 30
slide-31
SLIDE 31
slide-32
SLIDE 32
slide-33
SLIDE 33
slide-34
SLIDE 34
slide-35
SLIDE 35
slide-36
SLIDE 36
slide-37
SLIDE 37
slide-38
SLIDE 38

Program binary Operating System

Requests Responses "Write" msgs "Read" msgs

slide-39
SLIDE 39
slide-40
SLIDE 40
slide-41
SLIDE 41
slide-42
SLIDE 42

Reactive system versus Transformational system

slide-43
SLIDE 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)

slide-44
SLIDE 44

(start)
 Inputs Processing Output
 (done)

slide-45
SLIDE 45

Examples:
 
 Compiler
 UNIX commands

slide-46
SLIDE 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."

slide-47
SLIDE 47

Input Processing Output

slide-48
SLIDE 48

Examples:
 
 Real-time systems User interfaces Websites Servers

slide-49
SLIDE 49

1990

Reactive programs Transformational programs

2000 2010

slide-50
SLIDE 50

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

slide-51
SLIDE 51
slide-52
SLIDE 52
slide-53
SLIDE 53

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Haskell
 Stream I/O

slide-54
SLIDE 54

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript Monadic I/O good for 
 transformational programs 👎

slide-55
SLIDE 55

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Haskell
 Monadic I/O

slide-56
SLIDE 56

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Multimedia

slide-57
SLIDE 57

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Period of confusion

slide-58
SLIDE 58

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Period of confusion

slide-59
SLIDE 59

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Shared-memory concurrency

slide-60
SLIDE 60

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Shared-memory concurrency

slide-61
SLIDE 61

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Early JavaScript
 apps

slide-62
SLIDE 62

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Early JavaScript
 apps

slide-63
SLIDE 63

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

slide-64
SLIDE 64

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Asynchronous Continuous interaction

slide-65
SLIDE 65

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Asynchronous Continuous interaction

slide-66
SLIDE 66

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

Java JavaScript

Message passing
 concurrency

slide-67
SLIDE 67

Program binary Operating System Requests Responses

Stream I/O

Message passing Lazy lists
 Blocking

slide-68
SLIDE 68

Program binary Operating System Requests Responses

"Stream I/O"

Message passing Lazy lists Streams
 Blocking Asynchronous

slide-69
SLIDE 69

Program binary Operating System Requests Responses

Message passing Streams
 Asynchronous

Cycle.js

slide-70
SLIDE 70
slide-71
SLIDE 71
slide-72
SLIDE 72
slide-73
SLIDE 73
slide-74
SLIDE 74
slide-75
SLIDE 75
slide-76
SLIDE 76
slide-77
SLIDE 77
slide-78
SLIDE 78
slide-79
SLIDE 79
slide-80
SLIDE 80
slide-81
SLIDE 81
slide-82
SLIDE 82
slide-83
SLIDE 83
slide-84
SLIDE 84
slide-85
SLIDE 85
slide-86
SLIDE 86

Stream of DOM events Stream of actions Stream of state Stream of reducers Stream of markup to the DOM

slide-87
SLIDE 87

👎 Asynchronous message passing 👎 User interfaces or any reactive system 👎 Separation of concerns
 👏 Handling question-and-answer I/O

Cycle.js

slide-88
SLIDE 88
slide-89
SLIDE 89
slide-90
SLIDE 90
slide-91
SLIDE 91
slide-92
SLIDE 92
slide-93
SLIDE 93

Elm

slide-94
SLIDE 94
slide-95
SLIDE 95

Elm program Elm runtime

Task Result "Do this and then 
 that and tell me the
 result"

slide-96
SLIDE 96
slide-97
SLIDE 97
slide-98
SLIDE 98
slide-99
SLIDE 99
slide-100
SLIDE 100
slide-101
SLIDE 101

Monadic I/O

slide-102
SLIDE 102
slide-103
SLIDE 103

Task: Monadic I/O Msg and Cmd: "Stream I/O"

Elm

slide-104
SLIDE 104

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

Elm

slide-105
SLIDE 105

Store Components

State Action

Flux

slide-106
SLIDE 106

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

slide-107
SLIDE 107

1990

Reactive programs Transformational programs

2000 2010

slide-108
SLIDE 108

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

slide-109
SLIDE 109

1990

Pascal FORTRAN BASIC

C

Reactive programs Transformational programs

2000 2010

slide-110
SLIDE 110

1990

Pascal FORTRAN BASIC Java JavaScript Ruby C#

C

Reactive programs Transformational programs

2000 2010

slide-111
SLIDE 111

1990

Pascal FORTRAN BASIC Java JavaScript Ruby C#

C

Reactive programs Transformational programs

2000 2010

slide-112
SLIDE 112

1990

Pascal FORTRAN BASIC Java JavaScript Ruby C#

C

Reactive programs Transformational programs

2000 2010

Elm Elixir Clojure Dart

slide-113
SLIDE 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

slide-114
SLIDE 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

slide-115
SLIDE 115

Framework Paradigm Cycle.js Wannabe functional React / Redux Wannabe functional Elm Functional Vue.js (Vuex) OOP Angular v1 ($scope) OOP ngrx Wannabe functional

slide-116
SLIDE 116

The future is functional, event-driven message passing concurrent programming

slide-117
SLIDE 117

Thank you