Basically this is also referred to as "push" versus "pull". The way I understand it: pushing means that when a source (= the real inputs, aka sensor, e.g. mouse) changes, it notifies its dependencies about this change. At the lowest level pushes are caused by interrupts, at the high level this is typically represented in OO by subject/observer (aka signals/slots, aka events in .NET). Pulling means that you read a value from the final output "node" (e.g. the voltage of a motor or a 3D object to be displayed on the screen), this node reads its inputs, until it samples the value of a sensor.
Hi,
When talking about the Observer pattern I was thinking in the case that appears in the reactive programming entry in Wikipedia (http://en.wikipedia.org/wiki/Reactive_programming).
If we have a reactive setting then the sentence
a := b + c
could mean that there is a dynamic data flow from the values b and c to the value a, so whenever b or c change, a is automatically changed.
This has similarities to the OO Observer pattern (in fact, you can implement it using the pattern) and is also supported in some new scripting languages as JavaFX.
It seems that some goals of reactive programming are shared with the goals of the Observer pattern. Are they actually related? Maybe this relationship is between the pattern and reactive programming in general, not FRP. Is this so or is Wikipedia just wrong about that? Anyway, is it possible to implement something alike the a := b + c case using Reactive or any oher FRP package? Can someone show any example?
Thanks,
Alvaro.---------- Forwarded message ----------
From: Patai Gergely <patai_gergely@fastmail.fm>
Date: 2009/6/9
Subject: Re: [reactive] FRP, continuous time and concurrency
To: Álvaro García Pérez <agarcia@babel.ls.fi.upm.es>, reactive@haskell.org
Hi Alvaro,
There are several flavours of FRP that approach reactivity from
> Observer patern using the standard FRP conventions? Are these situations
> inside the aims of FRP?
different angles. I'd say Grapefruit is the one most relevant to the
Observer pattern, since it models complex systems as a network of
interconnected circuits, where circuits are effectful entities, and they
can communicate through both discrete and continuous signals. The other
system that might be relevant is Yampa, since you model entities as
stateful signal functions (but unlike in Grapefruit they cannot perform
side effects), and connect them however you want. Incidentally, both of
these approaches are arrow based.
In contrast, Reactive aims to describe the (output over the) whole
lifetime of an entity as a pure value. Dependencies between entities are
established simply by defining one as a function of the other, and
mutual dependencies are naturally allowed. I don't think there's any
meaningful way to connect the Observer pattern to that. In fact, the
basic OO design patterns are often meaningless in functional
programming, because it's a completely different world.
Gergely
--
http://www.fastmail.fm - Or how I learned to stop worrying and
love email again
_______________________________________________
Reactive mailing list
Reactive@haskell.org
http://www.haskell.org/mailman/listinfo/reactive