Deprecating the Observer Pattern
infoscience.epfl.ch
infoscience.epfl.ch
tl;dr - functional reactive programming is a nice abstraction which addresses many of the flaws in the observer pattern, especially as it is often employed in UIs, and can be implemented quite nicely in Scala.
Having first class EventSource objects is far superior. Would love to see the ideas from this paper make it into the mainstream of UI frameworks.
The problem solved in Section 3 is to use some cleverness in your compiler/runtime to make it so you can write a state machine as straight line code but have it wait for signals to arrive and run in parallel with other code without having to think about it.
The Reactor described on the second column of page 4 enables this. Notice the difference with the previous column, and even more so with the first example. You are no longer tracking any state (starting/disposing moveObserver or adding/removing moveObservers) but just writing the code as if you can wait forever for the signals and then respond to them.
This looks really nice, but depends on some compiler features that most languages do not have (continuations and/or tail call optimisation) so it is unlikely to make it into other languages soon.
Section 4 describes time-varying instead of discrete signals, so that Section 5 can then describe how to unify time-varying and event-based signals into a framework, which is (the already invented but not widely used) functional reactive programming. The types make it much more exciting than the Scheme implementation though. Section 6 shows how this is/could be actually implemented.
I'm still not sure how they use 'reactive programming' and 'inversion of control' in relation to each other - it seems that what they call 'reactive programming' is 'inversion of control', no?
http://lamp.epfl.ch/~imaier/pub/DeprecatingObserversTR2010.p...
observers.foreach(o => o ! myEvent)
...and you're sending asynchronous events to each of the observers. With Akka, you can have those actors running basically anywhere and have the messages automatically routed to them. The obvious question is-- can this Reactor trait be applied via Akka to external machines?