deprecating the observer pattern

17
PL@NES - Reading Club Paper: Deprecating the Observer Pattern with Scala.React by Ingo Maier & Martin Odersky [email protected]

Upload: christophevg

Post on 17-Jul-2015

107 views

Category:

Technology


6 download

TRANSCRIPT

Page 1: Deprecating the Observer Pattern

PL@NES - Reading Club Paper: Deprecating the Observer

Pattern with Scala.React by Ingo Maier & Martin Odersky

[email protected]

Page 2: Deprecating the Observer Pattern

R

THE FOLLOWING PRESENTATION DOES NOT INCLUDE MATERIAL ABOUT SCALA NOR SCALA.REACT.

IT WILL HIGHLIGHT THE GREAT PARTS OF THE ORIGINAL PAPER IN A GENERIC WAY.

RECOMMENDEDMIGHT CONTAIN MILD HUMOR. MIGHT PROVOKE INTELLECTUAL DISCUSSIONS AND CAUSE FRESH IDEAS TO EMERGE.

christophe.vg distrinet.cs.kuleuven.be

Page 3: Deprecating the Observer Pattern

• Observer Pattern

• Reactive Semantics

• Scala.React

• Reactive Performance

Contributions

ok, maybe a little ;-)

3

Goals • summary of RP • applicability to NES

Page 4: Deprecating the Observer Pattern

Observer Pattern

4

Page 5: Deprecating the Observer Pattern
Page 6: Deprecating the Observer Pattern

Observer Patternvar path: Path = null!!val moveObserver = { (event: MouseEvent) =>! path.lineTo(event.position)! draw(path)!}!!control.addMouseDownObserver { event =>! path = new Path(event.position)! control.addMouseMoveObserver(moveObserver)!}!!control.addMouseUpObserver { event =>! control.removeMouseMoveObserver(moveObserver)! path.close()! draw(path)!}!

6

side-effects

encapsulation

composability

resourcemanagementseparation of

concernsdata

consistency

uniformity

abstractionsemantic distance

Page 7: Deprecating the Observer Pattern
Page 8: Deprecating the Observer Pattern

• Event Streams

• Events and Signals

• Composition/Transformation

• Reactors

• Data Flow Language

Reactive Semanticsdependency graph

merge, map, filter,…

Resource Mgmt Inversion of Control

pause, await, par, join, loop,…

eventssignal

observable observers

(with simple interfaces)

8

scripting of dynamic & structural dependency graph

modifications

liftingbehavior

Page 9: Deprecating the Observer Pattern

Reactive Semantics

9

+ API for dynamic binding modifications

Page 10: Deprecating the Observer Pattern
Page 11: Deprecating the Observer Pattern

Reactive Performance

11

observer

Scala.React

others

chain fan

…source observer source observers…

Page 12: Deprecating the Observer Pattern

ARM 32-bit Cortex™-M3 CPU Core 72Mhz operating frequency

Does it Scale?

12

on embedded devices

Intel 2,4 GHz Intel Core 2 Duo 2530Mhz operating frequency

Throughput (updates/second)

0

325.000

650.000

975.000

1.300.000

observer.c reactive-c

802.978

1.243.955

611.356723.345

chain fan

Throughput (updates/second) (Spark Core)

0

2750

5500

8250

11000

observer.c reactive-c

5.501,5

10.294

5.189

9.871

chain fan

-50%-30%

: 110

Page 13: Deprecating the Observer Pattern

“Time moves in one direction, memory in another.”

William Gibson

Page 14: Deprecating the Observer Pattern

Shameless PlugReactive-C Rose

https://github.com/christophevg/reactive-c https://github.com/christophevg/rose14

Page 15: Deprecating the Observer Pattern

• Automate Dependency Graph Management

• Avoid Data Inconsistencies

• Offer a Functional API

• Allow for Imperative Encoding of Algorithms

Deprecating the Observer Pattern?

Observer Pattern on Steroids !

15

Page 16: Deprecating the Observer Pattern

Reactions ?

Page 17: Deprecating the Observer Pattern

http://www.slideshare.net/christophevg/deprecating-the-observer-pattern

[email protected]