<?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/"
	>

<channel>
	<title>Higher-Order</title>
	<atom:link href="http://blog.higher-order.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.higher-order.net</link>
	<description>topics: functional programming, concurrency, web-development, REST, dynamic languages</description>
	<lastBuildDate>Wed, 07 Mar 2012 21:28:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Calabash: Functional testing for mobile apps</title>
		<link>http://blog.higher-order.net/2012/03/07/calabash-functional-testing-for-mobile-apps/</link>
		<comments>http://blog.higher-order.net/2012/03/07/calabash-functional-testing-for-mobile-apps/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 21:28:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.higher-order.net/?p=712</guid>
		<description><![CDATA[I&#8217;m happy to announce that we at LessPainful have just released Calabash as open source. Calabash is a library and toolchain for automated functional tests for iOS and Android. Read more in the introductory post: http://blog.lesspainful.com/2012/03/07/Calabash/]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m happy to announce that we at <a href="http://www.lesspainful.com">LessPainful</a> have just released Calabash as open source. Calabash is a library and toolchain for automated functional tests for iOS and Android. Read more in the introductory post: <a href="http://blog.lesspainful.com/2012/03/07/Calabash/">http://blog.lesspainful.com/2012/03/07/Calabash/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.higher-order.net/2012/03/07/calabash-functional-testing-for-mobile-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Clojure Users Group: Meetup in copenhagen, may 12th</title>
		<link>http://blog.higher-order.net/2011/04/29/703/</link>
		<comments>http://blog.higher-order.net/2011/04/29/703/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 10:58:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.higher-order.net/?p=703</guid>
		<description><![CDATA[I&#8217;ve managed to arrange a free DCUG meetup in Copenhagen in conjunction with Goto CPH. We will be several Clojure &#8220;stars&#8221;: Christophe Grand and Lau Jensen, Stefan Richter and Stefan Tilkov. Right now we have only one registration apart from &#8230; <a href="http://blog.higher-order.net/2011/04/29/703/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve managed to arrange a free <a href="http://www.clojure.dk">DCUG</a> meetup in Copenhagen in conjunction with Goto CPH. We will be several Clojure &#8220;stars&#8221;: Christophe Grand and Lau Jensen, Stefan Richter and Stefan Tilkov.</p>
<p>Right now we have only one registration apart from the people above and myself &#8211; so come on <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Time and date:  May 12th, Thursday 19:15 &#8211; 20:15 / Location: Room 202<br />
Location: <a href="http://gotocon.com/cph-2011/venue/">GOTO Copenhagen 2011 takes place in Radisson Blu Falconer Hotel &#038; Conference Center</a></p>
<p>Info and registration: <a href="http://gotocon.com/cph-2011/presentation/UserGroup-Meeting:%20Clojure%20stars%20and%20you">http://gotocon.com/cph-2011/presentation/UserGroup-Meeting:%20Clojure%20stars%20and%20you</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.higher-order.net/2011/04/29/703/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>vectormap and pvectormap</title>
		<link>http://blog.higher-order.net/2010/10/14/vectormap-and-pvectormap/</link>
		<comments>http://blog.higher-order.net/2010/10/14/vectormap-and-pvectormap/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 18:59:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[clj-ds]]></category>

		<guid isPermaLink="false">http://blog.higher-order.net/?p=690</guid>
		<description><![CDATA[So after attending Brian Goetz&#8217; talk and Rich Hickey&#8217;s talk at JAOO Aarhus (eer, I mean Goto Aarhus), I was thinking about how to construct Clojure data structures in parallel. To start with something that wasn&#8217;t too complex, I decided &#8230; <a href="http://blog.higher-order.net/2010/10/14/vectormap-and-pvectormap/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So after attending Brian Goetz&#8217; talk and Rich Hickey&#8217;s talk at JAOO Aarhus (eer, I mean <a href="http://gotocon.com/aarhus-2010/tracks/">Goto Aarhus</a>), I was thinking about how to construct Clojure data structures in parallel. </p>
<p>To start with something that wasn&#8217;t too complex, I decided to try and create a parallel version of mapping a function for vectors, i.e., an eager function that would take a vector and a function as input and produce a mapped vector as output (instead of a seq). This would replace a pattern I&#8217;ve often used:</p>
<pre><tt><code>(into [] (map f vs))
</code></tt></pre>
<p>with <tt><code>(vectormap f vs)</code></tt>, which avoids the overhead of constructing a seq and the reconstructing a vector by conj&#8217;ing from the seq. </p>
<p>My initial goal was to produce a parallel version e.g., <tt><code>(pvectormap f vs)</code></tt>. As Rich has pointed out: Clojure&#8217;s persistent data structures are excellent candidates for parallel processing using divide and conquer since they are trees which are already &#8220;sitting there divided!&#8221; Further immutability means no synchronization is needed. For example, <a href="http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/">remember that</a> PersistentVector is a balanced 32-way tree consisting of size 32 arrays of Objects (Nodes in the tree or the actual values stored in the vector). </p>
<p>I decided to warm up by implementing vectormap, i.e., the serial version, first. </p>
<h2>Remember this?</h2>
<p><a href="http://olabini.com/blog/2010/07/the-jvm-language-summit-2010/">Apparently Rich Hickey presented this piece of code</a> at JVM Lang summit:</p>
<pre><tt><code>static public Object ret1(Object ret, Object nil) {
    return ret;
}

public static int count(Object o){
    if(o instanceof Counted)
        return ((Counted) o).count();
    return countFrom(Util.ret1(o, o = null));
}
</code></tt></pre>
<p>Has Rich gone mad? A two argument static method which simply returns the first argument?? When I first read Ola&#8217;s blog post I simply couldn&#8217;t figure out why he would use that code&#8230; However, when I was writing the vectormap code I was thinking: suppose the input vector is really large &#8212; in fact, so large that we don&#8217;t have memory enough to hold both the input and the output vector. Then vectormap would produce an OutOfMemoryError. But suppose the calling code didn&#8217;t actually need the input vector what if we would release references to the elements of the input vector as we construct the corresponding mapped elements in the output vector (but without destroying the input vector)? We would need to only keep references to Node vectors we hadn&#8217;t already processed, and then null out our local variables to those we had. </p>
<p>This was when I realized that this is exactly what Rich&#8217;s function can help with: when calling the <tt>countFrom</tt> function, he provides as argument the seq referenced by the local variable o via the ret1 function. The side effect of using ret1 is that since Java is strict,  both argument expressions to ret1 are evaluated (left-to-right), and consequently o is null&#8217;ed out. No more holding on the the head <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I could use this to only hold on to the vector arrays I hadn&#8217;t processed. </p>
<p>For example:</p>
<pre><tt><code>private static Node mapNode(IFn f, Node node, int level) {
	if (node == null) {return null;}
	if (level == 0) {
		return new Node(null,mapArray(f, Util.ret1(node.array, node=null)));
	}
	Object[] newArr = new Object[node.array.length];
	System.arraycopy(node.array, 0, newArr, 0, node.array.length);
	node=null;
	level -= 5;
	for (int i=0;i&lt;newArr.length;i++) {
		newArr[i] = mapNode(f,Util.ret1((Node) newArr[i], newArr[i]=null),level);
	}
	return new Node(null,newArr);
}
</code></tt></pre>
<p>This code is available in <a href="http://blog.higher-order.net/2010/06/11/clj-ds-clojures-persistent-data-structures-for-java/">my clj-ds project</a>.</p>
<h2>Parallelize with Fork/Join</h2>
<p>The pvectormap function uses <a href="http://gee.cs.oswego.edu/dl/concurrency-interest/">Fork/Join</a> to parallelize the mapping. I&#8217;m not sure about the granularity of the tasks, but I decided that processing a size 32 array was too small a task, and went with processing 32 size 32 arrays instead.</p>
<p>Starting at the root array of nodes, the code simply forks 32 tasks which recursively process each child of the root. This forking continues recursively until we hit the second lowest level in the tree &#8212; this is processed sequentially using the mapNode function from above. This is implemented as a RecursiveTask in the Fork/Join framework. </p>
<pre><tt><code>static final class PMapTask extends RecursiveTask&lt;Node&gt; {

	private IFn f;
	private int shift;
	private Node node;

	public PMapTask(IFn f, int shift, Node node) {
		this.f = f;
		this.shift = shift;
		this.node = node;
	}

	public Node compute() {
		if (node == null) {
			return null;
		}
	   if (this.shift &lt;= 5) {
		   return mapNode(f,node,shift);
	   }

	   PMapTask[] tasks = new PMapTask[node.array.length];
	   shift -= 5;
	   for (int i=0;i&lt;tasks.length;i++) {
		   tasks[i] = new PMapTask(f,shift,(Node) node.array[i]);
	   }
	   invokeAll(tasks);
	   Node[] nodes = new Node[node.array.length];
	   try {
		   for (int i=0;i&lt;tasks.length;i++) {
				nodes[i] = tasks[i].get();
		   }
		   return new Node(null,nodes);
	   } catch (InterruptedException e) {
			Thread.currentThread().interrupt();
			throw new RuntimeException(e);
		} catch (ExecutionException e) {
			throw new RuntimeException(e);
		}
   }
}
</code></tt></pre>
<p>On my dual core system with a non trivial function f that actually does some work, using pvectormap is about twice as fast as vectormap: <a href="http://github.com/krukow/clj-ds/blob/master/test/com/trifork/clj_ds/test/PersistentVectorTest.java#L90">see PersistentVectorTest of clj-ds</a>.</p>
<p>Next stop: optimize and add vectormap and pvectormap to Clojure core <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.higher-order.net/2010/10/14/vectormap-and-pvectormap/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Clojure without the parentheses: looks a bit like ruby :)</title>
		<link>http://blog.higher-order.net/2010/08/31/clojure-without-parentheses/</link>
		<comments>http://blog.higher-order.net/2010/08/31/clojure-without-parentheses/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 20:23:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.higher-order.net/?p=647</guid>
		<description><![CDATA[I gave an introductory talk about Clojure at Trifork yesterday: https://secure.trifork.com/aarhus-2010/freeevent/index.jsp?eventOID=2713 I really wanted to focus on the core of Clojure: things like time/state management, functional programming, programming to contracts, meta programming, host interop, dynamics, interactivity and expressive power. I &#8230; <a href="http://blog.higher-order.net/2010/08/31/clojure-without-parentheses/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I gave an introductory talk about Clojure at Trifork yesterday:</p>
<p><a href="https://secure.trifork.com/aarhus-2010/freeevent/index.jsp?eventOID=2713">https://secure.trifork.com/aarhus-2010/freeevent/index.jsp?eventOID=2713<br />
</a></p>
<p>I really wanted to focus on the core of Clojure: things like time/state management, functional programming, programming to contracts, meta programming, host interop, dynamics, interactivity and expressive power. I want people to see what Clojure is without being blinded by <a href="http://img264.imageshack.us/img264/1397/lispnd7.png">what is a mental blocker for some: the parentheses</a>. </p>
<p>So as a fun exercise, I decided to remove (almost) all parentheses from code on my slides. As it turns out, the code looks much like ruby or python (just more functional and concise). All code on my slides can be turned into real Clojure code by inserting parens appropriate places (newlines and indentation help with &#8220;visual parsing&#8221;). The &#8220;commas are whitespace&#8221; is used to make it more readable (for comma-liking eyes). Obviously as we go into meta programming with macros this breaks down, but that is the last topic of the talk <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://blog.higher-order.net/files/clj/clojure-intro.pdf">slides</a></p>
<p>Github repos:</p>
<p><a href="http://github.com/krukow/swing-demo">http://github.com/krukow/swing-demo<br />
</a><br />
<a href="http://github.com/krukow/ants-demo">http://github.com/krukow/ants-demo</a><br />
<a href="http://github.com/krukow/clojure-circuit-breaker">http://github.com/krukow/clojure-circuit-breaker</a></p>
<p>Examples (I know the semantics aren&#8217;t exactly the same, but I am considering syntax here). </p>
<div style="float:left">
<strong>Ruby</strong>:
<pre><tt><code>ruby-1.9.2-p0 > def m
ruby-1.9.2-p0 ?>  {:name => "Karl", :age => 42}
ruby-1.9.2-p0 ?>  end
ruby-1.9.2-p0 > m
 => {:name=>"Karl", :age=>42}
ruby-1.9.2-p0 >
</code>
</tt></pre>
</div>
<div style="float:left; margin-left: 10px">
<strong>Clojure</strong>:
<pre><tt><code>user> def p
         {:name "Fred", :age 42}
#'user/p
user> p
{:name "Fred", :age 42}
</code>
</tt></pre>
</div>
<div style="clear:both;" ></div>
<div style="float:left">
<strong>Ruby</strong>:
<pre><tt><code>ruby-1.9.2-p0 > class Person
ruby-1.9.2-p0 ?>  attr :name,:age
ruby-1.9.2-p0 ?>  attr_writer :name,:age
ruby-1.9.2-p0 ?>  end
ruby-1.9.2-p0 > p = Person.new
 => #<Person:0x00000101073580>
ruby-1.9.2-p0 > p.name="fred";p.age=42;
ruby-1.9.2-p0 > [p,p,p].map &#038;:name
 => ["fred", "fred", "fred"]
</code>
</tt></pre>
</div>
<div style="float:left; margin-left: 10px">
<strong>Clojure</strong>:
<pre><tt><code>
user> map :name [p,p,p]
("Fred" "Fred" "Fred")
;;or
user> defrecord Person [name,age]
user.Person
user> def p
         Person. "Fred", 42
#'user/p
user> map :name [p, p, p]
("Fred" "Fred" "Fred")
</code>
</tt></pre>
</div>
<div style="clear:both;" ></div>
<div style="float:left">
<strong>Ruby</strong>:
<pre><tt><code>ruby-1.9.2-p0 > [p,p,p].map(&#038;:age).reduce(&#038;:+)
 => 126
</code>
</tt></pre>
</div>
<div style="float:left; margin-left: 10px">
<strong>Clojure</strong>:
<pre><tt><code>
reduce +
   map :age [p p p] => 126
;;or
->> [p p p]
          map :age
           reduce +
</code>
</tt></pre>
</div>
<div style="clear:both;" ></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.higher-order.net/2010/08/31/clojure-without-parentheses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Assoc and Clojure&#8217;s PersistentHashMap: part ii</title>
		<link>http://blog.higher-order.net/2010/08/16/assoc-and-clojures-persistenthashmap-part-ii/</link>
		<comments>http://blog.higher-order.net/2010/08/16/assoc-and-clojures-persistenthashmap-part-ii/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 08:15:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[persistent data structures]]></category>

		<guid isPermaLink="false">http://blog.higher-order.net/?p=609</guid>
		<description><![CDATA[Some time ago I wrote introductory posts that gave high-level overviews of how Clojure&#8217;s PersistentVector and PersistentHashMap work. In the PersistentHashMap post I promised that &#8220;In part 2 we look at how assoc works…&#8221; &#8211; it seems I never got &#8230; <a href="http://blog.higher-order.net/2010/08/16/assoc-and-clojures-persistenthashmap-part-ii/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Some time ago I wrote introductory posts that gave high-level overviews of how Clojure&#8217;s PersistentVector and PersistentHashMap work. In the <a href="http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/">PersistentHashMap post</a> I promised that &#8220;In part 2 we look at how assoc works…&#8221; &#8211; it seems I never got around to that!</p>
<p>A lot of interesting things have happened with data structures in JVM-land since then: <a href="http://github.com/krestenkrab/erjang">Erjang</a> uses Clojure&#8217;s data structures, it looks like Scala <a href="https://lampsvn.epfl.ch/trac/scala/ticket/3724">is porting PersistentVector</a>, <a href="http://olabini.com/blog/2010/07/preannouncing-seph/">upcoming Seph</a> is using them too. My <a href="http://blog.higher-order.net/2010/06/11/clj-ds-clojures-persistent-data-structures-for-java/">clj-ds project</a> should help in this regard: I&#8217;ve extracted the data structures of Clojure from its compiler for use with JVM-based languages (providing some extra stuff like reverse and &#8220;positioned&#8221; iterators). There are already people interested in using this in Java land.</p>
<p>Some people have asked for the &#8220;part ii&#8221; post, and my son just fell asleep, so &#8230; <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Most of what is described in the <a href="http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/">PersistentHashMap post</a> is still true, however there have been optimizations and simplifications which I explain here. Note: before reading this post, you should read the previous post on PersistentHashMap.</p>
<p><strong>First, some changes</strong>. Previously there were five implementations of the <tt>INode</tt> interface; this has changed and there are now only three implementations: <tt>ArrayNode</tt>, <tt>BitmapIndexedNode</tt> and <tt>HashCollisionNode</tt>. This means that: <tt>EmptyNode, LeafNode, FullNode</tt> are out, with <tt>ArrayNode</tt> replacing <tt>FullNode</tt>. An array node is an array where the entries are null or instances of INode, i.e., it stores other nodes but not any key-value pairs. An empty persistent hash map is simply a persistent hash map where the root node is null &#8212; this removes the need for EmptyNode. Finally, leaf nodes used to store the actual entries stored in the map. Leaf nodes are out, and instead BitmapIndexedNodes directly embed the map entries in their arrays. </p>
<p>The idea is the following: if, in the old implementation, a BitmapIndexedNode would store a leaf node at an index, then instead, it now embeds the key and value directly in its array. This array used to be of type <tt>INode[]</tt>, storing only nodes, but is now a mixed object array for which the value can be one of: a map key, a map entry, null or an INode object. </p>
<p><img src="http://blog.higher-order.net/files/clj/persistenthashmap1.png" alt="Old persistent hashmap structure" /></p>
<p><em>The above drawing corresponds to the old structure.</em> In the new structure all the white circles (the leaf nodes) are embedded directly in their parents.</p>
<p><strong><em>There is an invariant: </em> </strong></p>
<p>for all the indices that are in the bitmap, the even indices store keys or null; the odd indices store values or INode objects. Key-value pairs are layed out in sequence, so that if index <tt>2*i</tt> is a key then index <tt>2*i + 1</tt> is a value. If an index <tt>2*i</tt> is null then <tt>2*i+1</tt> must be a non-null INode object.</p>
<p>Note: if you don&#8217;t remember how bitpos, bitmap and index work see <a href="http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/">the part i post</a>.</p>
<p>The strategy used in BitmapIndexedNode is that it can store up to 16 entries in the bit map: if the size grows above 16, it is converted to a FullNode. </p>
<p><strong>Assoc</strong>. The assoc method creates a persistent hash map which is like the current one, except that it additionally stores another map entry. As before assoc works using path copying: all that is changed in the new map is the path from the root node to the newly added map entry.</p>
<p><em>Beware</em>: the following drawing looks confusing: take the time and read the explanation. It is showing two persistent hash maps, where one is obtained by assoc&#8217;ing to the first. Again this is a modified version of one of Rich&#8217;s slides. </p>
<p><img style="position: relative; left:-20px;" src="http://blog.higher-order.net/files/clj/persistenthashmap-pathcopy.png" alt="Path copying in the old structure" /></p>
<p>The first map is rooted on the left (where the left-most box points to). The second is rooted where the right-most box points to. The nodes are grouped in three, each indicated by a colored circle that surrounds it. The new node is in the right-most, lower corner.</p>
<p>Purple is the path in the old tree to where the new map entry would be;<br />
green is the new nodes that are created in the new hash map.<br />
The dashed lines indicate that the nodes in the new tree share children with nodes in the old tree. The red circles show all the nodes that are shared in the tree: note that this is most of the nodes. </p>
<p>So how much work needs to be done to create the new tree? Suppose we are storing key k with value v. Using recursion, descend down the original tree as if looking for the key k. The key k isn&#8217;t found. In the worst case this takes time: <tt>O(log<sub>32</sub> n)</tt>, in practice it we could stop at any level in the tree so 2-3 steps would be common (remember from <a href="http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice">the old post</a> that the work done at each level is constant and fast). At the bottom we create a new BitmapIndexedNode and store the new map entry in it. If the bottom node in the old tree was a BitmapIndexedNode with less than 16 elements the new BitmapIndexedNode is a copy of the old one, except that the new map entry is added. This step takes constant time since the array to copy at the bitmap indexed node always has less than 32 elements (because we store at most 16 map entries as: key, value, key, value, &#8230;). If the bottom node was an <tt>ArrayNode</tt> we simply copy the array node, and make the new BitmapIndexedNode a size-one child of this array node (still constant time). </p>
<p>On the drawing above, we have now recursively descended the purple path in the left/old tree, and we have created the new node which is a bitmap indexed node. What remains is to establish the path to this new node, in the new tree: this path is almost identical to the &#8220;purple&#8221; path in the old tree: the only difference is that we have created a new bitmap indexed node. The parent of the new node must of course reference it, so that is copied and modified to get a reference to the new node. This means that we must also copy the grandparent of the new node, modifying it to reference the parent. And so on&#8230; This copying takes place on our way &#8220;up&#8221; through the recursion, i.e., after the recursive calls complete at each node level.</p>
<p>Let&#8217;s decompose the code. We only look at assoc for BitmapIndexedNode as it is the most interesting.</p>
<pre><tt><span class="keyword">public</span><span class="normal"> INode </span><span class="function">assoc</span><span class="symbol">(</span><span class="type">int</span><span class="normal"> shift</span><span class="symbol">,</span><span class="normal"> </span><span class="type">int</span><span class="normal"> hash</span><span class="symbol">,</span><span class="normal"> Object key</span><span class="symbol">,</span><span class="normal"> Object val</span><span class="symbol">,</span><span class="normal"> Box addedLeaf</span><span class="symbol">)</span><span class="cbracket">{</span>
<span class="normal">		</span><span class="type">int</span><span class="normal"> bit </span><span class="symbol">=</span><span class="normal"> </span><span class="function">bitpos</span><span class="symbol">(</span><span class="normal">hash</span><span class="symbol">,</span><span class="normal"> shift</span><span class="symbol">);</span>
<span class="normal">		</span><span class="type">int</span><span class="normal"> idx </span><span class="symbol">=</span><span class="normal"> </span><span class="function">index</span><span class="symbol">(</span><span class="normal">bit</span><span class="symbol">);</span>
<span class="normal">		</span><span class="keyword">if</span><span class="symbol">((</span><span class="normal">bitmap </span><span class="symbol">&amp;</span><span class="normal"> bit</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">!=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="comment">//..</span>
<span class="normal">		</span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="comment">//</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="cbracket">}</span></tt></pre>
<p>This should be familiar from the previous post: we check if the index of the hash (at the current level) is in the bitmap. The else branch is the case where the index is not in the bitmap, corresponding to reaching the bottom of the path: here we must create a new node and path-copy as described above. In the &#8220;if&#8221;-branch we simply either call recursively if the index references an INode: if it references a key-value pair this is a &#8220;replace&#8221; and we do path copying here too. Again we look only at the else-branch as it is the most interesting.</p>
<pre><tt><span class="keyword">public</span><span class="normal"> INode </span><span class="function">assoc</span><span class="symbol">(</span><span class="type">int</span><span class="normal"> shift</span><span class="symbol">,</span><span class="normal"> </span><span class="type">int</span><span class="normal"> hash</span><span class="symbol">,</span><span class="normal"> Object key</span><span class="symbol">,</span><span class="normal"> Object val</span><span class="symbol">,</span><span class="normal"> Box addedLeaf</span><span class="symbol">)</span><span class="cbracket">{</span>
<span class="normal">		</span><span class="type">int</span><span class="normal"> bit </span><span class="symbol">=</span><span class="normal"> </span><span class="function">bitpos</span><span class="symbol">(</span><span class="normal">hash</span><span class="symbol">,</span><span class="normal"> shift</span><span class="symbol">);</span>
<span class="normal">		</span><span class="type">int</span><span class="normal"> idx </span><span class="symbol">=</span><span class="normal"> </span><span class="function">index</span><span class="symbol">(</span><span class="normal">bit</span><span class="symbol">);</span>
<span class="normal">		</span><span class="keyword">if</span><span class="symbol">((</span><span class="normal">bitmap </span><span class="symbol">&amp;</span><span class="normal"> bit</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">!=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="comment">//..</span>
<span class="normal">		</span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="type">int</span><span class="normal"> n </span><span class="symbol">=</span><span class="normal"> Integer</span><span class="symbol">.</span><span class="function">bitCount</span><span class="symbol">(</span><span class="normal">bitmap</span><span class="symbol">);</span>
<span class="normal">			</span><span class="keyword">if</span><span class="symbol">(</span><span class="normal">n </span><span class="symbol">&gt;=</span><span class="normal"> </span><span class="number">16</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">				</span><span class="comment">//convert to ArrayNode</span>
<span class="normal">			</span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">				Object</span><span class="symbol">[]</span><span class="normal"> newArray </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> Object</span><span class="symbol">[</span><span class="number">2</span><span class="symbol">*(</span><span class="normal">n</span><span class="symbol">+</span><span class="number">1</span><span class="symbol">)];</span>
<span class="normal">				System</span><span class="symbol">.</span><span class="function">arraycopy</span><span class="symbol">(</span><span class="normal">array</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> newArray</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2</span><span class="symbol">*</span><span class="normal">idx</span><span class="symbol">);</span>
<span class="normal">				newArray</span><span class="symbol">[</span><span class="number">2</span><span class="symbol">*</span><span class="normal">idx</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> key</span><span class="symbol">;</span>
<span class="normal">				addedLeaf</span><span class="symbol">.</span><span class="normal">val </span><span class="symbol">=</span><span class="normal"> addedLeaf</span><span class="symbol">;</span><span class="normal"> </span>
<span class="normal">				newArray</span><span class="symbol">[</span><span class="number">2</span><span class="symbol">*</span><span class="normal">idx</span><span class="symbol">+</span><span class="number">1</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> val</span><span class="symbol">;</span>
<span class="normal">				System</span><span class="symbol">.</span><span class="function">arraycopy</span><span class="symbol">(</span><span class="normal">array</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2</span><span class="symbol">*</span><span class="normal">idx</span><span class="symbol">,</span><span class="normal"> newArray</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2</span><span class="symbol">*(</span><span class="normal">idx</span><span class="symbol">+</span><span class="number">1</span><span class="symbol">),</span><span class="normal"> </span><span class="number">2</span><span class="symbol">*(</span><span class="normal">n</span><span class="symbol">-</span><span class="normal">idx</span><span class="symbol">));</span>
<span class="normal">				</span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">BitmapIndexedNode</span><span class="symbol">(</span><span class="keyword">null</span><span class="symbol">,</span><span class="normal"> bitmap </span><span class="symbol">|</span><span class="normal"> bit</span><span class="symbol">,</span><span class="normal"> newArray</span><span class="symbol">);</span>
<span class="normal">			</span><span class="cbracket">}</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="cbracket">}</span></tt></pre>
<p>Remember (from the previous post) that <tt>Integer.bitCount(bitmap)</tt> counts the number of children of this node. If we are storing less than 16 elements, we have room for one more: To create the new bitmap indexed node simply copy the object array, and modify it to store the new key-value pair (using the invariant mentioned above). (Ignore the &#8220;box&#8221; part, it is used to communicate to higher-levels in the recursion what happened.) Finally, if we have 16 elements stored already, convert to an ArrayNode:</p>
<pre><tt><span class="keyword">public</span><span class="normal"> INode </span><span class="function">assoc</span><span class="symbol">(</span><span class="type">int</span><span class="normal"> shift</span><span class="symbol">,</span><span class="normal"> </span><span class="type">int</span><span class="normal"> hash</span><span class="symbol">,</span><span class="normal"> Object key</span><span class="symbol">,</span><span class="normal"> Object val</span><span class="symbol">,</span><span class="normal"> Box addedLeaf</span><span class="symbol">)</span><span class="cbracket">{</span>
<span class="normal">		</span><span class="type">int</span><span class="normal"> bit </span><span class="symbol">=</span><span class="normal"> </span><span class="function">bitpos</span><span class="symbol">(</span><span class="normal">hash</span><span class="symbol">,</span><span class="normal"> shift</span><span class="symbol">);</span>
<span class="normal">		</span><span class="type">int</span><span class="normal"> idx </span><span class="symbol">=</span><span class="normal"> </span><span class="function">index</span><span class="symbol">(</span><span class="normal">bit</span><span class="symbol">);</span>
<span class="normal">		</span><span class="keyword">if</span><span class="symbol">((</span><span class="normal">bitmap </span><span class="symbol">&amp;</span><span class="normal"> bit</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">!=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="comment">//..</span>
<span class="normal">		</span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="type">int</span><span class="normal"> n </span><span class="symbol">=</span><span class="normal"> Integer</span><span class="symbol">.</span><span class="function">bitCount</span><span class="symbol">(</span><span class="normal">bitmap</span><span class="symbol">);</span>
<span class="normal">			</span><span class="keyword">if</span><span class="symbol">(</span><span class="normal">n </span><span class="symbol">&gt;=</span><span class="normal"> </span><span class="number">16</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">				INode</span><span class="symbol">[]</span><span class="normal"> nodes </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> INode</span><span class="symbol">[</span><span class="number">32</span><span class="symbol">];</span>
<span class="normal">				</span><span class="type">int</span><span class="normal"> jdx </span><span class="symbol">=</span><span class="normal"> </span><span class="function">mask</span><span class="symbol">(</span><span class="normal">hash</span><span class="symbol">,</span><span class="normal"> shift</span><span class="symbol">);</span>
<span class="normal">				nodes</span><span class="symbol">[</span><span class="normal">jdx</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> EMPTY</span><span class="symbol">.</span><span class="function">assoc</span><span class="symbol">(</span><span class="normal">shift </span><span class="symbol">+</span><span class="normal"> </span><span class="number">5</span><span class="symbol">,</span><span class="normal"> hash</span><span class="symbol">,</span><span class="normal"> key</span><span class="symbol">,</span><span class="normal"> val</span><span class="symbol">,</span><span class="normal"> addedLeaf</span><span class="symbol">);</span><span class="normal">  </span>
<span class="normal">				</span><span class="type">int</span><span class="normal"> j </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span>
<span class="normal">				</span><span class="keyword">for</span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> </span><span class="number">32</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span>
<span class="normal">					</span><span class="keyword">if</span><span class="symbol">(((</span><span class="normal">bitmap </span><span class="symbol">&gt;&gt;&gt;</span><span class="normal"> i</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">&amp;</span><span class="normal"> </span><span class="number">1</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">!=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">						</span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">array</span><span class="symbol">[</span><span class="normal">j</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">==</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">)</span>
<span class="normal">							nodes</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">INode</span><span class="symbol">)</span><span class="normal"> array</span><span class="symbol">[</span><span class="normal">j</span><span class="symbol">+</span><span class="number">1</span><span class="symbol">];</span>
<span class="normal">						</span><span class="keyword">else</span>
<span class="normal">							nodes</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> EMPTY</span><span class="symbol">.</span><span class="function">assoc</span><span class="symbol">(</span><span class="normal">shift </span><span class="symbol">+</span><span class="normal"> </span><span class="number">5</span><span class="symbol">,</span><span class="normal">  Util</span><span class="symbol">.</span><span class="function">hash</span><span class="symbol">(</span><span class="normal">array</span><span class="symbol">[</span><span class="normal">j</span><span class="symbol">]),</span><span class="normal"> array</span><span class="symbol">[</span><span class="normal">j</span><span class="symbol">],</span><span class="normal"> array</span><span class="symbol">[</span><span class="normal">j</span><span class="symbol">+</span><span class="number">1</span><span class="symbol">],</span><span class="normal"> addedLeaf</span><span class="symbol">);</span>
<span class="normal">						j </span><span class="symbol">+=</span><span class="normal"> </span><span class="number">2</span><span class="symbol">;</span>
<span class="normal">					</span><span class="cbracket">}</span>
<span class="normal">				</span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">ArrayNode</span><span class="symbol">(</span><span class="keyword">null</span><span class="symbol">,</span><span class="normal"> n </span><span class="symbol">+</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span><span class="normal"> nodes</span><span class="symbol">);</span>
<span class="normal">			</span><span class="cbracket">}</span><span class="normal"> </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">				</span><span class="comment">//we covered this...</span>
<span class="normal">			</span><span class="cbracket">}</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="cbracket">}</span></tt></pre>
<p>The first block up to the &#8216;for&#8217; loop prepares the array of INodes that will be the children array of the new ArrayNode. We create a new BitmapIndexedNode easily by calling assoc on an empty persistent hash map (which is an easy way of creating an one-entry BitmapIndexedNode). Note that the indexing strategy for ArrayNodes is different from BitmapIndexedNode: we don&#8217;t need the bitmap <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  We simply use the 5-bit block corresponding to the level (again see the older post). </p>
<p>Finally, the for-loop copies all the other nodes that are stored in this bitmap indexed node into the new array node. This entails mapping between the bitmap index scheme and the &#8220;5-bit hash-block&#8221; scheme. For each possible index in the bitmap node, only do work if the index is present in the bit map: <tt>if(((bitmap >>> i) &#038; 1) != 0)</tt>. The variable <tt>j</tt> runs through the even indexes, and according to the invariant: null means that <tt>j+1</tt> is an INode, and non-null means it is a value in a map entry.</p>
<p>I am wondering if there is an optimization possible here? We are looping through all possible indices of the new ArrayNode, but we know that we only have to do something on the indices that correspond to an non-zero index in the bit map; and there can be only 15 of those&#8230; Would it be possible to iterate only those using some strategy? If I figure something out, I&#8217;ll let you know <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.higher-order.net/2010/08/16/assoc-and-clojures-persistenthashmap-part-ii/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Conj-labs Clojure lessons part i</title>
		<link>http://blog.higher-order.net/2010/07/04/conj-labs-clojure-lessons-part-i/</link>
		<comments>http://blog.higher-order.net/2010/07/04/conj-labs-clojure-lessons-part-i/#comments</comments>
		<pubDate>Sun, 04 Jul 2010 07:43:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[circuit breaker]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[protocols]]></category>

		<guid isPermaLink="false">http://blog.higher-order.net/?p=589</guid>
		<description><![CDATA[I attended the first conj-labs in Brussels, June 23-25. It was three days of intense Clojure learning with Clojure profiles: Christophe Grand and Lau Jensen. I must say it exceeded my expectations! Everyone was great and I really feel it &#8230; <a href="http://blog.higher-order.net/2010/07/04/conj-labs-clojure-lessons-part-i/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I attended the <a href="http://www.conj-labs.eu/">first conj-labs in Brussels, June 23-25</a>. It was three days of intense Clojure learning with Clojure profiles: <a href="http://clj-me.cgrand.net/">Christophe Grand</a> and <a href="http://www.bestinclass.dk/">Lau Jensen</a>. I must say it exceeded my expectations! Everyone was great and I really feel it took my Clojure to the next level.</p>
<p>This post describes some mistakes I&#8217;ve made in the Clojure circuit breaker project, and how I managed to fix them, mostly due to guidance from Christophe. </p>
<p>The following is an (embarrassingly long) list of issues that my <a href="http://blog.higher-order.net/2010/05/05/circuitbreaker-clojure-1-2/">previous version of circuit breaker</a> had. I think others can learn from my mistakes.</p>
<p><strong>Platform speed protocol functions.</strong> In order for a protocol function reaching a datatype to run at platform call-speed, the datatype must inline the protocol implementation. In the old version, I extended the state transitions protocol to the circuit breaker states using (extend &#8230;): this is usually 3-4x times slower than platform-speed method calls (but can be much slower when cache misses). I now inline the protocol extension to the states.</p>
<p>This inlining gave a new problem. I had two data types, say A and B, where A creates an instance of B and B creates an instance of A in the implementation of the inlined protocol functions. You can&#8217;t have this type of &#8220;mutually recursive data types&#8221; since they are compiled on the fly to Java classes. The fix was to&#8230;</p>
<p><strong>Create factory functions for your data types.</strong> There are at least two reasons for this. First a factory function can do processing of its arguments (e.g. pre condition), say for validation. The data type constructors can&#8217;t have any logic. Second, as noted by Alex Miller on his blog: <a href="http://tech.puredanger.com/2010/06/30/using-records-from-a-different-namespace-in-clojure/&#038;">to use data types defined in another namespace you must import them</a>. But you can use require/use to bring the factory functions into your namespace. </p>
<p><strong>I thought I knew: protocols aren&#8217;t interfaces (and Java interop).</strong>. I used a protocol: CircuitBreakerTransitions to model the states. The protocol contains functions needed for state transition on various events. I extended the protocol to my states, e.g., </p>
<pre><code>
(defrecord ClosedState [policy fail-count]
  CircuitBreakerTransitions
  ...)
</code></pre>
<p>It inlines the protocol so the generated class implements the protocol&#8217;s backing interface: It&#8217;s fast and works great. </p>
<p>The problem appeared when I wanted to expose a Java API for the circuit breaker: one of the API methods getCurrentState returns the current state &#8211; now, the question is what is its signature? My first attempt was public CircuitBreakerTransitions getCurrentState(). Now what is wrong?</p>
<p>The problem is that my protocol can be extended to reach other types. Those types may or may not inline the protocol functions, and hence it is possible for the protocol to reach a type which doesn&#8217;t implement the CircuitBreakerTransitions interface&#8230; So should I just return &#8220;Object&#8221; &#8211; that isn&#8217;t really useful. </p>
<p>I haven&#8217;t implemented a solution yet, but this is what I am thinking. Keep the type: CircuitBreakerTransitions getCurrentState(), but in my Java-interop (gen-class), the function that implements getCurrentState should grab the state s from the circuit breaker. Now I know that (satisfies? CircuitBreakerTransitions s) is true, but (instance? (:on-interface CircuitBreakerTransitions) s) may be false. If it is true, I simply return it. Otherwise: reify  CircuitBreakerTransitions by delegating to the protocol functions on s. This may sound a bit wierd at first, but I think of it like creating a new object that satisfies the interface by dynamically dispatching to s.</p>
<p><strong>Type-hits are for removing reflection, not enforcing type safety</strong> My first iteration tried to type-hint the records, e.g.,</p>
<pre><code>
(defrecord ClosedState [^TransitionPolicy policy ^int fail-count])
</code></pre>
<p>This is just plain terrible <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  First, those hints are ignored (but may be used in later versions of Clojure). Second, int isn&#8217;t suported in the current version of Clojure. Third, TransitionPolicy is a protocol &#8211; and, yes, protocol&#8217;s aren&#8217;t interfaces (see above): problem being again if I supply an object that satisfies the protocol but doesn&#8217;t implement the backing interface. Ugh.<br />
The reason I put the hints wasn&#8217;t to remove reflection, it was for the generated constructor to have types (which is a valid thing to want, but unsupported now). But it is the wrong approach for the reasons above. </p>
<p>The right thing is to remove hints and expose a factory function which checks that the first argument satisfies the TransitionPolicy protocol and that the second argument is non-negative.</p>
<p><strong>Premature optimization</strong>. My circuit breaker implementation tried to optimize a corner-case for the swap! function: suppose you (swap! state f) and f applied to the current state is identically the same state. Then there is no reason to do a compare-and-set!. My transition-by! function implemented this optimization. However, this was a premature optimization that changes the semantics of time (wow, Clojure really is powerful <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ). The fundamental question is this:  [s] -f-> [s] (where s is a state and f is a side-effect free function that advances time), is this transition really advancing time? (it isn&#8217;t observable, is it?&#8230;)</p>
<p>Anyway, I&#8217;ve never benchmarked the code so it was a premature optimization leading to less understandable code. Also, as <a href="http://twitter.com/chopmo">Jacob</a> and I discussed in the plane home: it actually skews the behavior of the circuit breaker to prefer switching states rather than staying in the same state &#8211; something that you may or may-not want.</p>
<p>Finally an off-topic: It is now possible to build the Clojure circuit breaker including AOT compilation of Java interop classes. I ran into a problem with lein where the order of namespaces in :namespaces isn&#8217;t preserved. This is a problem when you are gen-interfacing in one file and gen-class :implements that interface in another.</p>
<p>I&#8217;ve created a very simple patch to lein to preserve the order.</p>
<p><a href="http://blog.higher-order.net/wp-content/uploads/2010/07/0001-don-t-convert-namespaces-aot-to-a-set-as-it-does-n.patch.txt">http://blog.higher-order.net/wp-content/uploads/2010/07/0001-don-t-convert-namespaces-aot-to-a-set-as-it-does-n.patch.txt</a></p>
<p>Phil is applying this patch so it should be out soon. Until then, if you don&#8217;t want to patch lein, there is a step-by-step guide to repl AOT compilation in the <a href="http://github.com/krukow/clojure-circuit-breaker">README</a>.</p>
<p>Those interested can grab the latest code.</p>
<p><a href="http://github.com/krukow/clojure-circuit-breaker">http://github.com/krukow/clojure-circuit-breaker</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.higher-order.net/2010/07/04/conj-labs-clojure-lessons-part-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is it just me or is this important</title>
		<link>http://blog.higher-order.net/2010/06/16/is-it-just-me-or-is-this-important/</link>
		<comments>http://blog.higher-order.net/2010/06/16/is-it-just-me-or-is-this-important/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 12:22:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.higher-order.net/?p=582</guid>
		<description><![CDATA[for all JVM-based languages http://www.infoq.com/news/2010/06/azul_ori?]]></description>
			<content:encoded><![CDATA[<p>for all JVM-based languages<br />
<a href="http://www.infoq.com/news/2010/06/azul_ori">http://www.infoq.com/news/2010/06/azul_ori</a>?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.higher-order.net/2010/06/16/is-it-just-me-or-is-this-important/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>clj-ds: Clojure&#8217;s persistent data structures for Java</title>
		<link>http://blog.higher-order.net/2010/06/11/clj-ds-clojures-persistent-data-structures-for-java/</link>
		<comments>http://blog.higher-order.net/2010/06/11/clj-ds-clojures-persistent-data-structures-for-java/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 13:45:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Clojure]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[persistent data structures]]></category>

		<guid isPermaLink="false">http://blog.higher-order.net/?p=575</guid>
		<description><![CDATA[One of the appealing features of Clojure is the pervasive use of (efficient!) persistent data structures. (In previous posts I&#8217;ve shed some light on how PersistentHashMap and PersistentVector are implemented, although some of that information is slightly dated now). There &#8230; <a href="http://blog.higher-order.net/2010/06/11/clj-ds-clojures-persistent-data-structures-for-java/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the appealing features of Clojure is the pervasive use of (efficient!) persistent data structures. (In previous posts I&#8217;ve shed some light on how <a href="http://blog.higher-order.net/2009/09/08/understanding-clojures-persistenthashmap-deftwice/">PersistentHashMap</a> and <a href="http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/">PersistentVector</a> are implemented, although some of that information is slightly dated now).</p>
<p>There are many advantages to programming with persistent data structures (which implies immutability) but that isn&#8217;t the topic of this post&#8230; Currently the Clojure data structures are implemented in Java, so in principle they should be usable also outside of Clojure, say from Java.  However, in practice it is inconvenient (see below). </p>
<p>I&#8217;ve created the project clj-ds to make Clojure&#8217;s data structures available in a more practical form to other JVM languages than Clojure. The <a href="http://github.com/krukow/clj-ds/raw/master/README">README</a> file from the <a href="http://github.com/krukow/clj-ds">clj-ds GitHub project</a> explains the motivation:</p>
<p><strong>Advantages of clj-ds when constrained to working with Java</strong> (as opposed to just including clojure.jar)</p>
<p>* Currently the Clojure data structures are implemented in Java. In the future,<br />
all of Clojure will be implemented in Clojure itself (known as &#8220;Clojure-in-Clojure&#8221;).<br />
This has many advantages for Clojure, but when it happens the data structures will<br />
probably be even more intertwined with the rest of the language,<br />
and may be even more inconvenient to use in a Java context.</p>
<p>The clj-ds project will maintain Java versions of the code, and where possible attempt<br />
to &#8220;port&#8221; improvements made in the Clojure versions back into clj-ds. Thus keeping maintained<br />
versions of the Java data structures. </p>
<p>* In the current Clojure version, calling certain methods on PersistentHashMap requires<br />
loading the entire Clojure runtime, including the bootstrap process. This takes about one second.<br />
This means that the first time one of these methods is called, a Java user will experience a<br />
slight delay (and a memory-usage increase). Further, many of the Clojure runtime<br />
Java classes are not needed when only support for persistent data structures<br />
is wanted (e.g., the compiler).</p>
<p>* The clj-ds library is not dependent on the Clojure runtime nor does it run any<br />
Clojure bootstrap process, e.g., the classes that deal with compilation have been removed.<br />
This results in a smaller library, and the mentioned delay does not occur.</p>
<p>* Clojure is a dynamically typed language. Java is statically typed, and supports<br />
&#8216;generics&#8217; from version 5. A Java user would expect generics support from a Java<br />
data structure library, and the Clojure version doesn&#8217;t have this.<br />
clj-ds will support generics.</p>
<p>* Finally, a slight improvement.  Certain of the Clojure data structure methods use Clojure&#8217;s &#8216;seq&#8217; abstraction. In the implementation of the Java &#8216;iterator&#8217; pattern. It is possible, to make<br />
slightly more efficient iterators using a tailor made iterator. clj-ds does this.</p>
<p>Code: <a href="http://github.com/krukow/clj-ds">http://github.com/krukow/clj-ds</a> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.higher-order.net/2010/06/11/clj-ds-clojures-persistent-data-structures-for-java/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Stomple RC1: Combining WebSockets and Reliable Messaging</title>
		<link>http://blog.higher-order.net/2010/06/01/stomple-rc1-combining-websockets-and-reliable-messaging/</link>
		<comments>http://blog.higher-order.net/2010/06/01/stomple-rc1-combining-websockets-and-reliable-messaging/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 20:30:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.higher-order.net/?p=541</guid>
		<description><![CDATA[I&#8217;ve finished Release Candidate 1 for Stomple, my JavaScript Stomp library which uses WebSockets to access compatible Stomp Message Brokers (which includes JMS providers via StompConnect). Stomple is heavily inspired by Jeff Mesnil&#8217;s great stomp-websocket, but aims to be feature &#8230; <a href="http://blog.higher-order.net/2010/06/01/stomple-rc1-combining-websockets-and-reliable-messaging/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finished <a href="http://github.com/krukow/stomple">Release Candidate 1 for Stomple</a>, my JavaScript <a href="http://stomp.codehaus.org/Protocol">Stomp</a> library which uses WebSockets to access compatible Stomp Message Brokers (which includes JMS providers via <a href="http://stomp.codehaus.org/StompConnect">StompConnect</a>). Stomple is heavily inspired by Jeff Mesnil&#8217;s great <a href="http://jmesnil.net/stomp-websocket/doc/">stomp-websocket</a>, but aims to be feature complete and to provide a high-level API which is more customizable, robust and easy to use. </p>
<p><strong>What</strong>? From the <a href="http://stomp.codehaus.org/Home">Stomp website</a>:<br />
<blockquote>Stomp provides an interoperable wire format so that any of the available Stomp Clients can communicate with any Stomp Message Broker to provide easy and widespread messaging interop among languages, platforms and brokers.</p></blockquote>
<p>As mentioned, this includes JMS. Stomple is a JavaScript library which enables using browsers that support WebSockets as messaging clients, e.g., subscribing to an JMS topic in a JavaScript program running inside Chrome. </p>
<p>Websocket communication has less overhead than HTTP when HTTP semantics aren&#8217;t needed. More importantly, WebSockets allow the <em>server</em> to push updates to the browser (as opposed to the usual HTTP request-response paradigm). For a simple example, see the <a href="http://screencast.com/t/NzdmMGJj">screen cast of the &#8220;transactional chat example&#8221;</a> where chat messages are pushed from the server to participating clients.</p>
<p><strong>Why</strong> release Stomple when there is already stomp-websocket? First of all, Jeff did an excellent job with stomp-websocket. However, I wanted additional features and more production maturity (e.g., support for timeouts, various low- and high-level callbacks and automatic receipts). </p>
<p><strong>A few notable features:</strong></p>
<ul>
<li>Customizability and Callbacks. A key value of Stomple is that it shouldn&#8217;t cut off access to any low-level functionality. Hence everything is customizable and accessible to the user code. All core functions support success and failure callbacks. Further, there are low-level callbacks: <tt>socketOpen, socketMessage, socketClose, socketError</tt> corresponding to the low-level websocket events. These can be used to customize behaviour for special use-cases. At a higher-level, there are callbacks <tt>onConnect, connectFailed, onError, onReceipt</tt> correspoding to the Stomp events.</li>
<li>Automatic receipts. If  <tt>client.autoReceipt</tt> is true (which it is by default), then all Stomp messages sent to the server include an automatically generated &#8216;receipt&#8217; header. In the Stomp protocol, this causes the server to send a receipt for each message it receives, hence reassuring that the message has been received. If not enabled, the client can&#8217;t be sure the message is actually received. </li>
<li>Timeouts. By default all messages sent to the server are associated with a (configurable) 8 second timeout. So for example, suppose you subscribe to a destination, but do not receive a server receipt within 8 seconds: then your failure callback is called with reason &#8216;timeout&#8217; and information about the message that failed. This way you are guaranteed that either your success or failure callback will always be called (but not both <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ). These time-outs are pervasive and configurable per API call.</li>
<li>Transaction management. In Stomp, transactions are started using the &#8216;BEGIN&#8217; frame, corresponding to a begin function in Stomple. When you call begin, you don&#8217;t have to specify a transaction-id: if you don&#8217;t, one will be generated automatically for you. Further, any API calls made between a begin and a commit/abort automatically use this transaction identifier, hence grouping the calls in the same transaction (unless, of course, you explicitly provide a different or no transaction id). Further, this nests arbitrarily, and works in a stack-like manner (e.g., begin, begin, send, associates send with inner-most begin). </li>
<li>Feature complete. Stomple aims to be feature complete. For example, it supports the recommended Stomp &#8216;content-length&#8217; header, where the current stomp-websocket version does not.</li>
<li>Correctness. Stomple is tested manually and has a growing automatic test-suite written in YUI3-test. Stomple passes JSLint.</li>
</ul>
<p>I decided not to build on Jeff&#8217;s library because when APIs become more complex, I prefer using configuration-objects since it makes code more readable and easy to maintain (most Stomple functions take a single object literal parameter which names the function&#8217;s &#8220;many arguments&#8221;).<br />
For example to create a Stomple client and to configure it to use destination &#8216;jms.topic.chat&#8217; as default use:</p>
<pre><tt><span class="keyword">var</span><span class="normal"> client </span><span class="symbol">=</span><span class="normal"> Stomple</span><span class="symbol">.</span><span class="function">create_client</span><span class="symbol">(</span><span class="cbracket">{</span>
<span class="normal">    url </span><span class="symbol">:</span><span class="normal"> </span><span class="string">"ws://localhost:61614/stomp"</span><span class="symbol">,</span>
<span class="normal">    destination </span><span class="symbol">:</span><span class="normal"> </span><span class="string">"jms.topic.chat"</span><span class="symbol">,</span>
<span class="normal">    login </span><span class="symbol">:</span><span class="normal"> </span><span class="string">"guest"</span><span class="symbol">,</span>
<span class="normal">    passcode </span><span class="symbol">:</span><span class="normal"> </span><span class="string">"guest"</span>
<span class="cbracket">}</span><span class="symbol">);</span>
</tt></pre>
<p>A different example of using single-argument configuration objects would be subscribe:</p>
<pre><tt><span class="normal">client</span><span class="symbol">.</span><span class="function">subscribe</span><span class="symbol">(</span><span class="cbracket">{</span>
<span class="normal">    success</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">(</span><span class="normal">frame</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span><span class="comment">//called if subscribe succeeds within timeout-period</span>
<span class="normal">        </span><span class="comment">//subscribe succeeded... do something</span>
<span class="normal">    </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">    failure</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">(</span><span class="normal">spec</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span><span class="comment">//called if subscribe fails or times out</span>
<span class="normal">        console</span><span class="symbol">.</span><span class="function">log</span><span class="symbol">(</span><span class="normal">spec</span><span class="symbol">.</span><span class="normal">reason</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">    handler</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">(</span><span class="normal">msg</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span><span class="comment">//called when a message arrived ('this' is scope - see below) </span>
<span class="normal">        </span><span class="keyword">this</span><span class="symbol">.</span><span class="normal">received </span><span class="symbol">=</span><span class="normal"> msg</span><span class="symbol">.</span><span class="normal">body</span><span class="symbol">;</span><span class="comment">//"this" is "someObject"</span>
<span class="normal">    </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">    scope</span><span class="symbol">:</span><span class="normal"> someObject</span>
<span class="cbracket">}</span><span class="symbol">);</span></tt></pre>
<p>Note by the way that if <tt>client.autoConnect</tt> is true (which it is by default), then you don&#8217;t have to explicitly connect. Stomple will automatically connect upon your first action. The subscribe function supports an optional destination parameter in-case a default wasn&#8217;t supplied when the client object was created (or in case you want to subscribe to a non-default destination). </p>
<p><strong>How</strong>?<br />
For each Stomp client frame  (command): SEND, SUBSCRIBE, UNSUBSCRIBE, BEGIN, COMMIT, ABORT,  ACK, DISCONNECT there are  corresponding lower-case functions on the client object, e.g., send, subscribe&#8230; Defaults are specified when creating the client object. For example.</p>
<pre><tt><span class="keyword">var</span><span class="normal"> client </span><span class="symbol">=</span><span class="normal"> Stomple</span><span class="symbol">.</span><span class="function">create_client</span><span class="symbol">(</span><span class="cbracket">{</span>
<span class="normal">    url </span><span class="symbol">:</span><span class="normal"> </span><span class="string">"ws://localhost:61614/stomp"</span><span class="symbol">,</span>
<span class="normal">    destination </span><span class="symbol">:</span><span class="normal"> </span><span class="string">"jms.topic.chat"</span><span class="symbol">,</span>
<span class="normal">    login </span><span class="symbol">:</span><span class="normal"> </span><span class="string">"guest"</span><span class="symbol">,</span>
<span class="normal">    passcode </span><span class="symbol">:</span><span class="normal"> </span><span class="string">"guest"</span><span class="symbol">,</span>
<span class="normal">    autoConnect</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">true</span><span class="symbol">,</span><span class="comment">//which is actually the default</span>
<span class="normal">    timeout</span><span class="symbol">:</span><span class="normal"> </span><span class="number">3000</span><span class="symbol">,</span>
<span class="normal">    autoReceipt</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">true</span><span class="comment">//which is actually the default</span>
<span class="normal">    </span><span class="comment">//...</span>
<span class="cbracket">}</span><span class="symbol">);</span>
</tt></pre>
<p>See Stomple.ClientPrototype for all overrides.</p>
<p>Once a client object is created, the user can issue commands. For example, in the chat example a typical sequence would be.</p>
<pre><tt><span class="normal">client</span><span class="symbol">.</span><span class="function">subscribe</span><span class="symbol">(</span><span class="cbracket">{</span>
<span class="normal">    handler </span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">(</span><span class="normal">msg</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span><span class="comment">//update screen on chat msg receiption</span>
<span class="normal">	    </span><span class="keyword">var</span><span class="normal"> c </span><span class="symbol">=</span><span class="normal"> document</span><span class="symbol">.</span><span class="function">getElementById</span><span class="symbol">(</span><span class="string">'content'</span><span class="symbol">);</span>
<span class="normal">	    c</span><span class="symbol">.</span><span class="normal">innerHTML </span><span class="symbol">=</span><span class="normal"> c</span><span class="symbol">.</span><span class="normal">innerHTML </span><span class="symbol">+</span><span class="normal"> </span><span class="string">'&lt;br&gt;'</span><span class="normal"> </span><span class="symbol">+</span><span class="normal"> msg</span><span class="symbol">.</span><span class="normal">body</span><span class="symbol">;</span>
<span class="normal">	</span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">	scope </span><span class="symbol">:</span><span class="normal"> anObjectIfNeeded</span><span class="symbol">,</span>
<span class="normal">	success </span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span><span class="comment">// did subscription succeed?</span>
<span class="normal">        </span><span class="comment">//send a test message</span>
<span class="normal">        client</span><span class="symbol">.</span><span class="function">send</span><span class="symbol">(</span><span class="cbracket">{</span>
<span class="normal">            body</span><span class="symbol">:</span><span class="normal"> </span><span class="string">"User krukow joined chatroom #stomple"</span><span class="symbol">,</span>
<span class="normal">            success</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">              console</span><span class="symbol">.</span><span class="function">log</span><span class="symbol">(</span><span class="string">"sent welcome message..."</span><span class="symbol">);</span><span class="normal">          </span>
<span class="normal">            </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            failure</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">              console</span><span class="symbol">.</span><span class="function">log</span><span class="symbol">(</span><span class="string">"Failed..."</span><span class="symbol">);</span>
<span class="normal">            </span><span class="cbracket">}</span>
<span class="normal">            </span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">);</span>
<span class="normal">	</span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">	failure </span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span><span class="comment">// did subscription fail?</span>
<span class="normal">		console</span><span class="symbol">.</span><span class="function">log</span><span class="symbol">(</span><span class="string">"sub fail"</span><span class="symbol">);</span>
<span class="normal">	</span><span class="cbracket">}</span>
<span class="cbracket">}</span><span class="symbol">);</span></tt></pre>
<p>Things are pretty straightforward from here (if you get Stomp <img src='http://blog.higher-order.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> ). For more advanced examples see the automated test-suite. Here is an example of a transaction.</p>
<pre><tt><span class="keyword">this</span><span class="symbol">.</span><span class="normal">client</span><span class="symbol">.</span><span class="function">begin</span><span class="symbol">(</span><span class="cbracket">{</span>
<span class="normal">    failure</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        Y</span><span class="symbol">.</span><span class="normal">Assert</span><span class="symbol">.</span><span class="function">fail</span><span class="symbol">(</span><span class="string">"Begin transaction failed."</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">    success</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">()</span><span class="cbracket">{</span><span class="normal"> </span>
<span class="normal">		</span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">i</span><span class="symbol">=</span><span class="number">0</span><span class="symbol">;</span><span class="normal">i</span><span class="symbol">&lt;</span><span class="normal">N</span><span class="symbol">;</span><span class="normal">i</span><span class="symbol">+=</span><span class="number">1</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">			</span><span class="keyword">this</span><span class="symbol">.</span><span class="normal">client</span><span class="symbol">.</span><span class="function">send</span><span class="symbol">(</span><span class="cbracket">{</span>
<span class="normal">				body</span><span class="symbol">:</span><span class="normal"> </span><span class="string">""</span><span class="symbol">+</span><span class="normal">msgBodies</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">],</span>
<span class="normal">				failure</span><span class="symbol">:</span><span class="normal"> sendFailed</span>
<span class="normal">                </span><span class="comment">//we don't wait for receipts here... Socket provies order..</span>
<span class="normal">			</span><span class="cbracket">}</span><span class="symbol">);</span>
<span class="normal">		</span><span class="cbracket">}</span>
<span class="normal">        </span><span class="keyword">this</span><span class="symbol">.</span><span class="normal">client</span><span class="symbol">.</span><span class="function">commit</span><span class="symbol">(</span><span class="cbracket">{</span>
<span class="normal">            failure</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">                Y</span><span class="symbol">.</span><span class="normal">Assert</span><span class="symbol">.</span><span class="function">fail</span><span class="symbol">(</span><span class="string">"Commit transaction failed."</span><span class="symbol">);</span>
<span class="normal">            </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            success</span><span class="symbol">:</span><span class="normal"> </span><span class="keyword">function</span><span class="symbol">()</span><span class="cbracket">{</span><span class="comment">//...</span>
<span class="normal">            </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>
<span class="cbracket">}</span><span class="symbol">);</span></tt></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.higher-order.net/2010/06/01/stomple-rc1-combining-websockets-and-reliable-messaging/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>My son</title>
		<link>http://blog.higher-order.net/2010/05/24/my-son/</link>
		<comments>http://blog.higher-order.net/2010/05/24/my-son/#comments</comments>
		<pubDate>Mon, 24 May 2010 09:32:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.higher-order.net/2010/05/24/my-son/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.higher-order.net/wp-content/uploads/2010/05/Frej_og_Far.jpg"><img src="http://blog.higher-order.net/wp-content/uploads/2010/05/Frej_og_Far.jpg" alt="My son and I" title="My son and I" width="768" height="1024" class="alignright size-full wp-image-524" /></a> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.higher-order.net/2010/05/24/my-son/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

