<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Writing better code: it&#8217;s imperative that you are declarative</title>
	<atom:link href="http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/feed/" rel="self" type="application/rss+xml" />
	<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/</link>
	<description>Andrew Hare&#039;s coding blog</description>
	<lastBuildDate>Thu, 14 Apr 2011 13:45:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Sergey</title>
		<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/comment-page-1/#comment-199</link>
		<dc:creator>Sergey</dc:creator>
		<pubDate>Wed, 28 Apr 2010 08:24:33 +0000</pubDate>
		<guid isPermaLink="false">http://togaroga.com/blog/?p=425#comment-199</guid>
		<description>&lt;p&gt;Andrew, it&#039;s a very good article and I absolutely agree with you. I think that who are not agree with you should read very nice book
&quot;Functional Programming for the Real World with examples in F# and C# by Tomas Petricek and Jon Skeet&quot; (yes, Jon Skeet) or just one chapter from this book &quot;1.2 Functional programming by example&quot; and they will change their mind very quickly :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Andrew, it&#8217;s a very good article and I absolutely agree with you. I think that who are not agree with you should read very nice book
&#8220;Functional Programming for the Real World with examples in F# and C# by Tomas Petricek and Jon Skeet&#8221; (yes, Jon Skeet) or just one chapter from this book &#8220;1.2 Functional programming by example&#8221; and they will change their mind very quickly :)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/comment-page-1/#comment-177</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Sat, 24 Apr 2010 13:45:46 +0000</pubDate>
		<guid isPermaLink="false">http://togaroga.com/blog/?p=425#comment-177</guid>
		<description>&lt;p&gt;@Michael Chandler - You make an excellent point about parallelization - declarative code is much easier to parallelize!  Thank you for your comment!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Michael Chandler &#8211; You make an excellent point about parallelization &#8211; declarative code is much easier to parallelize!  Thank you for your comment!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Chandler</title>
		<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/comment-page-1/#comment-176</link>
		<dc:creator>Michael Chandler</dc:creator>
		<pubDate>Sat, 24 Apr 2010 13:22:05 +0000</pubDate>
		<guid isPermaLink="false">http://togaroga.com/blog/?p=425#comment-176</guid>
		<description>&lt;p&gt;I&#039;m surprised to see so many people disagreeing with you. I totally agree with you that the readability of the second and third examples prevail. Clearly in this case it&#039;s a trivial example, but breaking out a lambda into a separate method is a great way of self-documenting what its purpose is.&lt;/p&gt;

&lt;p&gt;It&#039;s also disappointing to see that people &lt;em&gt;assume&lt;/em&gt; that declarative performance is going to be worse than that of the imperative counterpart. How does your imperative, state-based code stack up when you need to perform in parallel? Functional / declarative programming seems to be the way forward in addressing much of these problems. You can&#039;t just stick an .IsParallel onto the end of your imperative code, that&#039;s for sure.&lt;/p&gt;

&lt;p&gt;The comment about using &amp; vs % is just silly. Either work fine. In my opinion modulus is a &#039;higher level of abstraction&#039; than the bitwise operator, so I would generally using it. (Yes, even if it&#039;s an operation slower.)&lt;/p&gt;

&lt;p&gt;I&#039;ve added your blog to my Google Reader. :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I&#8217;m surprised to see so many people disagreeing with you. I totally agree with you that the readability of the second and third examples prevail. Clearly in this case it&#8217;s a trivial example, but breaking out a lambda into a separate method is a great way of self-documenting what its purpose is.</p>

<p>It&#8217;s also disappointing to see that people <em>assume</em> that declarative performance is going to be worse than that of the imperative counterpart. How does your imperative, state-based code stack up when you need to perform in parallel? Functional / declarative programming seems to be the way forward in addressing much of these problems. You can&#8217;t just stick an .IsParallel onto the end of your imperative code, that&#8217;s for sure.</p>

<p>The comment about using &amp; vs % is just silly. Either work fine. In my opinion modulus is a &#8216;higher level of abstraction&#8217; than the bitwise operator, so I would generally using it. (Yes, even if it&#8217;s an operation slower.)</p>

<p>I&#8217;ve added your blog to my Google Reader. :)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/comment-page-1/#comment-171</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Sat, 17 Apr 2010 18:24:04 +0000</pubDate>
		<guid isPermaLink="false">http://togaroga.com/blog/?p=425#comment-171</guid>
		<description>&lt;p&gt;@John Haugeland - I appreciate the Erlang example, your use of &lt;code&gt;list.sum&lt;/code&gt; and &lt;code&gt;list.seq&lt;/code&gt; both greatly contribute to its declarative nature.  I am not completely certain what you meant by these two statements:&lt;/p&gt;

&lt;blockquote&gt;
  &#160;&quot;Thanks for not confusing the effects of one particular language’s syntax with those of a style of language.&quot;&lt;br/&gt;
&#160;&quot;You’re really just showing off the effects of a bad formatting style.&quot;
&lt;/blockquote&gt;

&lt;p&gt;Would you mind explaining a bit more?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@John Haugeland &#8211; I appreciate the Erlang example, your use of <code>list.sum</code> and <code>list.seq</code> both greatly contribute to its declarative nature.  I am not completely certain what you meant by these two statements:</p>

<blockquote>
  &nbsp;&#8221;Thanks for not confusing the effects of one particular language’s syntax with those of a style of language.&#8221;<br />
&nbsp;&#8221;You’re really just showing off the effects of a bad formatting style.&#8221;
</blockquote>

<p>Would you mind explaining a bit more?</p>]]></content:encoded>
	</item>
	<item>
		<title>By: John Haugeland</title>
		<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/comment-page-1/#comment-170</link>
		<dc:creator>John Haugeland</dc:creator>
		<pubDate>Sat, 17 Apr 2010 18:10:48 +0000</pubDate>
		<guid isPermaLink="false">http://togaroga.com/blog/?p=425#comment-170</guid>
		<description>&lt;p&gt;Alternatively,&lt;/p&gt;

&lt;p&gt;&lt;code&gt;int Total = 0;  
for (int i=0; i&lt;100; ++i) { if (i%2==0) { Total += i; }}&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You&#039;re really just showing off the effects of a bad formatting style.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Alternatively,</p>

<p><code>int Total = 0;  
for (int i=0; i&lt;100; ++i) { if (i%2==0) { Total += i; }}</code></p>

<p>You&#8217;re really just showing off the effects of a bad formatting style.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: John Haugeland</title>
		<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/comment-page-1/#comment-169</link>
		<dc:creator>John Haugeland</dc:creator>
		<pubDate>Sat, 17 Apr 2010 18:09:41 +0000</pubDate>
		<guid isPermaLink="false">http://togaroga.com/blog/?p=425#comment-169</guid>
		<description>&lt;p&gt;Er.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;lists:sum( [ X &#124;&#124; X &lt;- lists:seq(1,100), x%2 == 0] )&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That&#039;s completely imperative code, sir.  Thanks for not confusing the effects of one particular language&#039;s syntax with those of a style of language.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Er.</p>

<p><code>lists:sum( [ X || X &amp;lt;- lists:seq(1,100), x%2 == 0] )</code></p>

<p>That&#8217;s completely imperative code, sir.  Thanks for not confusing the effects of one particular language&#8217;s syntax with those of a style of language.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ed The Dev .com &#187; Blog Archive &#187; Declarative programming</title>
		<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/comment-page-1/#comment-167</link>
		<dc:creator>Ed The Dev .com &#187; Blog Archive &#187; Declarative programming</dc:creator>
		<pubDate>Sat, 17 Apr 2010 04:42:41 +0000</pubDate>
		<guid isPermaLink="false">http://togaroga.com/blog/?p=425#comment-167</guid>
		<description>&lt;p&gt;[...] togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/   Posted in Random Geekiness by Edward Delaporte RSS 2.0 [...]&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>[...] togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/   Posted in Random Geekiness by Edward Delaporte RSS 2.0 [...]</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/comment-page-1/#comment-166</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Fri, 16 Apr 2010 23:24:08 +0000</pubDate>
		<guid isPermaLink="false">http://togaroga.com/blog/?p=425#comment-166</guid>
		<description>&lt;p&gt;@hobbit125 - Private methods that are singular in focus like I have used here are not only appropriate but actually desired in some cases.  I did consider using a named lambda expression to check for evenness but given the introductory nature of the article I decided against it.  I also don&#039;t think a comment explaining the evenness check makes a whole lot of sense given that this article is supposed to be an introduction on declarative code.   You could make a case that my &lt;code&gt;isEven&lt;/code&gt; method is unnecessary but I could just as easily make the case that you are missing the point of the article.&lt;/p&gt;

&lt;p&gt;I do appreciate your alternative method for checking a number for evenness.  From the way you phased your statement someone could get the impression that you consider your approach to be correct and my approach incorrect.  Given the fact that &lt;code&gt;i &amp; 1 == 0&lt;/code&gt; provides the same exact results as &lt;code&gt;i % 2 == 0&lt;/code&gt; and takes about the same amount of time to execute I thought it was important to point out that &lt;em&gt;both&lt;/em&gt; solutions are correct and can be used interchangeably.&lt;/p&gt;

&lt;p&gt;Finally, I am happy to report that I am in no way a superstitious person at all!  I simply prefer to use the actual names of the types as they are defined in their assemblies instead of their corresponding aliases.  Given the fact that the aliases are changed by the compiler into their respective type names I like to think that I am saving the compiler that trouble and therefore compiling my code at a faster rate than others who prefer to use aliases.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@hobbit125 &#8211; Private methods that are singular in focus like I have used here are not only appropriate but actually desired in some cases.  I did consider using a named lambda expression to check for evenness but given the introductory nature of the article I decided against it.  I also don&#8217;t think a comment explaining the evenness check makes a whole lot of sense given that this article is supposed to be an introduction on declarative code.   You could make a case that my <code>isEven</code> method is unnecessary but I could just as easily make the case that you are missing the point of the article.</p>

<p>I do appreciate your alternative method for checking a number for evenness.  From the way you phased your statement someone could get the impression that you consider your approach to be correct and my approach incorrect.  Given the fact that <code>i &amp; 1 == 0</code> provides the same exact results as <code>i % 2 == 0</code> and takes about the same amount of time to execute I thought it was important to point out that <em>both</em> solutions are correct and can be used interchangeably.</p>

<p>Finally, I am happy to report that I am in no way a superstitious person at all!  I simply prefer to use the actual names of the types as they are defined in their assemblies instead of their corresponding aliases.  Given the fact that the aliases are changed by the compiler into their respective type names I like to think that I am saving the compiler that trouble and therefore compiling my code at a faster rate than others who prefer to use aliases.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/comment-page-1/#comment-165</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Fri, 16 Apr 2010 22:45:02 +0000</pubDate>
		<guid isPermaLink="false">http://togaroga.com/blog/?p=425#comment-165</guid>
		<description>&lt;p&gt;@Dean Camera - Yes declarative code like this has the potential to have poorer performance but I believe that it is better to write the most readable code first.  If it becomes apparent (through the use of a profiler) that the code is creating a bottleneck in the application&#039;s performance only then would I consider changing it to an imperatively-styled solution.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@Dean Camera &#8211; Yes declarative code like this has the potential to have poorer performance but I believe that it is better to write the most readable code first.  If it becomes apparent (through the use of a profiler) that the code is creating a bottleneck in the application&#8217;s performance only then would I consider changing it to an imperatively-styled solution.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: hobbit125</title>
		<link>http://togaroga.com/2010/03/writing-better-code-its-imperative-that-you-are-declarative/comment-page-1/#comment-163</link>
		<dc:creator>hobbit125</dc:creator>
		<pubDate>Fri, 16 Apr 2010 03:35:06 +0000</pubDate>
		<guid isPermaLink="false">http://togaroga.com/blog/?p=425#comment-163</guid>
		<description>&lt;p&gt;Eww...polluting the class with a one-off method.  At least, use a named local lambda.  Better, don&#039;t bother.  Just inline it.  Most people are familiar with even check statements, and if it&#039;s that big of a deal, throw a comment at the end of the Where line.&lt;/p&gt;

&lt;p&gt;Also, this is how you check for evens:  (i &amp; 1) == 0.&lt;/p&gt;

&lt;p&gt;Also, do you have some superstitious reason for not liking keyword types?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Eww&#8230;polluting the class with a one-off method.  At least, use a named local lambda.  Better, don&#8217;t bother.  Just inline it.  Most people are familiar with even check statements, and if it&#8217;s that big of a deal, throw a comment at the end of the Where line.</p>

<p>Also, this is how you check for evens:  (i &amp; 1) == 0.</p>

<p>Also, do you have some superstitious reason for not liking keyword types?</p>]]></content:encoded>
	</item>
</channel>
</rss>

