<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>Comments on: Trimming inputs in functional reactive programming</title>
	<atom:link href="http://conal.net/blog/posts/trimming-inputs-in-functional-reactive-programming/feed" rel="self" type="application/rss+xml" />
	<link>http://conal.net/blog/posts/trimming-inputs-in-functional-reactive-programming</link>
	<description>Inspirations &#38; experiments, mainly about denotative/functional programming in Haskell</description>
	<lastBuildDate>Sat, 26 Sep 2020 21:06:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.17</generator>
	<item>
		<title>By: Peter Verswyvelen</title>
		<link>http://conal.net/blog/posts/trimming-inputs-in-functional-reactive-programming#comment-281</link>
		<dc:creator><![CDATA[Peter Verswyvelen]]></dc:creator>
		<pubDate>Sat, 13 Dec 2008 16:05:15 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=71#comment-281</guid>
		<description><![CDATA[&lt;p&gt;Some random thoughts:&lt;/p&gt;

&lt;p&gt;What Chris King describes is exactly what most imperative videogames do: everything happens in the &quot;now&quot;, and if you want to keep track of history, you need to use a &quot;history&quot; (aka delay or memory) function explicitly.&lt;/p&gt;

&lt;p&gt;As you mentioned before, imperative systems indeed don&#039;t have the problem of past input being accumulated, since they use mutable variables. Since that gives plenty of side effects, the standard simulation approach is introducing two &quot;world immutable state frames&quot;, one for the current time and for the &quot;earliest&quot; future as determined by the time of the global earliest event occurrence. The two frames are &quot;swapped&quot;, so only one mutable reference cell actually exists. just as in Haskell, when combined parts of these frames don&#039;t change, they can just be copied-by-reference to the next frame. I guess this basically is what Fruit and Yampa tried to mimic with Arrows: don&#039;t make  signals/behaviors/events first class values, so nobody can make a strong reference to the head of the stream; in a sense, signal functions only get to see the current &quot;frame&quot;. As you mentioned, systems like Yampa, Fruit and of course surely the imperative ones don&#039;t give the same notational advantage as one usually gets with Haskell. I&#039;m curious how Reactive will evolve to tackle this nasty dilemma.&lt;/p&gt;

&lt;p&gt;Also if I recall correctly in Yampa one had to mark &lt;em&gt;all&lt;/em&gt; outputs as strict otherwise lazy evaluation will create a space/time leak again in case the outputs are not observed. This can be problematic when e.g. computing only bounding boxes of deformed geometry for doing visual surface elimination: ideally you don&#039;t want to compute the deformed geometry if the bounding boxes are not visible, but in Yampa, this won&#039;t work I guess since the non-strict deformed geometry would cause a space/time leak...&lt;/p&gt;

&lt;p&gt;Other systems like Autodesk&#039;s Maya combine push/pull by having a push system that marks all intermediate and output values that depend on a changed input &quot;dirty&quot;, so that a &quot;pull&quot; of the dirty outputs only re-evaluates those intermediate values that need updating.&lt;/p&gt;

&lt;p&gt;Regarding push versus pull, I feel that in practice one must perform runtime profiling of a reactive application to figure out where in the dependency graph one needs to push or pull, as you can&#039;t determine statically how often event sources will trigger.&lt;/p&gt;

&lt;p&gt;Other game developers (among I believe Tim Sweeney) have done interesting experiments with the software transactional memory to approach reactive behaviors (often called just AI in games ;): let every behavior &quot;run&quot; on its own thread, using STM variables to read/write the &quot;current&quot; state of other behaviors, retrying when read variables are overwritten by other behaviors during the atomic &quot;update&quot;. Since behaviors in general have few dependencies between them, this approach would scale massively, and when the CPU gets more cores, the system gets faster and faster without having to change the code at all :)&lt;/p&gt;

&lt;p&gt;I wonder what the reactive code using STM in Haskell would like like...&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Some random thoughts:</p>

<p>What Chris King describes is exactly what most imperative videogames do: everything happens in the &#8220;now&#8221;, and if you want to keep track of history, you need to use a &#8220;history&#8221; (aka delay or memory) function explicitly.</p>

<p>As you mentioned before, imperative systems indeed don&#8217;t have the problem of past input being accumulated, since they use mutable variables. Since that gives plenty of side effects, the standard simulation approach is introducing two &#8220;world immutable state frames&#8221;, one for the current time and for the &#8220;earliest&#8221; future as determined by the time of the global earliest event occurrence. The two frames are &#8220;swapped&#8221;, so only one mutable reference cell actually exists. just as in Haskell, when combined parts of these frames don&#8217;t change, they can just be copied-by-reference to the next frame. I guess this basically is what Fruit and Yampa tried to mimic with Arrows: don&#8217;t make  signals/behaviors/events first class values, so nobody can make a strong reference to the head of the stream; in a sense, signal functions only get to see the current &#8220;frame&#8221;. As you mentioned, systems like Yampa, Fruit and of course surely the imperative ones don&#8217;t give the same notational advantage as one usually gets with Haskell. I&#8217;m curious how Reactive will evolve to tackle this nasty dilemma.</p>

<p>Also if I recall correctly in Yampa one had to mark <em>all</em> outputs as strict otherwise lazy evaluation will create a space/time leak again in case the outputs are not observed. This can be problematic when e.g. computing only bounding boxes of deformed geometry for doing visual surface elimination: ideally you don&#8217;t want to compute the deformed geometry if the bounding boxes are not visible, but in Yampa, this won&#8217;t work I guess since the non-strict deformed geometry would cause a space/time leak&#8230;</p>

<p>Other systems like Autodesk&#8217;s Maya combine push/pull by having a push system that marks all intermediate and output values that depend on a changed input &#8220;dirty&#8221;, so that a &#8220;pull&#8221; of the dirty outputs only re-evaluates those intermediate values that need updating.</p>

<p>Regarding push versus pull, I feel that in practice one must perform runtime profiling of a reactive application to figure out where in the dependency graph one needs to push or pull, as you can&#8217;t determine statically how often event sources will trigger.</p>

<p>Other game developers (among I believe Tim Sweeney) have done interesting experiments with the software transactional memory to approach reactive behaviors (often called just AI in games ;): let every behavior &#8220;run&#8221; on its own thread, using STM variables to read/write the &#8220;current&#8221; state of other behaviors, retrying when read variables are overwritten by other behaviors during the atomic &#8220;update&#8221;. Since behaviors in general have few dependencies between them, this approach would scale massively, and when the CPU gets more cores, the system gets faster and faster without having to change the code at all <img src="http://conal.net/blog/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley" /></p>

<p>I wonder what the reactive code using STM in Haskell would like like&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: conal</title>
		<link>http://conal.net/blog/posts/trimming-inputs-in-functional-reactive-programming#comment-280</link>
		<dc:creator><![CDATA[conal]]></dc:creator>
		<pubDate>Wed, 10 Dec 2008 19:27:09 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=71#comment-280</guid>
		<description><![CDATA[&lt;p&gt;@Chris:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Your switcher, upon receipt at time T of an event carrying some behavior, starts behaving at time T as that behavior behaved at time 0 ... hence the space-time leak. OK, so why not define switcher to instead behave at time T as the switched-in behavior behaved at ... time T?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The semantics of &lt;code&gt;switcher&lt;/code&gt; is exactly what you are suggesting it be, rather than what you thought it is.  The tricky part is that &lt;code&gt;world&lt;/code&gt; contains information for times earlier than T, so there can be quite a lot of catching up to do.&lt;/p&gt;

&lt;p&gt;Is there a paper that defines the semantics of OCamlRT?&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>@Chris:</p>

<blockquote>
  <p>Your switcher, upon receipt at time T of an event carrying some behavior, starts behaving at time T as that behavior behaved at time 0 &#8230; hence the space-time leak. OK, so why not define switcher to instead behave at time T as the switched-in behavior behaved at &#8230; time T?</p>
</blockquote>

<p>The semantics of <code>switcher</code> is exactly what you are suggesting it be, rather than what you thought it is.  The tricky part is that <code>world</code> contains information for times earlier than T, so there can be quite a lot of catching up to do.</p>

<p>Is there a paper that defines the semantics of OCamlRT?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris King</title>
		<link>http://conal.net/blog/posts/trimming-inputs-in-functional-reactive-programming#comment-279</link>
		<dc:creator><![CDATA[Chris King]]></dc:creator>
		<pubDate>Wed, 10 Dec 2008 16:23:55 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=71#comment-279</guid>
		<description><![CDATA[&lt;p&gt;So, the problem with cat1 seems to be more a problem of the semantics of switcher than of any need for extra FRP mechanisms.  Your switcher, upon receipt at time T of an event carrying some behavior, starts behaving at time T as that behavior behaved at time 0... hence the space-time leak.  OK, so why not define switcher to instead behave at time T as the switched-in behavior behaved at... time T?  If someone really wants to look at a behavior&#039;s past behavior, then they must explicitly delay it with some &quot;delay&quot; operator.  This method worked well with my OCamlRT system.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>So, the problem with cat1 seems to be more a problem of the semantics of switcher than of any need for extra FRP mechanisms.  Your switcher, upon receipt at time T of an event carrying some behavior, starts behaving at time T as that behavior behaved at time 0&#8230; hence the space-time leak.  OK, so why not define switcher to instead behave at time T as the switched-in behavior behaved at&#8230; time T?  If someone really wants to look at a behavior&#8217;s past behavior, then they must explicitly delay it with some &#8220;delay&#8221; operator.  This method worked well with my OCamlRT system.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
