<?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:series="http://unfoldingneurons.com/"
		>
<channel>
	<title>Comments on: The barbarism of the for loop</title>
	<atom:link href="http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/feed/" rel="self" type="application/rss+xml" />
	<link>http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/</link>
	<description>Polymath practicing programming, probably procrastinating</description>
	<lastBuildDate>Fri, 05 Mar 2010 07:52:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Keith Elder</title>
		<link>http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/comment-page-1/#comment-117</link>
		<dc:creator>Keith Elder</dc:creator>
		<pubDate>Thu, 17 Jan 2008 21:24:42 +0000</pubDate>
		<guid isPermaLink="false">http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/#comment-117</guid>
		<description>I don&#039;t think it is premature optimization if I know that I am dealing with a zero indexed array of data.  The fastest way to process through that data is a for loop.  Now with that said that doesn&#039;t mean I will use a for loop I may use a foreach because it is more convenient for me and I honestly could at that moment care less about speed.  

I write mainly in C# so I don&#039;t have a &quot;map&quot; function.  My point is it is still useful and to say it just shouldn&#039;t ever be considered or used because you have to *think* more to use it doesn&#039;t equate to throwing it out of the tool bag all together.

-Keith</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think it is premature optimization if I know that I am dealing with a zero indexed array of data.  The fastest way to process through that data is a for loop.  Now with that said that doesn&#8217;t mean I will use a for loop I may use a foreach because it is more convenient for me and I honestly could at that moment care less about&nbsp;speed.  </p>
<p>I write mainly in C# so I don&#8217;t have a &#8220;map&#8221; function.  My point is it is still useful and to say it just shouldn&#8217;t ever be considered or used because you have to <strong>think</strong> more to use it doesn&#8217;t equate to throwing it out of the tool bag all&nbsp;together.</p>
<p>-Keith</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Keys</title>
		<link>http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/comment-page-1/#comment-116</link>
		<dc:creator>Adam Keys</dc:creator>
		<pubDate>Thu, 17 Jan 2008 17:54:58 +0000</pubDate>
		<guid isPermaLink="false">http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/#comment-116</guid>
		<description>Keith, my feeling is that if you&#039;re using a for loop just to speed up your code, you&#039;re engaging in premature optimization. For loops often lead to fence post errors. Plus, its just more to think about. 

Something like @foreach@ at least gets you away from fence post errors. Using higher-order iterators like @map@ further reduce the amount of code you need to write in all sorts of common cases.</description>
		<content:encoded><![CDATA[<p>Keith, my feeling is that if you&#8217;re using a for loop just to speed up your code, you&#8217;re engaging in premature optimization. For loops often lead to fence post errors. Plus, its just more to think&nbsp;about. </p>
<p>Something like <code>foreach</code> at least gets you away from fence post errors. Using higher-order iterators like <code>map</code> further reduce the amount of code you need to write in all sorts of common&nbsp;cases.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Keith Elder</title>
		<link>http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/comment-page-1/#comment-111</link>
		<dc:creator>Keith Elder</dc:creator>
		<pubDate>Mon, 14 Jan 2008 19:06:11 +0000</pubDate>
		<guid isPermaLink="false">http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/#comment-111</guid>
		<description>Hi, found your blog through OBJO on Twitter.  He and I met at Codemash this past week.

For loops have their place in the programming paradigm. I have done a lot of benchmarks in languages over the years and when you need to loop through something the for loop is still faster than a while or a foreach or whatever other shortcut syntax you boil it down to.  

Just because it isn&#039;t pretty doesn&#039;t mean it shouldn&#039;t still be used.</description>
		<content:encoded><![CDATA[<p>Hi, found your blog through <span class="caps"><span class="caps">OBJO</span> </span>on Twitter.  He and I met at Codemash this past&nbsp;week.</p>
<p>For loops have their place in the programming paradigm. I have done a lot of benchmarks in languages over the years and when you need to loop through something the for loop is still faster than a while or a foreach or whatever other shortcut syntax you boil it down&nbsp;to.  </p>
<p>Just because it isn&#8217;t pretty doesn&#8217;t mean it shouldn&#8217;t still be&nbsp;used.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Keys</title>
		<link>http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/comment-page-1/#comment-110</link>
		<dc:creator>Adam Keys</dc:creator>
		<pubDate>Mon, 14 Jan 2008 18:51:28 +0000</pubDate>
		<guid isPermaLink="false">http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/#comment-110</guid>
		<description>I&#039;m also adding those who do insane graphics programming (3D stuff, etc.) Basically, if you are anyone&#039;s inner loop, then you are a beautiful flower who can use whatever ugly constructs you need in order to squeeze out cycles.

Everyone else still using a for loop is on notice.</description>
		<content:encoded><![CDATA[<p>I&#8217;m also adding those who do insane graphics programming (3D stuff, etc.) Basically, if you are anyone&#8217;s inner loop, then you are a beautiful flower who can use whatever ugly constructs you need in order to squeeze out&nbsp;cycles.</p>
<p>Everyone else still using a for loop is on&nbsp;notice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Keys</title>
		<link>http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/comment-page-1/#comment-109</link>
		<dc:creator>Adam Keys</dc:creator>
		<pubDate>Mon, 14 Jan 2008 18:02:44 +0000</pubDate>
		<guid isPermaLink="false">http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/#comment-109</guid>
		<description>The jury is still out for me on list comprehensions. That said, there is something distinctly cool about doing Pythagorean triplets in Erlang with them:

&lt;pre&gt;&lt;code&gt;
pyth(N) -&gt;
    [ {A,B,C} &#124;&#124;
        A &lt;- lists:seq(1,N),
        B &lt;- lists:seq(1,N),
        C &lt;- lists:seq(1,N),
        A+B+C =&lt; N,
        A*A+B*B == C*C 
    ].
&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>The jury is still out for me on list comprehensions. That said, there is something distinctly cool about doing Pythagorean triplets in Erlang with&nbsp;them:</p>
<pre><code>
pyth(N) -&gt;
    [ {A,B,C} ||
        A &lt;- lists:seq(1,N),
        B &lt;- lists:seq(1,N),
        C &lt;- lists:seq(1,N),
        A+B+C =&lt; N,
        A*A+B*B == C*C
    ].
</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil</title>
		<link>http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/comment-page-1/#comment-108</link>
		<dc:creator>Phil</dc:creator>
		<pubDate>Mon, 14 Jan 2008 17:51:01 +0000</pubDate>
		<guid isPermaLink="false">http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/#comment-108</guid>
		<description>One of these days someone is going to have to explain how list comprehensions are more than just a workaround for Python&#039;s extremely lame lambda support. How is that more expressive/powerful than map?</description>
		<content:encoded><![CDATA[<p>One of these days someone is going to have to explain how list comprehensions are more than just a workaround for Python&#8217;s extremely lame lambda support. How is that more expressive/powerful than&nbsp;map?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin smith</title>
		<link>http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/comment-page-1/#comment-100</link>
		<dc:creator>Kevin smith</dc:creator>
		<pubDate>Tue, 08 Jan 2008 15:18:45 +0000</pubDate>
		<guid isPermaLink="false">http://therealadam.com/archive/2008/01/06/the-barbarism-of-the-for-loop/#comment-100</guid>
		<description>There&#039;s also pure map:

do_something(Data) -&gt;
  F = fun(Item) -&gt; io:format(&quot;~p~n&quot;, [Item]) end,
  lists:map(F, Data).

And filter:

do_something(Data) -&gt;
  F = fun(Item) -&gt; Item &lt; 5 end,
  lists:filter(F, Data).

fold, foldr, and flatmap are also useful.</description>
		<content:encoded><![CDATA[<p>There&#8217;s also pure&nbsp;map:</p>
<p>do_something(Data) -&gt;<br />
  F = fun(Item) -&gt; io:format(&#8220;~p~n&#8221;, [Item]) end,<br />
  lists:map(F,&nbsp;Data).</p>
<p>And&nbsp;filter:</p>
<p>do_something(Data) -&gt;<br />
  F = fun(Item) -&gt; Item &lt; 5 end,<br />
  lists:filter(F,&nbsp;Data).</p>
<p>fold, foldr, and flatmap are also&nbsp;useful.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
