<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	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>Comments on: Hashes And Trees Are Not Fungible</title>
	<atom:link href="http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/feed/" rel="self" type="application/rss+xml" />
	<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/</link>
	<description>Leveraging Perl and Emacs</description>
	<lastBuildDate>Sat, 15 Jun 2013 02:12:16 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jared</title>
		<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/#comment-8400</link>
		<dc:creator><![CDATA[Jared]]></dc:creator>
		<pubDate>Sun, 03 Oct 2010 15:54:13 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/?p=1281#comment-8400</guid>
		<description><![CDATA[@Nathan - yep, good point about binary trees.  I should have said trees of course.  Cons cells are useful for making any type of tree.  If I include unsorted trees, they&#039;re even more useful vs plain hashes with (for example) hierarchy information included for free.

Personally, I often find that I need to iterate over a range shortly after I&#039;ve implemented something complex in a hash, e.g. an LRU cache or whatever.  Yes, you could say this shows a lack of foresight :)

For the search of hash usage vs tree usage, I&#039;m going to attribute this to the English Effect.  I&#039;m sure if you look at a typical native lisper&#039;s code where trees are 1st class structures and hashes are definitely 2nd class, they will find more utility for trees.  Heck, even C++ got map before hashmap.

Anyway, interesting discussion.  I enjoyed it :)]]></description>
		<content:encoded><![CDATA[<p>@Nathan &#8211; yep, good point about binary trees.  I should have said trees of course.  Cons cells are useful for making any type of tree.  If I include unsorted trees, they&#8217;re even more useful vs plain hashes with (for example) hierarchy information included for free.</p>
<p>Personally, I often find that I need to iterate over a range shortly after I&#8217;ve implemented something complex in a hash, e.g. an LRU cache or whatever.  Yes, you could say this shows a lack of foresight <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>For the search of hash usage vs tree usage, I&#8217;m going to attribute this to the English Effect.  I&#8217;m sure if you look at a typical native lisper&#8217;s code where trees are 1st class structures and hashes are definitely 2nd class, they will find more utility for trees.  Heck, even C++ got map before hashmap.</p>
<p>Anyway, interesting discussion.  I enjoyed it <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nathan</title>
		<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/#comment-8393</link>
		<dc:creator><![CDATA[Nathan]]></dc:creator>
		<pubDate>Fri, 01 Oct 2010 13:51:00 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/?p=1281#comment-8393</guid>
		<description><![CDATA[@Jared: I think the connotation of &quot;binary tree&quot; is that there are some value at the nodes, which is three pieces of information, rather than two.  (Yes, you can implement this with cons cells.)  Talking about the fundamental datatype of Lisp being trees is liable to receive a double-take, even if the listener has read TAoCP volume 1.

I think we are in violent (mostly) agreement.  Both of us have said that if you want sorted range iteration of some kind, then you ought to use a tree instead of a hash.  No argument there.  I think where we disagree is that you think sorted range iteration is a common thing to do; that has not been my experience.  Nor can I think of too many instances where it would have been helpful.

As a quick-and-dirty calculation, looking for HashMap in Java code via codesearch.google.com results in more than 10x the number of hits than looking for TreeMap.  This is an imperfect way of looking at it: the first page of results for both are from open-source Java implementations, for instance.  Context is also lacking; the keys from those HashMaps might be sorted for further processing, in which case a TreeMap might have been the better choice.  But 10x suggests that a fair number of other programmers think sorted range iteration is not a very common operation either.]]></description>
		<content:encoded><![CDATA[<p>@Jared: I think the connotation of &#8220;binary tree&#8221; is that there are some value at the nodes, which is three pieces of information, rather than two.  (Yes, you can implement this with cons cells.)  Talking about the fundamental datatype of Lisp being trees is liable to receive a double-take, even if the listener has read TAoCP volume 1.</p>
<p>I think we are in violent (mostly) agreement.  Both of us have said that if you want sorted range iteration of some kind, then you ought to use a tree instead of a hash.  No argument there.  I think where we disagree is that you think sorted range iteration is a common thing to do; that has not been my experience.  Nor can I think of too many instances where it would have been helpful.</p>
<p>As a quick-and-dirty calculation, looking for HashMap in Java code via codesearch.google.com results in more than 10x the number of hits than looking for TreeMap.  This is an imperfect way of looking at it: the first page of results for both are from open-source Java implementations, for instance.  Context is also lacking; the keys from those HashMaps might be sorted for further processing, in which case a TreeMap might have been the better choice.  But 10x suggests that a fair number of other programmers think sorted range iteration is not a very common operation either.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jared</title>
		<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/#comment-8392</link>
		<dc:creator><![CDATA[Jared]]></dc:creator>
		<pubDate>Thu, 30 Sep 2010 21:21:16 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/?p=1281#comment-8392</guid>
		<description><![CDATA[@Ramon - I&#039;ll try it with humour next time and let you know how it works out :)]]></description>
		<content:encoded><![CDATA[<p>@Ramon &#8211; I&#8217;ll try it with humour next time and let you know how it works out <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jared</title>
		<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/#comment-8391</link>
		<dc:creator><![CDATA[Jared]]></dc:creator>
		<pubDate>Thu, 30 Sep 2010 21:20:28 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/?p=1281#comment-8391</guid>
		<description><![CDATA[@Fulko - YET!  No wait, your assertion was not negative ;)

Although yet, followed by a reason would work (it would still be a little clumsy) I&#039;m afraid YET! doesn&#039;t work standalone in the same way as Doch (if I understand Doch usage correctly - admittedly I don&#039;t intuit German well).  AND!? might work better, but then I think UND!? would be similar in German and still different from Doch oder?]]></description>
		<content:encoded><![CDATA[<p>@Fulko &#8211; YET!  No wait, your assertion was not negative <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Although yet, followed by a reason would work (it would still be a little clumsy) I&#8217;m afraid YET! doesn&#8217;t work standalone in the same way as Doch (if I understand Doch usage correctly &#8211; admittedly I don&#8217;t intuit German well).  AND!? might work better, but then I think UND!? would be similar in German and still different from Doch oder?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jared</title>
		<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/#comment-8390</link>
		<dc:creator><![CDATA[Jared]]></dc:creator>
		<pubDate>Thu, 30 Sep 2010 21:14:45 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/?p=1281#comment-8390</guid>
		<description><![CDATA[@Nathan - on the fundamental type in lisp being trees: cons cells have a car, and a cdr.  And you can store anything you like in either one, including other cons cells.  That seems like a binary tree to me.

on trees requiring a less than function: Hashes require a hashing function.  If a built-in hash can provide a hashing function for anything under the covers, so a built-in tree could provide an ordering function under the covers (if you&#039;re really stuck for ideas you could use less(hash(key)).  In some cases an ordered traversal would return seemingly random elements, just like a traversal of a hash.  In others, an ordered traversal would do what you expect.

Aside from a slightly slower store/retrieve operation, you don&#039;t lose anything by having your fundamental type be a tree instead of a hash.  But in many cases you gain a decent key range operation.

I don&#039;t doubt that you understand what a tree is.  But I think the fact that you don&#039;t see opportunities to use them all over the place just means your native language consists of scalars, extensible arrays and hashes which has constrained your thinking.  I think I have the same reaction to Graphs.  I know what they are, and I have some ideas about the problem domains in which they are useful.  But doggone it, I&#039;m sure I could just replace them with a tree and not lose too much!

It&#039;s the English Effect - my language doesn&#039;t contain graphs, or Doch!]]></description>
		<content:encoded><![CDATA[<p>@Nathan &#8211; on the fundamental type in lisp being trees: cons cells have a car, and a cdr.  And you can store anything you like in either one, including other cons cells.  That seems like a binary tree to me.</p>
<p>on trees requiring a less than function: Hashes require a hashing function.  If a built-in hash can provide a hashing function for anything under the covers, so a built-in tree could provide an ordering function under the covers (if you&#8217;re really stuck for ideas you could use less(hash(key)).  In some cases an ordered traversal would return seemingly random elements, just like a traversal of a hash.  In others, an ordered traversal would do what you expect.</p>
<p>Aside from a slightly slower store/retrieve operation, you don&#8217;t lose anything by having your fundamental type be a tree instead of a hash.  But in many cases you gain a decent key range operation.</p>
<p>I don&#8217;t doubt that you understand what a tree is.  But I think the fact that you don&#8217;t see opportunities to use them all over the place just means your native language consists of scalars, extensible arrays and hashes which has constrained your thinking.  I think I have the same reaction to Graphs.  I know what they are, and I have some ideas about the problem domains in which they are useful.  But doggone it, I&#8217;m sure I could just replace them with a tree and not lose too much!</p>
<p>It&#8217;s the English Effect &#8211; my language doesn&#8217;t contain graphs, or Doch!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fulko</title>
		<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/#comment-8389</link>
		<dc:creator><![CDATA[Fulko]]></dc:creator>
		<pubDate>Thu, 30 Sep 2010 16:37:02 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/?p=1281#comment-8389</guid>
		<description><![CDATA[My translation of &#039;doch&#039; would be to use the word &#039;yet&#039;

You can always follow &#039;yet&#039; with your reason,
or you can let it stand-alone as your comeback.

YET! ...]]></description>
		<content:encoded><![CDATA[<p>My translation of &#8216;doch&#8217; would be to use the word &#8216;yet&#8217;</p>
<p>You can always follow &#8216;yet&#8217; with your reason,<br />
or you can let it stand-alone as your comeback.</p>
<p>YET! &#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nathan</title>
		<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/#comment-8388</link>
		<dc:creator><![CDATA[Nathan]]></dc:creator>
		<pubDate>Thu, 30 Sep 2010 15:55:56 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/?p=1281#comment-8388</guid>
		<description><![CDATA[I do understand trees.  So much so that I&#039;ve written a library for them in Common Lisp.  ;)  The inspiration for them *was* to implement an in-memory database where I needed to iterate through in sorted order...but I haven&#039;t really needed them besides that, in CL or other places.  (I&#039;m not totally happy with my implementation, but that&#039;s another story...)  It&#039;s funny that you think of the basic datatype of Lisp as a tree, though; I&#039;ve never heard it expressed that way before.

If trees are your fundamental map, using them requires you to implement an ordering over whatever type your keys are.  Which can be an unnecessary irritation, especially if you don&#039;t naturally think of your keys as having an ordering.  Or maybe it&#039;s not straightforward to give them an ordering.  And it&#039;s another piece of code to write and debug...  Hashes (in dynamic languages) make it very easy to use whatever you like as a key; the implementation hides all those details.

Ordering constraints also make using multiple datatypes as keys tricky; doing so is very easy with a hashtable.  (Granted, I think it would be unusual to have such a table.)

Depending on your area of concern, these may be trivial or they may be significant speed bumps.]]></description>
		<content:encoded><![CDATA[<p>I do understand trees.  So much so that I&#8217;ve written a library for them in Common Lisp.  <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   The inspiration for them *was* to implement an in-memory database where I needed to iterate through in sorted order&#8230;but I haven&#8217;t really needed them besides that, in CL or other places.  (I&#8217;m not totally happy with my implementation, but that&#8217;s another story&#8230;)  It&#8217;s funny that you think of the basic datatype of Lisp as a tree, though; I&#8217;ve never heard it expressed that way before.</p>
<p>If trees are your fundamental map, using them requires you to implement an ordering over whatever type your keys are.  Which can be an unnecessary irritation, especially if you don&#8217;t naturally think of your keys as having an ordering.  Or maybe it&#8217;s not straightforward to give them an ordering.  And it&#8217;s another piece of code to write and debug&#8230;  Hashes (in dynamic languages) make it very easy to use whatever you like as a key; the implementation hides all those details.</p>
<p>Ordering constraints also make using multiple datatypes as keys tricky; doing so is very easy with a hashtable.  (Granted, I think it would be unusual to have such a table.)</p>
<p>Depending on your area of concern, these may be trivial or they may be significant speed bumps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jared</title>
		<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/#comment-8386</link>
		<dc:creator><![CDATA[Jared]]></dc:creator>
		<pubDate>Thu, 30 Sep 2010 11:45:52 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/?p=1281#comment-8386</guid>
		<description><![CDATA[I tried to point out that Nathan probably understands trees in footnote 2.

And I kind of get that rationalization. But if I was only going to get one of hashes and trees, I&#039;d rather have trees. Log2 N isn&#039;t much slower for normal usage, and you get much saner range traversal.]]></description>
		<content:encoded><![CDATA[<p>I tried to point out that Nathan probably understands trees in footnote 2.</p>
<p>And I kind of get that rationalization. But if I was only going to get one of hashes and trees, I&#8217;d rather have trees. Log2 N isn&#8217;t much slower for normal usage, and you get much saner range traversal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zbigniew Lukasiak</title>
		<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/#comment-8385</link>
		<dc:creator><![CDATA[Zbigniew Lukasiak]]></dc:creator>
		<pubDate>Thu, 30 Sep 2010 11:35:55 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/?p=1281#comment-8385</guid>
		<description><![CDATA[I am with Nathan on this one - it is not that he does not understand the differences between the various algorithms - what he says is that for most purposes they are close enough.  This is about Huffman coding the language - the cases where you really need trees (or bags, sets, etc) - are so rare that they can be relegated to the libraries.]]></description>
		<content:encoded><![CDATA[<p>I am with Nathan on this one &#8211; it is not that he does not understand the differences between the various algorithms &#8211; what he says is that for most purposes they are close enough.  This is about Huffman coding the language &#8211; the cases where you really need trees (or bags, sets, etc) &#8211; are so rare that they can be relegated to the libraries.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramon Leon</title>
		<link>http://curiousprogrammer.wordpress.com/2010/09/30/hashes-and-trees-are-not-fungible/#comment-8384</link>
		<dc:creator><![CDATA[Ramon Leon]]></dc:creator>
		<pubDate>Thu, 30 Sep 2010 06:46:23 +0000</pubDate>
		<guid isPermaLink="false">http://curiousprogrammer.wordpress.com/?p=1281#comment-8384</guid>
		<description><![CDATA[If you use the appropriate humor when saying it, they&#039;ll get the gist of it.]]></description>
		<content:encoded><![CDATA[<p>If you use the appropriate humor when saying it, they&#8217;ll get the gist of it.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
