<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>My Digital Neuron</title>
	<atom:link href="http://benhutchison.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://benhutchison.wordpress.com</link>
	<description>Ben Hutchison's contribution to our Internet mind</description>
	<lastBuildDate>Fri, 09 Oct 2009 08:27:05 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='benhutchison.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/694ac53a21a7d6fb1662392f95a6e9e8?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>My Digital Neuron</title>
		<link>http://benhutchison.wordpress.com</link>
	</image>
			<item>
		<title>Escape Analysis changes the rules for performance critical code</title>
		<link>http://benhutchison.wordpress.com/2009/10/09/escape-analysis-changes-the-rules-for-performance-critical-code/</link>
		<comments>http://benhutchison.wordpress.com/2009/10/09/escape-analysis-changes-the-rules-for-performance-critical-code/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 08:27:05 +0000</pubDate>
		<dc:creator>benhutchison</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://benhutchison.wordpress.com/?p=209</guid>
		<description><![CDATA[The last few days its been dawning on me how Escape Analysis changes the rules on performance critical code.
Its a big deal. Short lived objects become nearly free to use. Convenience rules. If you need to tuple-ize 2 Ints, then stick them in a List, to pass through an API, only to immediately unpack back [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=209&subd=benhutchison&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>The last few days its been dawning on me how <a href="http://en.wikipedia.org/wiki/Escape_analysis">Escape Analysis </a>changes the rules on performance critical code.</p>
<p>Its a big deal. Short lived objects become nearly free to use. Convenience rules. If you need to tuple-ize 2 Ints, then stick them in a List, to pass through an API, only to immediately unpack back to the Ints on the other side: <em>go ahead</em>. <em>Dont worry. </em>Those objects probably will never be created; they&#8217;re <em>conceptually</em> there.</p>
<p>Get back to what you ought to be doing: Abstracting and Composing.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benhutchison.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benhutchison.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benhutchison.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benhutchison.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benhutchison.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benhutchison.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benhutchison.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benhutchison.wordpress.com/209/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benhutchison.wordpress.com/209/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benhutchison.wordpress.com/209/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=209&subd=benhutchison&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benhutchison.wordpress.com/2009/10/09/escape-analysis-changes-the-rules-for-performance-critical-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/173eb485ae275ac7a615da353eabe753?s=96&#38;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&#38;r=R" medium="image">
			<media:title type="html">benhutchison</media:title>
		</media:content>
	</item>
		<item>
		<title>Changeset Merging: the other, other, concurrency paradigm</title>
		<link>http://benhutchison.wordpress.com/2009/09/06/changeset-merging-the-other-other-concurrency-paradigm/</link>
		<comments>http://benhutchison.wordpress.com/2009/09/06/changeset-merging-the-other-other-concurrency-paradigm/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 14:07:03 +0000</pubDate>
		<dc:creator>benhutchison</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://benhutchison.wordpress.com/?p=207</guid>
		<description><![CDATA[Software Transactional Memory relies on optimistic locking to avoid deadlock, but as a result suffers at least one serious problem.
An optimistic update transaction will succeed when the data being updated remains stable for the period of the transaction.
If n threads are trying to update a shared variable at m Hz, on average there will be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=207&subd=benhutchison&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Software Transactional Memory relies on optimistic locking to avoid deadlock, but as a result suffers at least one serious problem.</p>
<p>An optimistic update transaction will succeed when the data being updated remains stable for the period of the transaction.</p>
<p>If <strong>n</strong> threads are trying to update a shared variable at <strong>m</strong> Hz, on average there will be an attempt to change the variables value about every <strong>(n m)-1 </strong>secs.<strong><br />
</strong></p>
<p>As that interval falls towards the average time it takes to perform an update transaction, the success rate for transactions will fall precipitously to almost zero, and the system will grind to a starved halted state that&#8217;s as bad as deadlock.</p>
<p><strong>We must make some progress even under heavy contention</strong></p>
<p>Pessimistic locking is one approach, but it suffers from deadlock problems.</p>
<p>The software equivalent of &#8220;Changeset Merging&#8221; is another.</p>
<p>In a version controlled system, we do not Revert Changes any time someone else has edited the same file. That seems wasteful, but that&#8217;s essentially what basic STM does. Rather, someone or something examines the two conflicting changesets, and merges them together. This might involve discarding part or all of one change, or some blend.</p>
<p><strong>Changeset merges in STM</strong></p>
<p>A transaction could declare a <em>merge routine </em>to be run after a conflict. It is given the current system state, and the transaction that lost out on the update race, and can either transform them into one merged state that is saved, or fallback to the default retry if  it cannot do so.</p>
<p>Of course, it&#8217;s likely there are other (3rd, 4th ..etc) transactions in progress while that merge is taking place. But this can simply be resolved by the running the merge routine again, which now blends the previous merge with the next incoming transaction, as the new system state.</p>
<p>I must credit [http://lists.basho.com/pipermail/riak-users_lists.basho.com/2009-September/000029.html] and [http://debasishg.blogspot.com/] for leading me to this idea.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benhutchison.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benhutchison.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benhutchison.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benhutchison.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benhutchison.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benhutchison.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benhutchison.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benhutchison.wordpress.com/207/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benhutchison.wordpress.com/207/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benhutchison.wordpress.com/207/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=207&subd=benhutchison&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benhutchison.wordpress.com/2009/09/06/changeset-merging-the-other-other-concurrency-paradigm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/173eb485ae275ac7a615da353eabe753?s=96&#38;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&#38;r=R" medium="image">
			<media:title type="html">benhutchison</media:title>
		</media:content>
	</item>
		<item>
		<title>Arcadia&#8217;s level editor lives again</title>
		<link>http://benhutchison.wordpress.com/2009/07/06/arcadias-level-editor-lives-again/</link>
		<comments>http://benhutchison.wordpress.com/2009/07/06/arcadias-level-editor-lives-again/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 09:15:05 +0000</pubDate>
		<dc:creator>benhutchison</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://benhutchison.wordpress.com/?p=205</guid>
		<description><![CDATA[This is a sight I havent seen for 3 months &#8211; my game&#8217;s level editor working. Its a relief to have it back (partially).
Heavy refactoring of game code, technical debt and experimentation have conspired to make it broken. Its taken much of the past month to fix.

       <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=205&subd=benhutchison&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>This is a sight I havent seen for 3 months &#8211; my game&#8217;s level editor working. Its a relief to have it back (partially).</p>
<p>Heavy refactoring of game code, technical debt and experimentation have conspired to make it broken. Its taken much of the past month to fix.</p>
<p><img class="aligncenter size-full wp-image-204" title="Resource_-_ArcadiaResourcesScenariosNuWoodhaven.scenario.xml_-_Eclipse_SDK-2009.07.06-19.03.27" src="http://benhutchison.files.wordpress.com/2009/07/resource_-_arcadiaresourcesscenariosnuwoodhaven-scenario-xml_-_eclipse_sdk-2009-07-06-19-03-27.jpg?w=477&#038;h=328" alt="Resource_-_ArcadiaResourcesScenariosNuWoodhaven.scenario.xml_-_Eclipse_SDK-2009.07.06-19.03.27" width="477" height="328" /></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benhutchison.wordpress.com/205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benhutchison.wordpress.com/205/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benhutchison.wordpress.com/205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benhutchison.wordpress.com/205/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benhutchison.wordpress.com/205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benhutchison.wordpress.com/205/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benhutchison.wordpress.com/205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benhutchison.wordpress.com/205/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benhutchison.wordpress.com/205/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benhutchison.wordpress.com/205/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=205&subd=benhutchison&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benhutchison.wordpress.com/2009/07/06/arcadias-level-editor-lives-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/173eb485ae275ac7a615da353eabe753?s=96&#38;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&#38;r=R" medium="image">
			<media:title type="html">benhutchison</media:title>
		</media:content>

		<media:content url="http://benhutchison.files.wordpress.com/2009/07/resource_-_arcadiaresourcesscenariosnuwoodhaven-scenario-xml_-_eclipse_sdk-2009-07-06-19-03-27.jpg" medium="image">
			<media:title type="html">Resource_-_ArcadiaResourcesScenariosNuWoodhaven.scenario.xml_-_Eclipse_SDK-2009.07.06-19.03.27</media:title>
		</media:content>
	</item>
		<item>
		<title>XSL for Xml Schema Migration &amp; Data Transformation</title>
		<link>http://benhutchison.wordpress.com/2009/07/06/xsl-for-xml-schema-migration-data-transformation/</link>
		<comments>http://benhutchison.wordpress.com/2009/07/06/xsl-for-xml-schema-migration-data-transformation/#comments</comments>
		<pubDate>Mon, 06 Jul 2009 02:20:23 +0000</pubDate>
		<dc:creator>benhutchison</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://benhutchison.wordpress.com/?p=196</guid>
		<description><![CDATA[Ive recently been using XSL to do schema migration on XML data; ie small, incremental modifications to XML where most of the existing data is preserved. The application was to massage some Heroes of Arcadia level data, serialized with XStream, to keep in step with code changes I&#8217;d made.
First I tried using Scala&#8217;s scala.xml.transform.RewriteRule, but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=196&subd=benhutchison&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Ive recently been using XSL to do schema migration on XML data; ie small, incremental modifications to XML where most of the existing data is preserved. The application was to massage some Heroes of Arcadia level data, serialized with XStream, to keep in step with code changes I&#8217;d made.</p>
<p>First I tried using Scala&#8217;s<a href="http://www.scala-lang.org/docu/files/api/scala/xml/transform/RewriteRule.html"> scala.xml.transform.RewriteRule</a>, but hit some bugs (#2124 and #2125) that convinced me to let it stabilize further before applied use.</p>
<p>So instead I used the new<a href="http://wiki.eclipse.org/XSLT_Project"> XSL support</a> in Eclipse 3.5  (in WTP 3.1). Seems to work well.</p>
<p>I&#8217;d only used XSL back in 2001 and never fully understood it. I found most entry level tutorials (eg ZVON and W3 Schools) unhelpful for this kind of application, because they don&#8217;t explain copy existing nodes well.</p>
<p>My breakthrough came when I discovered Jesper Tverskov&#8217;s article on the <a href="http://www.xmlplease.com/xsltidentity#s9">Identity Template</a>. This explains how to recursively process XML by copying with modification.</p>
<p>One case Jesper doesnt cover is copying where segments of the subtree are omitted and others are retained but modified.</p>
<p>I solved that in my template by using a <strong>&lt;for-each&gt;</strong> to pickout the subtree part I wanted to preserve, wrapping the <strong>&lt;xsl:copy&gt;&lt;xsl:apply-templates select=&#8221;@*|node()&#8221;/&gt;&lt;/xsl:copy&gt;</strong> structure thats fundamental to recursive processing.</p>
<pre>&lt;xsl:template match="@*|node()"&gt;
&lt;xsl:copy&gt;
&lt;xsl:apply-templates select="@*|node()"/&gt;
&lt;/xsl:copy&gt;
&lt;/xsl:template&gt;

&lt;xsl:template match="//vector[default]"&gt;
&lt;size&gt;&lt;xsl:value-of select="default/elementCount"/&gt;&lt;/size&gt;
&lt;xsl:for-each select="default/elementData" &gt;
&lt;xsl:copy&gt;
&lt;xsl:apply-templates select="@*|node()"/&gt;
&lt;/xsl:copy&gt;
&lt;/xsl:for-each&gt;
&lt;/xsl:template&gt;</pre>
<p>Sample input and output:</p>
<pre>&lt;__features id="50" serialization="custom"&gt;
&lt;vector&gt;
&lt;default&gt;
&lt;capacityIncrement&gt;4&lt;/capacityIncrement&gt;
&lt;elementCount&gt;1&lt;/elementCount&gt;
&lt;elementData id="51"&gt;
&lt;arcadia.domain.Unit reference="46"/&gt;
&lt;null/&gt;
&lt;null/&gt;
&lt;null/&gt;
&lt;null/&gt;
&lt;/elementData&gt;
&lt;/default&gt;
&lt;/vector&gt;
&lt;/__features&gt;

&lt;__features id="50" serialization="custom"&gt;
&lt;size&gt;1&lt;/size&gt;
&lt;elementData id="51"&gt;
&lt;arcadia.domain.Unit reference="46"/&gt;
&lt;null/&gt;
&lt;null/&gt;
&lt;null/&gt;
&lt;null/&gt;
&lt;/elementData&gt;
&lt;/__features&gt;
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benhutchison.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benhutchison.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benhutchison.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benhutchison.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benhutchison.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benhutchison.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benhutchison.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benhutchison.wordpress.com/196/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benhutchison.wordpress.com/196/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benhutchison.wordpress.com/196/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=196&subd=benhutchison&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benhutchison.wordpress.com/2009/07/06/xsl-for-xml-schema-migration-data-transformation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/173eb485ae275ac7a615da353eabe753?s=96&#38;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&#38;r=R" medium="image">
			<media:title type="html">benhutchison</media:title>
		</media:content>
	</item>
		<item>
		<title>Entities, Programs and Bindings: an embryonic programming paradigm</title>
		<link>http://benhutchison.wordpress.com/2009/06/20/entities-programs-and-bindings-an-embryonic-programming-paradigm/</link>
		<comments>http://benhutchison.wordpress.com/2009/06/20/entities-programs-and-bindings-an-embryonic-programming-paradigm/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 13:13:53 +0000</pubDate>
		<dc:creator>benhutchison</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://benhutchison.wordpress.com/?p=192</guid>
		<description><![CDATA[!Warning! This is one of my most abstract and part-formed blog posts, a rough sketch of some ideas that are still forming in my mind. You might want to skip onto to something more tangible.
I beleive the ideas expressed in Rich Hickey&#8217;s monograph &#8220;On State and Identity&#8221; (and my own independent grasping toward these ideas) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=192&subd=benhutchison&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><strong>!Warning! </strong>This is one of my most abstract and part-formed blog posts, a rough sketch of some ideas that are still forming in my mind. You might want to skip onto to something more tangible.</p>
<p>I beleive the ideas expressed in Rich Hickey&#8217;s monograph &#8220;<a href="http://clojure.org/state">On State and Identity</a>&#8221; (and my own independent <a href="http://benhutchison.wordpress.com/2009/06/15/appropriate-use-of-mutable-data-in-object-functional-systems/">grasping toward these ideas</a>) are true.</p>
<p>The past few days I have been contemplating what large scale software look like in this model. The answer seems quite exciting. Traditional immutable versus mutable state conflicts are finally cleared away &#8211; instead, each has its defined place.</p>
<p><strong>Values</strong></p>
<p>A value is something time-invariant. All observations of a value should be equivalent. Computationally, a value may be passed around in unresolved or part-resolved form, and further computation is required when parts of the value are accessed.</p>
<p><strong>Entities</strong></p>
<p>An entity is a time-varying stream of values associated with a particular identity. Note that the history of an entity&#8217;s value, as well its its current value, is available, which is why a Stream is returned (the history may need to be truncated to fit within real-world computational and storage limit).</p>
<p>def entity[T](id: ID): Stream[T, Timestamp]</p>
<p>Entities change their value transactionally. All changes to the value are recorded permanently. Changes are timestamped in system-time.</p>
<p>def update[T](id: ID, T newValue) //in transaction</p>
<p>Logically, the number of entities is infinite and they are never created or destroyed. If one asks for an entity which has not previously been set to a value, then it returns an empty stream.</p>
<p>Note: There is no way to ask what entities exist. One must find entities via references from other already known entities, and not via a system-level &#8220;browse-style&#8221; method.</p>
<p><strong>IDs</strong></p>
<p>An opaque immutable value representing an identity. IDs can be used to obtain the values of the entity they reference. IDs are values like any other, can be stored as/in entities, passed to functions, etc.</p>
<p>There is one special identity, system-time. This refers to an entity that holds the current system time, that updates in some discretized approximation of a smoothly changing variable.</p>
<p><strong>Programs</strong></p>
<p>Programs are the things that happen, the things that update entity values and respond to updates in entity state.<strong> </strong>Most operations are functional, but imperative operations may be required when communicating with external systems, ie for IO.<strong><br />
</strong></p>
<p><strong>Functions with Bindings</strong></p>
<p>Functional Programs consist of two things:</p>
<ul>
<li>a (purely functional) Function from N inputs to M outputs. It can and should contain other functions nested to any depth.</li>
<li>a Binding of the function&#8217;s inputs and outputs to either
<ul>
<li>the value of an entity. In the case of inputs, this means the function is evaluated passing the entity&#8217;s value as a parameter. For outputs, this means the entity&#8217;s value is assigned that value returned by the function.</li>
<li>the event of an entity changing value, for inputs only. This means that a function fires when a entity has changed value. (cf <a href="http://www.haskell.org/haskellwiki/Functional_Reactive_Programming">FRP</a>)</li>
</ul>
</li>
</ul>
<p>The ability to launch programs when entities change state is a key to the operation of the paradigm.</p>
<p><strong>Imperative Operations</strong></p>
<p>Programs can also run imperatively, in order to sequence IO operations for communicating without outside systems.  They can bind inputs to entity values or entity change events, exactly as functional programs do, but do not return any outputs that are assigned back onto entities.</p>
<p>This explanation is rather terse. I need to give some examples, some diagrams, and some explanations. Perahps some outline of what my goals are. To do anything practical with this paradigm requires alot of infrastructure built on top of this base. For now, Im mainly writing this down as a record of my own thought process, for later re-editing</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benhutchison.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benhutchison.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benhutchison.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benhutchison.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benhutchison.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benhutchison.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benhutchison.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benhutchison.wordpress.com/192/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benhutchison.wordpress.com/192/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benhutchison.wordpress.com/192/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=192&subd=benhutchison&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benhutchison.wordpress.com/2009/06/20/entities-programs-and-bindings-an-embryonic-programming-paradigm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/173eb485ae275ac7a615da353eabe753?s=96&#38;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&#38;r=R" medium="image">
			<media:title type="html">benhutchison</media:title>
		</media:content>
	</item>
		<item>
		<title>Oh, how shall I spend my Creative Mana?</title>
		<link>http://benhutchison.wordpress.com/2009/06/20/oh-how-shall-i-spend-my-creative-mana/</link>
		<comments>http://benhutchison.wordpress.com/2009/06/20/oh-how-shall-i-spend-my-creative-mana/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 11:06:27 +0000</pubDate>
		<dc:creator>benhutchison</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[life & culture]]></category>

		<guid isPermaLink="false">http://benhutchison.wordpress.com/?p=188</guid>
		<description><![CDATA[Im coming late to the party: in February Errki Lindpere posed an worthwhile question on his blog that want to talk about:
&#8220;Anyway, please comment, if you are also a programmer, or a geek with a different specialization, who has a lot of hobby projects, how do you manage not to get swamped with them or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=188&subd=benhutchison&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Im coming late to the party: in February Errki Lindpere posed an <a href="http://villane.wordpress.com/2009/02/18/my-head-asplode/">worthwhile question</a> on his blog that want to talk about:</p>
<p><em>&#8220;Anyway, please comment, if you are also a programmer, or a geek with a different specialization, who has a lot of hobby projects, how do you manage not to get swamped with them or get the feeling that you are always working on cool stuff but never releasing?&#8221;</em></p>
<p>Myself, I have been developing a fantasy mobile game Heroes of Arcadia since early 2005. While so far Ive got some funding, formed a company and released 2 beta versions, a finished game remains /at least/ 12 months off. [full story:  http://bit.ly/e3UKE]</p>
<p>I would <strong>never</strong> have dreamed in early 2005 that I&#8217;d still be unfinished in 2009. I would never have imagined the marathon effort it  would require of me to create a polished, fun, playable and stable game.</p>
<p>This experience has taught me an important life lesson: Pick your creative battles!</p>
<p>Our lives are finite. There are actually a limited number of things one person can attempt and complete in one lifetime.</p>
<p>Therefore, I feel it&#8217;s important to try to understand what you truly aspire to, what you are really good at, what you&#8217;re going to be happy doing. Find the <em>sweet spot</em> and really try to focus on it.</p>
<p>My strategy increasingly is to ensure that everything I am involved with fits with my overall aspirations, reinforces each other, and reuses what Ive learned and done already in life. In a word, <em>Synergy</em>.</p>
<p>By trying to create something large, Ive gained a sense of how much creative &#8216;mana&#8217; Ive got in me. The blunt truth is that it feels somewhat finite, and less than I had idealistically imagined in my youthful daydreams.</p>
<p>So I want to ensure that I spend this mana in the most fruitful way I can.</p>
<p>Anything I attempt to do, I want to</p>
<ul>
<li>yield some outcome</li>
<li>create something beautiful</li>
<li>be proud of what Im doing</li>
<li>enjoy the journey as the well as the destination</li>
<li>learn and grow from</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benhutchison.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benhutchison.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benhutchison.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benhutchison.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benhutchison.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benhutchison.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benhutchison.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benhutchison.wordpress.com/188/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benhutchison.wordpress.com/188/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benhutchison.wordpress.com/188/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=188&subd=benhutchison&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benhutchison.wordpress.com/2009/06/20/oh-how-shall-i-spend-my-creative-mana/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/173eb485ae275ac7a615da353eabe753?s=96&#38;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&#38;r=R" medium="image">
			<media:title type="html">benhutchison</media:title>
		</media:content>
	</item>
		<item>
		<title>Appropriate Use of Mutable Data in Functional Software Systems</title>
		<link>http://benhutchison.wordpress.com/2009/06/15/appropriate-use-of-mutable-data-in-object-functional-systems/</link>
		<comments>http://benhutchison.wordpress.com/2009/06/15/appropriate-use-of-mutable-data-in-object-functional-systems/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 05:38:28 +0000</pubDate>
		<dc:creator>benhutchison</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://benhutchison.wordpress.com/?p=178</guid>
		<description><![CDATA[Since I wrote this post, I have become aware of Rich Hickey&#8217;s discussion of State and Identity on Clojure.org. I feel he expresses the same truths in a generally clearer, sharper way than I have managed to here&#8230;
++++++++++++++++++
This post arose out of a Twitter discussion with Daniel Spiewak on twitter. I dont know whether Newton [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=178&subd=benhutchison&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Since I wrote this post, I have become aware of Rich Hickey&#8217;s discussion of <a href="http://clojure.org/state">State and Identity</a> on Clojure.org. I feel he expresses the same truths in a generally clearer, sharper way than I have managed to here&#8230;</p>
<p>++++++++++++++++++</p>
<p>This post arose out of a Twitter <a href="http://twitter.com/djspiewak/status/2171480174">discussion </a>with <a href="http://www.codecommit.com/blog/">Daniel Spiewak</a> on twitter. I dont know whether Newton could have encoded his laws of Mechanics into 140 characters, but I need more space to share my thoughts on the (hopefully) simpler matter of: <em>What is appropriate use of Mutable Data in Functional software systems</em>?</p>
<p><strong>Entities and Identities</strong></p>
<p>I feel the answer is inter-connected with the idea of <em>Identity</em> represented by the data in a software system. As <a href="http://en.wikipedia.org/wiki/Domain-driven_design">Eric Evans</a> explained so well, data that has a strong identity is called an <a href="http://domaindrivendesign.org/node/109"><em>Entity</em></a>.</p>
<p>A classic example, present in almost every business software system, is some &#8220;User Entity&#8221;, modeling a person&#8217;s account in that system. In such a system, when we speak about a particular User, conceptually we really want there to be <em>only one </em>such entity in existence.</p>
<p>The identity of an entity is normally governed by a <em>unique </em>&amp; <em>immutable </em>primary key. Other than the primary key, everything attribute of the entity may change. A User, for example, might change their favorites list, address, name or possibly even sex.</p>
<p><strong>Functional Interaction with Entities</strong></p>
<p>Conceptually there&#8217;s only one entity. But actually, there&#8217;s only one &#8220;offical version&#8221;, and other possibly divergent versions, which may be promoted to official status.</p>
<p>Entities should be accessed via transactions (in broadest sense, including <a href="http://en.wikipedia.org/wiki/Software_transactional_memory">STM </a>or concurrent data structures). A functional program makes an immutable snapshot of the entity at some time. It may derive an updated version of the entity from that, and then request that its copy be promoted as the &#8220;master&#8221; copy. Typically, this promotion would be done using optimistic concurrency, so that if another process changed the entity first, the update must retry. But other models (eg pessimistic concurr, change merging) might be used instead.</p>
<p>Note that</p>
<ul>
<li>An executing program has no guarantee that it operates on the &#8220;latest&#8221; version of an entity.</li>
<li>After the fact, it is possible to say &#8220;at time X, the official state of the entity was thus&#8230;&#8221;, by time-stamping updates. This is important, for example, in a legal case if we wanted to know who owned some property at a particular point in time in a dispute.</li>
<li>This is <a href="http://en.wikipedia.org/wiki/Concurrent_computing">either Shared State and Message Passing concurrency</a>. We can view the &#8220;official entity version&#8221; as shared state, or as an agent to whom we send read-entity and write-entity messages.</li>
</ul>
<p>Pretty much as Daniel put it (borrowed from Clojure, apparently) <a href="http://twitter.com/djspiewak/status/2172192522">&#8220;<span><span>Everything is immutable except for concurrency-safe entities</span></span>&#8220;</a></p>
<p><strong>The meaning of Entity Update</strong></p>
<p>Something special happens when an entity&#8217;s master state is updated. This is the synchronization/convergence point between separate threads and components. It is the boundary between the functional code, which transforms some input state into some new entity states, and the imperative world of sequentially updating mutable state. It is the end of a Unit of Work, a time when a functional program says &#8220;this is not a means to an end, this is the end&#8221;. The transient becomes persisted, allowing the state in the current moment to affect and interact with other points in time.</p>
<p><strong>Granularity, </strong><strong> </strong><strong>Scalability </strong><strong> </strong><strong>and Consistency<br />
</strong></p>
<p>So how many entities do we need? Coarse or fine grained? A few larger, internally complex entities, or many simpler and smaller entities?</p>
<p>Its a matter of chosing a point on a spectrum whose extremes are</p>
<ul>
<li>A single StateOfTheWorld entity whose attributes encompass all data in the system. As in a purely functional system; the program sees only its own private version of state, without any interference.</li>
<li>Every tiny piece of data is its own entity. This would be like programming only with atomic global variables. Everyone sees and shares all state without privacy.</li>
</ul>
<p>I don&#8217;t think there&#8217;s one &#8220;right&#8221; answer. All I can offer is an outline of some design forces acting in either direction:</p>
<p>Fewer Entities each containing more data</p>
<ul>
<li><strong>For: data consistency within an entity</strong>. A coarse grained entity starts in a consistent state and is never externally updated. A program is free to compute changes to the entity&#8217;s state independently without risk of being disrupted by other program&#8217;s updates. The benefits of the purely functional model accrue.</li>
<li><strong>Against: Contention if multiple processes try to simultaneously update the same entity</strong>. For an extreme example, imagine if two functional programs simulatneously computed a new StateOfTheWorld entity &#8211; they would operate in a perpetual state of fatal contention.</li>
<li><strong>Against: Copying Overhead. </strong>Need to copy minimum of log(N)  (where N is the &#8220;size&#8221; of the entity), and often much more, of an entity&#8217;s data to update it.</li>
</ul>
<p>More Entities each containing less data</p>
<ul>
<li><strong>For: Less copying overhead. </strong>We still need to copy minimum of log(N)  of an entity&#8217;s data to update it, but N is smaller.</li>
<li><strong>For: Less contention </strong>when multiple processes try to simultaneously update entities, because the updates are spread across more fine-grained locks.</li>
<li><strong>Against: data inconsistency between inter-related entities.</strong> We either have to tolerate inconsistency between entities (eg Person entity &#8216;Ben&#8217; has a son &#8216;Otto&#8217;, but Person entity &#8216;Otto&#8217; doesnt have a father &#8216;Ben&#8217;), or introduce an extra layer of locking over the entities (as most databases do). Note that if we inroduce locking above the entity level, our contention benefits go away, and we may be creating de-facto coarse-grain entities.</li>
</ul>
<p>Its interesting to note that the same trade-off between consistency and scalability shows up many times elsewhere &#8211; <a href="http://www.infoq.com/news/2008/03/ebaybase">eBay being a nice example</a>.</p>
<p><strong>Non-Global Identity</strong></p>
<p>Above, I presented Entities as having a globally unique identity. Much of the time, thats a good way to think about them, but be aware it is a simplification. In fact, identity is inherently defined relative to some scope. That scope needn&#8217;t be global.</p>
<p>Here are 3 different scopes for the entity <em>The number of people on earth at midnight on Dec 31, 1999</em>.</p>
<ol>
<li>The globally true answer that an omnipotent god might know</li>
<li>My national government&#8217;s official figure</li>
<li>My personal estimate</li>
</ol>
<p>Scopes may nest. Im still contemplating exactly how this affects the design of systems with mutable data.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benhutchison.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benhutchison.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benhutchison.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benhutchison.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benhutchison.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benhutchison.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benhutchison.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benhutchison.wordpress.com/178/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benhutchison.wordpress.com/178/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benhutchison.wordpress.com/178/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=178&subd=benhutchison&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benhutchison.wordpress.com/2009/06/15/appropriate-use-of-mutable-data-in-object-functional-systems/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/173eb485ae275ac7a615da353eabe753?s=96&#38;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&#38;r=R" medium="image">
			<media:title type="html">benhutchison</media:title>
		</media:content>
	</item>
		<item>
		<title>OO/Imperative programmers: &#8216;Study Functional Programming or Be Ignorant&#8217;</title>
		<link>http://benhutchison.wordpress.com/2009/06/02/study-functional-programming-or-be-ignorant/</link>
		<comments>http://benhutchison.wordpress.com/2009/06/02/study-functional-programming-or-be-ignorant/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 03:56:34 +0000</pubDate>
		<dc:creator>benhutchison</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://benhutchison.wordpress.com/?p=169</guid>
		<description><![CDATA[Right now, if you want to understand the state of the art in computer programming, those are your choices as I see them.
Sorry to be so blunt &#8230; please don&#8217;t shoot the messenger.
My awakening started when I began searching for a better Java, and found Scala. Scala had these weird (in my  ignorance) functional [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=169&subd=benhutchison&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Right now, if you want to understand the state of the art in computer programming, those are your choices as I see them.</p>
<p>Sorry to be so blunt &#8230; please don&#8217;t shoot the messenger.</p>
<p>My awakening started when I began searching for a better Java, and <a href="http://benhutchison.wordpress.com/2008/07/01/retooling-for-scala/">found Scala</a>. Scala had these weird (in my  ignorance) functional features and learned Scala people often talked about Haskell. A uni friend <a href="http://www.cs.mu.oz.au/~bjpop/">Bernie Pope</a> raved about it too.</p>
<p>I took a look at Haskell. It wasn&#8217;t a pleasurable experience. Much of the code was almost incomprehensible. Half the concepts I&#8217;d never heard of before. It made me feel stupid, but actually what I was was <em>ignorant</em>.</p>
<p>I say <em>ignorant</em>, rather than <em>innocent</em>, because Haskell has been around for over a decade, and FP much longer.</p>
<p>I still struggle to read most Haskell, and I certainly can&#8217;t use it to build anything. But I am starting to get a sense of just how sophisticated it is, and a map of it&#8217;s concepts in my mind. I began by going down a rabbit-hole, and expected to find a burrow, a community of Haskelliers programming in their own unique way. Instead, bit by bit Ive realised Ive ended up in a vast cavern absolutely full of stuff I barely even knew existed.</p>
<ul>
<li><a href="http://www.haskell.org/all_about_monads/html/index.html">Monads &amp; friends</a></li>
<li><a href="http://www.haskell.org/sitewiki/images/8/85/TMR-Issue13.pdf">Typeclasses</a> (see &#8220;Typeclassopedia&#8221;, a must-read for advanced programmers, if only to appreciate what you don&#8217;t yet know <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</li>
<li>Composability (Need a good succinct web ref here, please suggest)</li>
<li><a href="http://blog.interlinked.org/tutorials/haskell_laziness.html">Laziness</a></li>
<li><a href="http://en.wikipedia.org/wiki/Higher-order_function">Higher order functions</a></li>
<li><a href="http://en.wikipedia.org/wiki/Functional_reactive_programming">Functional Reactive Programming</a></li>
<li><a href="http://www.haskell.org/haskellwiki/Software_transactional_memory">Software Transactional memory</a></li>
<li><a href="http://www.haskell.org/haskellwiki/Pointfree">Point-free style</a></li>
<li><a href="http://en.wikipedia.org/wiki/Zipper_(data_structure)">Zippers</a>, <a href="http://scienceblogs.com/goodmath/2009/05/finally_finger_trees.php">Finger Trees</a> and other <a href="http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf">Immutable Data Structures</a></li>
<li><a href="http://www.realworldhaskell.org/">Real World Haskell </a>and <a href="http://www.haskell.org/soe/">Hudak&#8217;s book</a></li>
</ul>
<p>The bit that stirs me up is that this &#8220;stuff&#8221; isn&#8217;t, repeat<em> is not</em>, Haskell-specific. Its rooted in the fabric of our reality, in our mathematics and our problem domains, and bits poke up like the tips of icebergs into mainstream OO languages, their true structure part-revealed. But rarely in the OO-world have I found such carefully abstracted and subtle techniques of programming in daily use.</p>
<p>Ideas from Haskell &amp; Functional Programming will continue to flow into the mainstream over the next couple of decades. Innovations will be trumpeted, trends identified, features debated, technologies evangelized.</p>
<p>But personally, Im too curious (and too lazy a typist) to wait that long.,</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benhutchison.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benhutchison.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benhutchison.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benhutchison.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benhutchison.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benhutchison.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benhutchison.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benhutchison.wordpress.com/169/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benhutchison.wordpress.com/169/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benhutchison.wordpress.com/169/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=169&subd=benhutchison&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benhutchison.wordpress.com/2009/06/02/study-functional-programming-or-be-ignorant/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/173eb485ae275ac7a615da353eabe753?s=96&#38;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&#38;r=R" medium="image">
			<media:title type="html">benhutchison</media:title>
		</media:content>
	</item>
		<item>
		<title>Why Javaspaces are not for me</title>
		<link>http://benhutchison.wordpress.com/2009/05/26/why-javaspaces-are-not-for-me/</link>
		<comments>http://benhutchison.wordpress.com/2009/05/26/why-javaspaces-are-not-for-me/#comments</comments>
		<pubDate>Tue, 26 May 2009 01:57:40 +0000</pubDate>
		<dc:creator>benhutchison</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://benhutchison.wordpress.com/?p=162</guid>
		<description><![CDATA[In 2001/2002 I worked for 18 months at the now defunct UK Javaspace vendor Intamission, building their Javaspace implementation Autevo, which went on to  &#8230; er&#8230; &#8220;inspire&#8221; the open source Blitz product , released by Intamission co-founder &#38; lead programmer Dan Creswell after he left the company.
One of the less satisfying aspects of that project [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=162&subd=benhutchison&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In 2001/2002 I worked for 18 months at the now defunct UK Javaspace vendor Intamission, building their Javaspace implementation <em>Autevo, </em>which went on to  &#8230; er&#8230; &#8220;inspire&#8221; the open source <a href="http://www.dancres.org/blitz/index.html">Blitz </a>product , released by Intamission co-founder &amp; lead programmer Dan Creswell after he left the company.</p>
<p>One of the less satisfying aspects of that project was that, as I worked with Javaspace/Tuplespace -based systems, I came to believe in them less and less. I now believe that while Javaspaces have some great qualities, they also have some serious flaws. Here&#8217;s a brief outline of what I think these flaws are.</p>
<p><strong>Some background for the layman</strong></p>
<p>Javaspaces pride themselves on having a <a href="http://java.sun.com/products/jini/1.0/docs/api/net/jini/space/JavaSpace.html">simple API based on 4 methods</a></p>
<ul>
<li><strong>write </strong>puts an object into the shared distributed space</li>
<li><strong>read </strong>returns a copy of one object matching some provided query criteria. There are blocking and polling variants.</li>
<li><strong>take </strong>returns a copy of one object matching some provided query criteria and removes it from the space. There are blocking and polling variants.</li>
<li><strong>notify </strong>registers interest in being notified should an object enter the space matching the provided criteria.</li>
</ul>
<p>Javaspaces use a <em>Query by Example</em> mechanism to query the state of the space. One presents an template <a href="http://java.sun.com/products/jini/2.0.1/doc/api/net/jini/core/entry/Entry.html">Entry </a>to the space, with zero or more public, non-primitive, serializable fields, any of which may be null, and the space matches any Entry in the space whose fields are equals() to the template&#8217;s field, while treating null fields of the Entry as wildcards that match anything. Thinking of Entry as being a tuple is a good analogy.</p>
<p>I subscribe to the design aesthetic <em>as simple as possible, but no simpler</em>. Unfortunately,  the Javaspace query mechanism is too simplistic, and not sufficiently powerful to solve practical distributed systems problems with:</p>
<p><strong>No Range Queries</strong></p>
<p>The query API allows one to specify either an <em>exact </em>value, or <em>any </em>value, but <em>nothing in between</em>. You can say &#8220;a Person of Age == 25&#8243;, or &#8220;a Person of any Age&#8221;, but not &#8220;a Person of Age 25- 34&#8243;. This is a result of Javaspace&#8217;s fixation with a flawed query-by-example model. As you might imagine, this limitation quickly becomes problematic when you try to build real applications.</p>
<p><strong>Use of Null as Wildcard</strong></p>
<p>Another nasty side-effect of the query-by-example model is that null becomes overloaded as a wildcard value. Accordingly, Entry fields cannot be primitive, and may not be null for any legitimate application purpose.</p>
<p><strong>Lack of a readAll Operation</strong></p>
<p>readAll would be the Javaspace analog of a SQL Select statement; ie find me all Entries in the space matching the provided criteria. Sorry, no can do. A Javaspace can give you one of them, but not all of them.</p>
<p>So for example, if we want to ask our space-based application, &#8220;How many tasks are in the queue?&#8221; , it can only reply &#8220;All I can tell you is that there is at least one.&#8221;</p>
<p><strong>The Future</strong></p>
<p>Someone should combine the best ideas from Javaspaces &#8211; a focus on high-performance, short-term storage of self-contained objects/messages, <a href="http://java.sun.com/products/jini/2.0.2/doc/api/net/jini/core/lease/package-summary.html">leases</a>, and <a href="http://java.sun.com/products/jini/1.0/docs/api/net/jini/core/event/package-summary.html">event notification</a>, with a decent, extensible query mechanism. Now that would fly. (Maybe someone already has? &#8230; I havent been following this field closely in recent years)</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benhutchison.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benhutchison.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benhutchison.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benhutchison.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benhutchison.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benhutchison.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benhutchison.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benhutchison.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benhutchison.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benhutchison.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=162&subd=benhutchison&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benhutchison.wordpress.com/2009/05/26/why-javaspaces-are-not-for-me/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/173eb485ae275ac7a615da353eabe753?s=96&#38;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&#38;r=R" medium="image">
			<media:title type="html">benhutchison</media:title>
		</media:content>
	</item>
		<item>
		<title>Deleting from the Heroes of Arcadia domain: a thorny problem</title>
		<link>http://benhutchison.wordpress.com/2009/05/16/deleting-from-the-heroes-of-arcadia-domain-a-thorny-problem/</link>
		<comments>http://benhutchison.wordpress.com/2009/05/16/deleting-from-the-heroes-of-arcadia-domain-a-thorny-problem/#comments</comments>
		<pubDate>Sat, 16 May 2009 02:47:59 +0000</pubDate>
		<dc:creator>benhutchison</dc:creator>
				<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://benhutchison.wordpress.com/?p=158</guid>
		<description><![CDATA[Deleting Objects from a Domain Model in a safe and scalable way with minimal adverse effects, is a thorny problem.
Eric Evans Domain Driven Design book has the best discussion Ive read under the section on Aggregates, but its not comprehensive.
Im struggling to find a really nice solution in Heroes of Arcadia. My best shot so [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=158&subd=benhutchison&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Deleting Objects from a Domain Model in a safe and scalable way with minimal adverse effects, is a thorny problem.</p>
<p>Eric Evans <a href="http://www.domaindrivendesign.org/">Domain Driven Design</a> book has the best discussion Ive read under the section on <em>Aggregates</em>, but its not comprehensive.</p>
<p>Im struggling to find a really nice solution in Heroes of Arcadia. My best shot so far involves a mixed approach &#8211; cleaning out as many root refs as I can, plus stamping the deleted object as inactive. An example:</p>
<p><em>Units </em>can be removed from a <em>Zone</em>.</p>
<p>There are two primary references to a Unit, via its <em>Faction</em> and its <em>Location</em>. These are bi-directional. When a unit is removed, it notifies its Faction and Location that it is going and they remove their ref to it. As these are the primary indices, cleaning them out will prevent the creation of new refs to the removed unit.</p>
<p>Units may also be referenced from other domain entities uni directionally (meaning they are unaware they&#8217;re referenced), for example, by being the target of a spell effect. These refs will remain after the unit is &#8220;removed&#8221;. The unit must stamp itself as being removed/inactive, and all domain operations need to tolerate this state. Gradually, the removed unit should &#8220;drain out&#8221; of the system as refs expire.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/benhutchison.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/benhutchison.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/benhutchison.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/benhutchison.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/benhutchison.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/benhutchison.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/benhutchison.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/benhutchison.wordpress.com/158/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/benhutchison.wordpress.com/158/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/benhutchison.wordpress.com/158/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=benhutchison.wordpress.com&blog=704887&post=158&subd=benhutchison&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://benhutchison.wordpress.com/2009/05/16/deleting-from-the-heroes-of-arcadia-domain-a-thorny-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/173eb485ae275ac7a615da353eabe753?s=96&#38;d=http%3A%2F%2Fa.wordpress.com%2Fi%2Fmu.gif&#38;r=R" medium="image">
			<media:title type="html">benhutchison</media:title>
		</media:content>
	</item>
	</channel>
</rss>