[reactive] FRP, continuous time and concurrency

Daniel Bünzli daniel.buenzli at erratique.ch
Wed Jun 10 09:25:07 EDT 2009


Le 10 juin 09 à 12:20, Álvaro García Pérez a écrit :

> I agree that there are some issues about the cyclic dependencies  
> with the observer pattern,

Note it is not a problem about _cyclic_ dependencies, the dependencies  
I have shown is a directed acyclic graph. Cyclic dependencies are yet  
another issue you can solve for example with fixed points and  
infinitesimal delays but it's a different problem.

>  but I think that considering it a glitch or not is a matter of  
> phylosophical discussion.

The semantics you really want is no glitches (= instantaneous  
propagation times aka synchrony hypothesis). Because you want to think  
about your values as being for all t : a(t) = b(t) + c(t) and you  
can't do that if you allow the glitches to occur.

You do the same kind of reasoning in electronics when you introduce  
latches and clocks.

> In Daniel's example you will end with the proper value in "a" (even  
> if you have an inproper value for some negligible instants). You  
> only may consider this a problem if your system has poles near those  
> values, which can turn it into a diverging system, and if the  
> updating period is big enough to trigger those diverging effects.  
> For almost any non real-time-control system this is not alike to  
> happen.

You may think it's marginal but it's not: you get into problems as  
soon as your update functions may performs some kind of side effects  
(e.g. write something to a file).

A friend of mine ran exactly into the problem I described with the  
observer pattern in Cocoa, all the glitches triggered expensive and  
unused graphical updates and were ruining the interactive experience  
with the system. Eventually he had to side-step the observation  
mechanism for certain parts of his system.

> And of course, you can implement your own Observer patern imposing  
> some policies in the update ordering, which can help to avoid the  
> glitches.

Yes, you'll end up implementing an frp system. You'll see this will be  
quite different from an observer pattern implementation because you  
need more contextual information about the observers to perform the  
update of the dependents under a synchrony hypothesis.

Best,

Daniel



More information about the Reactive mailing list