Basically this is also referred to as &quot;push&quot; versus &quot;pull&quot;. 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 &quot;node&quot; (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.<div>
<br><div><div>Pulling has the advantage that only those values that are needed are computed, but has the disadvantage that all these values will always be recomputed.</div><div><br></div><div>Pushing has that advantage that only those values that change cause other values to be updated, but has the disadvantage that the values that are updated are actually not needed in the output, or that other changes can cause redundant updates.</div>
<div><br></div><div><div><div>I believe Reactive actually tries to find a good balance between push and pull: a reactive value (which basically is a value sampled at discrete points in time) is only recomputed when any of its inputs changes. Grapefruit also does this but uses a completely different approach.</div>
<div><br></div><div>My personal opinion is that you cannot statically determine which strategy is best (and where to insert nodes that cache values), one would need to do perform profiling to measure the change frequency of sensors (and dependencies) in a typical scenario. Of course sensors could have an estimated change frequency that would help at compile time. For example when playing a videogame the change frequency of the analog stick is very high, while that of the joypad buttons is much lower.</div>
<div><br></div><div> </div><div><br></div><div><div class="gmail_quote">2009/6/9 Álvaro García Pérez <span dir="ltr">&lt;<a href="mailto:agarcia@babel.ls.fi.upm.es">agarcia@babel.ls.fi.upm.es</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br><br>When talking about the Observer pattern I was thinking in the case that appears in the reactive programming entry in Wikipedia (<a href="http://en.wikipedia.org/wiki/Reactive_programming" target="_blank">http://en.wikipedia.org/wiki/Reactive_programming</a>).<br>

<br>If we have a reactive setting then the sentence<br>a := b + c<br>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.<br><br>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.<br>

<br>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?<br>

<br>Thanks,<br><br>Alvaro.<div><div></div><div class="h5"><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Patai Gergely</b> <span dir="ltr">&lt;<a href="mailto:patai_gergely@fastmail.fm" target="_blank">patai_gergely@fastmail.fm</a>&gt;</span><br>

Date: 2009/6/9<br>Subject: Re: [reactive] FRP, continuous time and concurrency<br>To: Álvaro García Pérez &lt;<a href="mailto:agarcia@babel.ls.fi.upm.es" target="_blank">agarcia@babel.ls.fi.upm.es</a>&gt;, <a href="mailto:reactive@haskell.org" target="_blank">reactive@haskell.org</a><br>

<br><br>Hi Alvaro,<br>
<div><br>
&gt; Observer patern using the standard FRP conventions? Are these situations<br>
&gt; inside the aims of FRP?<br>
</div>There are several flavours of FRP that approach reactivity from<br>
different angles. I&#39;d say Grapefruit is the one most relevant to the<br>
Observer pattern, since it models complex systems as a network of<br>
interconnected circuits, where circuits are effectful entities, and they<br>
can communicate through both discrete and continuous signals. The other<br>
system that might be relevant is Yampa, since you model entities as<br>
stateful signal functions (but unlike in Grapefruit they cannot perform<br>
side effects), and connect them however you want. Incidentally, both of<br>
these approaches are arrow based.<br>
<br>
In contrast, Reactive aims to describe the (output over the) whole<br>
lifetime of an entity as a pure value. Dependencies between entities are<br>
established simply by defining one as a function of the other, and<br>
mutual dependencies are naturally allowed. I don&#39;t think there&#39;s any<br>
meaningful way to connect the Observer pattern to that. In fact, the<br>
basic OO design patterns are often meaningless in functional<br>
programming, because it&#39;s a completely different world.<br>
<br>
Gergely<br>
<font color="#888888"><br>
--<br>
<a href="http://www.fastmail.fm" target="_blank">http://www.fastmail.fm</a> - Or how I learned to stop worrying and<br>
                          love email again<br>
<br>
</font></div><br>
</div></div><br>_______________________________________________<br>
Reactive mailing list<br>
<a href="mailto:Reactive@haskell.org">Reactive@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/reactive" target="_blank">http://www.haskell.org/mailman/listinfo/reactive</a><br>
<br></blockquote></div><br></div></div></div></div></div>