<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
	<title>Comments for Foognostic blogs</title>
	
	<link>http://blogs.foognostic.net</link>
	<description>Seeking knowledge of foo</description>
	<lastBuildDate>Wed, 13 Jan 2010 14:49:16 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CommentsForFoognosticBlogs" /><feedburner:info uri="commentsforfoognosticblogs" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Comment on Presenting on Leiningen to Cap-Clug by fogus</title>
		<link>http://feedproxy.google.com/~r/CommentsForFoognosticBlogs/~3/_QdZgHhyFqM/</link>
		<dc:creator>fogus</dc:creator>
		<pubDate>Wed, 13 Jan 2010 14:49:16 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.foognostic.net/?p=341#comment-413</guid>
		<description>&lt;p&gt;Thanks for the shout-out.  I'm likewise excited to see your presentation as I've not had a chance to dig into Leiningen and Clojars.  :-)&lt;/p&gt;

&lt;p&gt;See you there.
-m&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Thanks for the shout-out.  I&#8217;m likewise excited to see your presentation as I&#8217;ve not had a chance to dig into Leiningen and Clojars.  <img src='http://blogs.foognostic.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>

<p>See you there.
-m</p><img src="http://feeds.feedburner.com/~r/CommentsForFoognosticBlogs/~4/_QdZgHhyFqM" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blogs.foognostic.net/2010/01/presenting-on-leiningen-to-cap-clug/comment-page-1/#comment-413</feedburner:origLink></item>
	<item>
		<title>Comment on The path of least resistance in Clojure by Seth Schroeder</title>
		<link>http://feedproxy.google.com/~r/CommentsForFoognosticBlogs/~3/Zxlz5Amz6F0/</link>
		<dc:creator>Seth Schroeder</dc:creator>
		<pubDate>Tue, 01 Dec 2009 13:37:58 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.foognostic.net/?p=254#comment-376</guid>
		<description>&lt;p&gt;Yes, it was unintentional to suggest that immutability leads to silent runtime failures. The intent was to a.) demonstrate one subtle reason it's bad to think in Java while coding in Clojure (you're not changing the object you think you're changing), and b.) provide a very small band-aid to patch up the problem (rebind the output). I wish I had thought how rotten a band-aid that suggestion was... but I was rushing to meet a self-imposed deadline.&lt;/p&gt;

&lt;p&gt;Did the actual output end up anywhere near where I wanted it? Sadly no: it was worse than silence. So that's a good lesson for me to keep in mind as I continue to blog.&lt;/p&gt;

&lt;p&gt;I appreciate the detailed feedback!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Yes, it was unintentional to suggest that immutability leads to silent runtime failures. The intent was to a.) demonstrate one subtle reason it&#8217;s bad to think in Java while coding in Clojure (you&#8217;re not changing the object you think you&#8217;re changing), and b.) provide a very small band-aid to patch up the problem (rebind the output). I wish I had thought how rotten a band-aid that suggestion was&#8230; but I was rushing to meet a self-imposed deadline.</p>

<p>Did the actual output end up anywhere near where I wanted it? Sadly no: it was worse than silence. So that&#8217;s a good lesson for me to keep in mind as I continue to blog.</p>

<p>I appreciate the detailed feedback!</p><img src="http://feeds.feedburner.com/~r/CommentsForFoognosticBlogs/~4/Zxlz5Amz6F0" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blogs.foognostic.net/2009/11/the-path-of-least-resistance-in-clojure/comment-page-1/#comment-376</feedburner:origLink></item>
	<item>
		<title>Comment on The path of least resistance in Clojure by Stuart Halloway</title>
		<link>http://feedproxy.google.com/~r/CommentsForFoognosticBlogs/~3/mfpgP6B0icE/</link>
		<dc:creator>Stuart Halloway</dc:creator>
		<pubDate>Mon, 30 Nov 2009 23:33:03 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.foognostic.net/?p=254#comment-374</guid>
		<description>&lt;p&gt;Sorry not to have responded in more detail after my earlier tweet--the iPhone is not the best for long-winded replies. It's great to post about your experiences when learning Clojure, and I think you will find the community, such as the previous commenters here, to be helpful resources.&lt;/p&gt;

&lt;p&gt;As written, and probably unintentionally, your original post suggests that immutability leads to silent runtime failures, while mutation is easy to follow and understand. This is exactly backwards, and is critical to understanding Clojure.&lt;/p&gt;

&lt;p&gt;I hope you will continue to post your experiences, and make the tentative, learning nature of these posts clear in the body of the text as you go. Also, if you haven't already, give the IRC a try, there is almost always someone there to talk to.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Sorry not to have responded in more detail after my earlier tweet&#8211;the iPhone is not the best for long-winded replies. It&#8217;s great to post about your experiences when learning Clojure, and I think you will find the community, such as the previous commenters here, to be helpful resources.</p>

<p>As written, and probably unintentionally, your original post suggests that immutability leads to silent runtime failures, while mutation is easy to follow and understand. This is exactly backwards, and is critical to understanding Clojure.</p>

<p>I hope you will continue to post your experiences, and make the tentative, learning nature of these posts clear in the body of the text as you go. Also, if you haven&#8217;t already, give the IRC a try, there is almost always someone there to talk to.</p><img src="http://feeds.feedburner.com/~r/CommentsForFoognosticBlogs/~4/mfpgP6B0icE" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blogs.foognostic.net/2009/11/the-path-of-least-resistance-in-clojure/comment-page-1/#comment-374</feedburner:origLink></item>
	<item>
		<title>Comment on The path of least resistance in Clojure by Seth Schroeder</title>
		<link>http://feedproxy.google.com/~r/CommentsForFoognosticBlogs/~3/kFBPDRBjJrU/</link>
		<dc:creator>Seth Schroeder</dc:creator>
		<pubDate>Wed, 25 Nov 2009 11:16:41 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.foognostic.net/?p=254#comment-367</guid>
		<description>&lt;p&gt;Wow, this was amazingly helpful. Thank you so much! I was surprised that so little code needed to change. This will be very helpful when I start digging into the concurrency parts of Clojure.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Wow, this was amazingly helpful. Thank you so much! I was surprised that so little code needed to change. This will be very helpful when I start digging into the concurrency parts of Clojure.</p><img src="http://feeds.feedburner.com/~r/CommentsForFoognosticBlogs/~4/kFBPDRBjJrU" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blogs.foognostic.net/2009/11/the-path-of-least-resistance-in-clojure/comment-page-1/#comment-367</feedburner:origLink></item>
	<item>
		<title>Comment on The path of least resistance in Clojure by Paul Barry</title>
		<link>http://feedproxy.google.com/~r/CommentsForFoognosticBlogs/~3/pLrvZNNQwHM/</link>
		<dc:creator>Paul Barry</dc:creator>
		<pubDate>Tue, 24 Nov 2009 16:44:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.foognostic.net/?p=254#comment-363</guid>
		<description>&lt;p&gt;When you are first getting using to working with immutable data structures it does seem counter-intuitive at first, but once you learn to think differently about it, it makes sense.  Here's the key difference between Clojure and Java.&lt;/p&gt;

&lt;p&gt;In your Java example, you have a reference (the customer variable) to a mutable object (an instance of Customer).  You call methods on that object to modify the state of the object.  If you have multiple references to that instance of Customer, all those references see those changes.  They may be what you want, but often times, especially in the context of a multithreaded application where multiple threads are trying to update the Customer, that could be a big problem.&lt;/p&gt;

&lt;p&gt;In Clojure, instead of modifying the Customer instance that your reference customer points to, you create a new "Customer instance" and modify the reference to point at the new "Customer instance".  I put that in quotes because you will use a Map to store the Customer data, not an object, but either way, it's the data structure that holds the customer data.  This still has the same effect of modifying the Customer and does it in a way where multiple threads could do it concurrently without a problem.&lt;/p&gt;

&lt;p&gt;I've modified your example to use a ref and you can see that calling add-order twice results in adding two orders to the customer:&lt;/p&gt;

&lt;p&gt;http://gist.github.com/242000&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>When you are first getting using to working with immutable data structures it does seem counter-intuitive at first, but once you learn to think differently about it, it makes sense.  Here&#8217;s the key difference between Clojure and Java.</p>

<p>In your Java example, you have a reference (the customer variable) to a mutable object (an instance of Customer).  You call methods on that object to modify the state of the object.  If you have multiple references to that instance of Customer, all those references see those changes.  They may be what you want, but often times, especially in the context of a multithreaded application where multiple threads are trying to update the Customer, that could be a big problem.</p>

<p>In Clojure, instead of modifying the Customer instance that your reference customer points to, you create a new &#8220;Customer instance&#8221; and modify the reference to point at the new &#8220;Customer instance&#8221;.  I put that in quotes because you will use a Map to store the Customer data, not an object, but either way, it&#8217;s the data structure that holds the customer data.  This still has the same effect of modifying the Customer and does it in a way where multiple threads could do it concurrently without a problem.</p>

<p>I&#8217;ve modified your example to use a ref and you can see that calling add-order twice results in adding two orders to the customer:</p>

<p><a href="http://gist.github.com/242000" rel="nofollow">http://gist.github.com/242000</a></p><img src="http://feeds.feedburner.com/~r/CommentsForFoognosticBlogs/~4/pLrvZNNQwHM" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blogs.foognostic.net/2009/11/the-path-of-least-resistance-in-clojure/comment-page-1/#comment-363</feedburner:origLink></item>
	<item>
		<title>Comment on The path of least resistance in Clojure by Anonymous</title>
		<link>http://feedproxy.google.com/~r/CommentsForFoognosticBlogs/~3/hwk24CJ5b8Q/</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Tue, 24 Nov 2009 15:54:48 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.foognostic.net/?p=254#comment-362</guid>
		<description>&lt;p&gt;Hmm, redefining 'me' doesn't seem like a good idea to me either.  Why not use STM to safely modify the value?&lt;/p&gt;

&lt;p&gt;Unfortunately, I actually find the Java code more readable in this example as well :(&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hmm, redefining &#8216;me&#8217; doesn&#8217;t seem like a good idea to me either.  Why not use STM to safely modify the value?</p>

<p>Unfortunately, I actually find the Java code more readable in this example as well <img src='http://blogs.foognostic.net/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p><img src="http://feeds.feedburner.com/~r/CommentsForFoognosticBlogs/~4/hwk24CJ5b8Q" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blogs.foognostic.net/2009/11/the-path-of-least-resistance-in-clojure/comment-page-1/#comment-362</feedburner:origLink></item>
	<item>
		<title>Comment on The path of least resistance in Clojure by Chas Emerick</title>
		<link>http://feedproxy.google.com/~r/CommentsForFoognosticBlogs/~3/a30WU2kQuNs/</link>
		<dc:creator>Chas Emerick</dc:creator>
		<pubDate>Tue, 24 Nov 2009 15:46:47 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.foognostic.net/?p=254#comment-361</guid>
		<description>&lt;p&gt;FYI, you really should not be rebinding new references to data in top level vars (which is what def does).  That's fine for playing at the REPL, but such global state is best reserved for functions, etc.&lt;/p&gt;

&lt;p&gt;Further, you don't need to use structs -- regular maps will do, unless you have a good reason to use structs' specific talents.  e.g.:&lt;/p&gt;

&lt;p&gt;(update-in customer [:orders] conj 
{:rush? true
  :lines [{:qty 6 :code "TAL"}
            {:qty 5 :code "HPK", :skippable? true}
            {:qty 3 :code "LGV"}]})&lt;/p&gt;

&lt;p&gt;There's &lt;em&gt;no way&lt;/em&gt; that formatting is going to come through! :-P&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>FYI, you really should not be rebinding new references to data in top level vars (which is what def does).  That&#8217;s fine for playing at the REPL, but such global state is best reserved for functions, etc.</p>

<p>Further, you don&#8217;t need to use structs &#8212; regular maps will do, unless you have a good reason to use structs&#8217; specific talents.  e.g.:</p>

<p>(update-in customer [:orders] conj 
{:rush? true
  :lines [{:qty 6 :code "TAL"}
            {:qty 5 :code "HPK", :skippable? true}
            {:qty 3 :code "LGV"}]})</p>

<p>There&#8217;s <em>no way</em> that formatting is going to come through! <img src='http://blogs.foognostic.net/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> </p><img src="http://feeds.feedburner.com/~r/CommentsForFoognosticBlogs/~4/a30WU2kQuNs" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blogs.foognostic.net/2009/11/the-path-of-least-resistance-in-clojure/comment-page-1/#comment-361</feedburner:origLink></item>
	<item>
		<title>Comment on The path of least resistance in Clojure by Tweets that mention The path of least resistance in Clojure « Foognostic blogs -- Topsy.com</title>
		<link>http://feedproxy.google.com/~r/CommentsForFoognosticBlogs/~3/4yUwMskRXfw/</link>
		<dc:creator>Tweets that mention The path of least resistance in Clojure « Foognostic blogs -- Topsy.com</dc:creator>
		<pubDate>Tue, 24 Nov 2009 15:21:00 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.foognostic.net/?p=254#comment-360</guid>
		<description>&lt;p&gt;[...] This post was mentioned on Twitter by fogus, Seth S. Seth S said: Posted a blog about the path less traveled in Clojure: http://blogs.foognostic.net/2009/11/the-path-of-least-resistance-in-clojure/ [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] This post was mentioned on Twitter by fogus, Seth S. Seth S said: Posted a blog about the path less traveled in Clojure: <a href="http://blogs.foognostic.net/2009/11/the-path-of-least-resistance-in-clojure/" rel="nofollow">http://blogs.foognostic.net/2009/11/the-path-of-least-resistance-in-clojure/</a> [...]</p><img src="http://feeds.feedburner.com/~r/CommentsForFoognosticBlogs/~4/4yUwMskRXfw" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blogs.foognostic.net/2009/11/the-path-of-least-resistance-in-clojure/comment-page-1/#comment-360</feedburner:origLink></item>
	<item>
		<title>Comment on Announcing Pokerepl by Seth Schroeder</title>
		<link>http://feedproxy.google.com/~r/CommentsForFoognosticBlogs/~3/SHRRyVQT7Kg/</link>
		<dc:creator>Seth Schroeder</dc:creator>
		<pubDate>Mon, 16 Nov 2009 13:54:03 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.foognostic.net/?p=249#comment-349</guid>
		<description>&lt;p&gt;Neat, I had no idea you could do that. Thanks for building and sustaining BitBucket. I'm very happy with it!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Neat, I had no idea you could do that. Thanks for building and sustaining BitBucket. I&#8217;m very happy with it!</p><img src="http://feeds.feedburner.com/~r/CommentsForFoognosticBlogs/~4/SHRRyVQT7Kg" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blogs.foognostic.net/2009/11/announcing-pokerepl/comment-page-1/#comment-349</feedburner:origLink></item>
	<item>
		<title>Comment on Macros make Elvis better by Seth Schroeder</title>
		<link>http://feedproxy.google.com/~r/CommentsForFoognosticBlogs/~3/3zpzJSR42ew/</link>
		<dc:creator>Seth Schroeder</dc:creator>
		<pubDate>Mon, 16 Nov 2009 13:48:34 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.foognostic.net/?p=222#comment-348</guid>
		<description>&lt;p&gt;Apparently so! I hadn't thought about using (or) for some strange reason. It would be a bad (or) that didn't defer evaluation.&lt;/p&gt;

&lt;p&gt;It was fun trying to combine (or) and (def) with a macro. I'm learning about macros slowly but don't understand why one of these works and the other fails:&lt;/p&gt;

&lt;p&gt;&lt;code lang="clojure"&gt;
(defmacro ordef-happy [var t f]
  `(def ~var (or ~t ~f)))

(defmacro ordef-fale [var t f]
  (def var (or t f)))

user&gt; (def foo :UGH) (ordef-happy foo :bar :baz) foo
:bar
user&gt; (def foo :UGH) (ordef-fale foo :bar :baz) foo
:UGH
&lt;/code&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Apparently so! I hadn&#8217;t thought about using (or) for some strange reason. It would be a bad (or) that didn&#8217;t defer evaluation.</p>

<p>It was fun trying to combine (or) and (def) with a macro. I&#8217;m learning about macros slowly but don&#8217;t understand why one of these works and the other fails:</p>

<p>

<div class="codecolorer-container clojure vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="clojure codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defmacro</span> ordef-happy <span style="color: #66cc66;">&#91;</span><span style="color: #b1b100;">var</span> t f<span style="color: #66cc66;">&#93;</span><br />
&nbsp; `<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">def</span> ~<span style="color: #b1b100;">var</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">or</span> ~t ~f<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
<br />
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defmacro</span> ordef-fale <span style="color: #66cc66;">&#91;</span><span style="color: #b1b100;">var</span> t f<span style="color: #66cc66;">&#93;</span><br />
&nbsp; <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">def</span> <span style="color: #b1b100;">var</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">or</span> t f<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><br />
<br />
user&gt; <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">def</span> foo :UGH<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>ordef-happy foo :bar :baz<span style="color: #66cc66;">&#41;</span> foo<br />
:bar<br />
user&gt; <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">def</span> foo :UGH<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>ordef-fale foo :bar :baz<span style="color: #66cc66;">&#41;</span> foo<br />
:UGH</div></div>

</p><img src="http://feeds.feedburner.com/~r/CommentsForFoognosticBlogs/~4/3zpzJSR42ew" height="1" width="1"/>]]></content:encoded>
	<feedburner:origLink>http://blogs.foognostic.net/2009/11/macros-make-elvis-better/comment-page-1/#comment-348</feedburner:origLink></item>
</channel>
</rss><!-- Dynamic page generated in 0.745 seconds. --><!-- Cached page generated by WP-Super-Cache on 2010-02-08 05:56:57 --><!-- Compression = gzip -->
