![Page 1: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/1.jpg)
Reactive Functional Programming
(or, Is That a Parenthesis in Your Pocket?)
Shriram Krishnamurthi
![Page 2: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/2.jpg)
PascalPascal
![Page 3: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/3.jpg)
begin
beginbegin
begin
begin
…
…
…
… begin
…
end;
…
…
end;
…
…
…
…
…
…
…
…end;
end;
begin
…
…
…
…
…
…
…
…
…
…
…
…
begin
…
end;end;
…
end;
…
…
end;
end.
3
![Page 4: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/4.jpg)
“Pascal is part of the same machinery as hall passesPascal is part of the same machinery as hall passes, dress codes, advisors’ signatures, single-sex dorms, and so on.”
—Brian Harvey
4
![Page 5: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/5.jpg)
The Flow of ControlThe Flow of Control
ModelThe world is in charge,h Modelnot the program
5
![Page 6: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/6.jpg)
flights from PVD to CDGmust
remember
list of flightslist of flights
the third outward flightmust
remember
restricted list of return flights
remember restricted
list of return
the second return flight
flights
ok
6
![Page 7: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/7.jpg)
user typed ‘(’
ok
user moved mousedifferentkinds ofhandlers
ok
user clicked mouse button
ok
7
![Page 8: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/8.jpg)
user moved right 10 yards loc: (0,0)
ok loc: (10,0)
user tilted phone left loc: (10,0)
ok loc: (10,0)
user moved left 10 yards loc: (10,0)
ok loc: (0,0)
8
![Page 9: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/9.jpg)
9
![Page 10: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/10.jpg)
var timerID = null;
timers, initialization,overlapvar timerID null;
var elapsedTime = 0;
function doEverySecond() {
overlap,interference,callbacks… oh my!
elapsedTime += 1;document.getElementById('curTime').innerHTML = elapsedTime; }
f ti t tTi () {function startTimer() {timerId = setInterval(doEverySecond, 1000); }
function resetElapsed() {elapsedTime = 0; }elapsedTime = 0; }
<body onload="startTimer()"><input id="reset" type="button" value="Reset" p yp
onclick="resetElapsed()" /><div id='curTime'> </div></body>
10
![Page 11: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/11.jpg)
Callback
idvoid
d b
void
database,memory store,Web
Event Loop
service,hidden fields,cont’ns
11OS Program
p cont ns
![Page 12: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/12.jpg)
(define gauge(define gauge(new gauge% [label "Elapsed"]
[range 150]))
(new timer%[interval 100][callback (lambda (event)
(send gauge set-value(add1 (send gauge get-value))))])
( b tt %(new button%[label "Reset"][callback (lambda (event)
(send gauge set-value 0))])(send gauge set value 0))])
12
![Page 13: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/13.jpg)
(define gauge(define gauge(new gauge% [label "Elapsed"]
[range 150]))
(new timer%[interval 100][callback (lambda (event)
(send gauge set-value(add1 (send gauge get-value))))])
( b tt %(new button%[label "Reset"][callback (lambda (event)
(send gauge set-value 0))])(send gauge set value 0))])
13
![Page 14: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/14.jpg)
interface ChangeListener extends EventListener {void stateChanged(ChangeEvent e) { ... } }
interface ActionListener extends EventListener {void actionPerformed(ActionEvent e) { ... } }
interface MouseListener extends EventListener {void mouseClicked(MouseEvent e) { }void mouseClicked(MouseEvent e) { ... }void mouseEntered(MouseEvent e) { ... }void mouseExited(MouseEvent e) { ... }void mousePressed(MouseEvent e) { }void mousePressed(MouseEvent e) { ... }void mouseReleased(MouseEvent e) { ... } }
14
![Page 15: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/15.jpg)
interface ChangeListener extends EventListener {void stateChanged(ChangeEvent e) { ... } }
interface ActionListener extends EventListener {void actionPerformed(ActionEvent e) { ... } }
interface MouseListener extends EventListener {void mouseClicked(MouseEvent e) { }void mouseClicked(MouseEvent e) { ... }void mouseEntered(MouseEvent e) { ... }void mouseExited(MouseEvent e) { ... }void mousePressed(MouseEvent e) { }void mousePressed(MouseEvent e) { ... }void mouseReleased(MouseEvent e) { ... } }
15
![Page 16: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/16.jpg)
mainLoop : unit -> unit pcloseTk : unit -> unit
destroy : 'a Widget.widget -> unit update : unit -> unit
pack : ... -> 'd Widget.widget list -> unit grid : ... -> 'b Widget.widget list -> unit
raise_window : ?above:'a Widget.widget-> 'b Widget.widget -> unit> b Widget.widget > unit
bind : events:event list-> 'a Widget.widget -> unit
16
![Page 17: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/17.jpg)
mainLoop : unit -> unitpcloseTk : unit -> unit
destroy : 'a Widget.widget -> unitupdate : unit -> unit
pack : ... -> 'd Widget.widget list -> unitgrid : ... -> 'b Widget.widget list -> unit
raise_window : ?above:'a Widget.widget-> 'b Widget.widget -> unit> b Widget.widget > unit
bind : events:event list-> 'a Widget.widget -> unit
17
![Page 18: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/18.jpg)
propagateEvent :: IO () p p gselect :: Selecting w => Event w (IO ()) mouse :: Reactive w => Event w (EventMouse -> IO ())keyboard :: Reactive w => y
Event w (EventKey -> IO ())resize :: Reactive w => Event w (IO ())focus :: Reactive w => Event w (Bool -> IO ())activate :: Reactive w => Event w (Bool -> IO ())enter :: Reactive w => Event w (Point -> IO ())leave :: Reactive w => Event w (Point -> IO ())( ())motion :: Reactive w => Event w (Point -> IO ())drag :: Reactive w => Event w (Point -> IO ())click :: Reactive w => Event w (Point -> IO ())c c :: eact e e t ( o t O ())unclick :: Reactive w => Event w (Point -> IO ())doubleClick :: Reactive w =>
Event w (Point -> IO ())
18
( ())
![Page 19: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/19.jpg)
propagateEvent :: IO ()p p gselect :: Selecting w => Event w (IO ()) mouse :: Reactive w => Event w (EventMouse -> IO ())keyboard :: Reactive w => y
Event w (EventKey -> IO ())resize :: Reactive w => Event w (IO ())focus :: Reactive w => Event w (Bool -> IO ())activate :: Reactive w => Event w (Bool -> IO ())enter :: Reactive w => Event w (Point -> IO ())leave :: Reactive w => Event w (Point -> IO ())( ())motion :: Reactive w => Event w (Point -> IO ())drag :: Reactive w => Event w (Point -> IO ())click :: Reactive w => Event w (Point -> IO ())c c :: eact e e t ( o t O ())unclick :: Reactive w => Event w (Point -> IO ())doubleClick :: Reactive w =>
Event w (Point -> IO ())
19
( ())
![Page 20: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/20.jpg)
So What?So What?
We care deeply about functions because ofWe care deeply about functions because of
T iTesting
Composition
Education
20
![Page 21: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/21.jpg)
SolutionsSolutions
Lazy evaluation(H k ll FRP)(Haskell FRP)Continuations
(PLT Scheme Web Server)Dataflow + state + GUIs in call-by-valueDataflow + state + GUIs in call by value
(FrTime, Flapjax, …)
21
![Page 22: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/22.jpg)
Why void?
The hostilevoid
The hostileoperating
system
Why hostile?
voidBecause
it’s neutral
Butneutrality hostility
void
y y
Neutrals can cooperate
(impartially)22
![Page 23: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/23.jpg)
User
Callback
OS
“W ld”“World”
“World”
“World”
“World”
23
![Page 24: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/24.jpg)
Current value of World
Will invokeevent-specific
functions
Might be enriched with
additional event
New value f W ld
additional event information
of World
The information you need to restore the computation pfrom a crash
24
![Page 25: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/25.jpg)
What’s changing?
Th l i f h UFOple
The location of the UFO.How do we represent it?
The modelinci
p
As a coordinate pair.The model
d Pr
iw
ood
Modelviewtransformation
olly
w
Modelmodelt f tihe
Ho
transformation
25Th
![Page 26: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/26.jpg)
26
![Page 27: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/27.jpg)
(define width 400)(define height 300)(define initial world 0)(define initial-world 0)(define PLANE )
world sceneworld scene(define (render w)(place-image PLANE
(* w 10)(image-height PLANE)(empty-scene width height)))
world world(define (incr-time w)(add1 w))
(big-bang initial-world(on-tick incr-time)(t d d ))
model modeld l (to-draw render))
27
modelview
![Page 28: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/28.jpg)
(define width 400)(define height 300)(define initial world 0)(define initial-world 0)(define PLANE )
world sceneworld scene(define (render w)(place-image PLANE
(* w 10)(image-height PLANE)(empty-scene width height)))
(animate initial-world render)
Functions as arguments (sssh!)
28
![Page 29: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/29.jpg)
World
World
World
Scene
World
W ldWorld
29
![Page 30: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/30.jpg)
World
World
World
Scene
World
Bool
30
![Page 31: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/31.jpg)
k k
on-click :: w btn w
on-move :: w dist w
on-tilt :: w incl w
on-key :: w key w
on move :: w dist w
to-draw :: w scene
on-tick :: w w
stop-when :: w boolstop when :: w bool
31
![Page 32: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/32.jpg)
32
![Page 33: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/33.jpg)
(define WIDTH 300)(define HEIGHT 300)
(define-struct vel (x y))
(define target (make-posn (random WIDTH) …))
(define-struct world (posn r vel))
(define initial-world (make-world (make-posn …)
30 (make-vel 0 0)))
world bool(define (game-ends? w)( (< ( ld ) 1)(or (<= (world-r w) 1)
(collide? w)))
33
![Page 34: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/34.jpg)
world world(define (tick w)(make world (posn+vel (world posn w) (world vel w))(make-world (posn+vel (world-posn w) (world-vel w))
(- (world-r w) 1/3)(world-vel w)))
world number number number world(define (tilt w azimuth pitch roll)(update-world-vel w
(big bang initial world
(update world vel w(make-vel roll (- pitch))))
(big-bang initial-world(to-draw render)(on-tick tick)(on-tilt tilt) (stop-when game-ends?))
34
![Page 35: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/35.jpg)
35
![Page 36: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/36.jpg)
36
![Page 37: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/37.jpg)
2006 PISA USA t i t 20 i th2006 PISA scores: USA not in top 20 in math, science, or reading
“Economic Time Bomb”—June Kronholz, WSJ
37
![Page 38: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/38.jpg)
Salient Curricular FactsSalient Curricular Facts
STEM “sorting” occurs in middle-school
Functions are a major barrier
Algebra only over numbers is boringAlgebra only over numbers is boring
38
![Page 39: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/39.jpg)
A train leaves Chicago at 6pm, traveling east at 50mph…
39
![Page 40: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/40.jpg)
40
![Page 41: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/41.jpg)
41
![Page 42: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/42.jpg)
5 + 3
17 = □ - 11
x2 = 25 - 16 process
17 33 3 20
1729 = x3 - 1000
17 + 33 = 3x - 20
1729 x 1000
f(x) = x2 objectf( ) j
• with attributes
42• with multiple representations
![Page 43: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/43.jpg)
FunctionsFunctionsf(x)
30
40
50
60
70
f(x)
0
10
20
x 1.4 1.9 2.4 2.9 3.4 3.9 4.4 4.9 5.4 5.9 6.4 6.9 7.4 7.9
f(x)
f(x) = x2Program
x 1 2 3 4 5 6
f(x) 1 4 9 16 25 36Tests
43
f( )
![Page 44: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/44.jpg)
44
![Page 45: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/45.jpg)
45
![Page 46: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/46.jpg)
Vital StatisticsVital Statistics
Middle-school, after-school (predominantly)Middle school, after school (predominantly)All teaching by volunteers (professionals, students)Day 1: design your own game; 9 weeks: implement itDay 1: design your own game; 9 weeks: implement it
24% female; 70% reporting race are minority;24% female; 70% reporting race are minority; 70% on free or reduced-price lunch
Emphasis on: testing, pair-programming, code-review
46
![Page 47: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/47.jpg)
Over 700 students (average age: 11y9m) so farAbout 200 new students this past year, growing /year
47
![Page 48: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/48.jpg)
48
![Page 49: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/49.jpg)
TechnologyTechnology
Scheme (Racket) on the desktopScheme (Racket) on the desktopScheme J2ME compiler for AndroidS h J S iScheme JavaScript
Works on both phones and browsersNeed to deal with asynchronyNeed to deal with re-entranceNeed to deal with re entrance(Futures, continuations, …)
W ld d R k J J S iWorld ported to Racket, Java, JavaScript…49
![Page 50: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/50.jpg)
50
![Page 51: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/51.jpg)
The World is Not EnoughThe World is Not Enough
![Page 52: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/52.jpg)
A t ti d t ti f t t f l APIAutomatic adaptation of stateful APIs
In-place updates of world state
“Universe” for distributed computing
Moore versus Mealy
52
![Page 53: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/53.jpg)
Take-Away MessagesTake Away Messages
• Programming with functions creates aProgramming with functions creates a virtuous cycle
• Middle-schoolers can write tests, i d isurvive code-reviews, etc.
• Programming models matter, especially across platformsp y p
53
![Page 54: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/54.jpg)
54
![Page 55: Reactive Functional Programmingee380.stanford.edu/Abstracts/110518-slides.pdf · Reactive Functional Programming (or, Is That a Parenthesis in Your Pocket?) Shriram Krishnamurthi](https://reader036.vdocuments.site/reader036/viewer/2022062505/5ee10df7ad6a402d666c137b/html5/thumbnails/55.jpg)
www.bootstrapworld.orgwww.bootstrapworld.org
www.facebook.com/BootstrapWorld/ p
Thanks:
Danny YooKathi Fisler
Emmanuel SchanzerMatthias Felleisen
Zhe Zhang (rest )
55