<?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: Premature Optimization Is the Root of All Evil</title>
	<atom:link href="http://www.johnramey.net/2009/05/28/premature-optimization-is-the-root-of-all-evil/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.johnramey.net/2009/05/28/premature-optimization-is-the-root-of-all-evil/</link>
	<description>Don&#039;t think...compute.</description>
	<lastBuildDate>Sun, 04 Apr 2010 23:29:20 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Ben</title>
		<link>http://www.johnramey.net/2009/05/28/premature-optimization-is-the-root-of-all-evil/comment-page-1/#comment-4544</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Wed, 17 Jun 2009 16:11:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.johnramey.net/?p=214#comment-4544</guid>
		<description>This whole argument assumes that you are writing inefficient code to begin with.  Stop writing inefficient code and this will cease to be an issue.

I don&#039;t know much about the structure and program flow of R but if it&#039;s like any other languages I&#039;ve worked with, one thing that might help is to re-evaluate your code re-use.  When you spend a decent amount of time optimizing a piece of code, examine what exactly that block of code does and pull the optimized code block out into a sub-function.  Create your own custom library of these optimized sub-functions, and over time you will end up with a collection of efficient subroutines that you will likely find yourself re-using or reading through (since it also serves as a catalog of optimization techniques).  This especially works well if you include the &quot;before&quot; code as a comment block before the optimized code.  Eventually, you will get to where you start thinking more like the code interpreter/compiler and you will write code that is more efficient the first time around. (one caveat: this can actually make things more difficult if you often code in several different languages).

Spending an hour optimizing a couple of lines of code isn&#039;t too terrible, assuming that the benefit of the optimization makes up that time later.  I have spent hours optimizing a 500-line function only to find that the code was only running when the system was idle (thus who cares about performance).  I have also spent a week optimizing one line of code that ended up cutting the run time of a simulation down from 20 hours to about 90 seconds.  It&#039;s all about how much benefit you will get from the changes (including future users of your code and future code that you will now know how to write more efficiently).</description>
		<content:encoded><![CDATA[<p>This whole argument assumes that you are writing inefficient code to begin with.  Stop writing inefficient code and this will cease to be an issue.</p>
<p>I don&#8217;t know much about the structure and program flow of R but if it&#8217;s like any other languages I&#8217;ve worked with, one thing that might help is to re-evaluate your code re-use.  When you spend a decent amount of time optimizing a piece of code, examine what exactly that block of code does and pull the optimized code block out into a sub-function.  Create your own custom library of these optimized sub-functions, and over time you will end up with a collection of efficient subroutines that you will likely find yourself re-using or reading through (since it also serves as a catalog of optimization techniques).  This especially works well if you include the &#8220;before&#8221; code as a comment block before the optimized code.  Eventually, you will get to where you start thinking more like the code interpreter/compiler and you will write code that is more efficient the first time around. (one caveat: this can actually make things more difficult if you often code in several different languages).</p>
<p>Spending an hour optimizing a couple of lines of code isn&#8217;t too terrible, assuming that the benefit of the optimization makes up that time later.  I have spent hours optimizing a 500-line function only to find that the code was only running when the system was idle (thus who cares about performance).  I have also spent a week optimizing one line of code that ended up cutting the run time of a simulation down from 20 hours to about 90 seconds.  It&#8217;s all about how much benefit you will get from the changes (including future users of your code and future code that you will now know how to write more efficiently).</p>
]]></content:encoded>
	</item>
</channel>
</rss>
