<?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"
	>
<channel>
	<title>Comments on: Wasting time on micro-optimizations</title>
	<atom:link href="http://outofcheese.org/2004/03/07/wasting-time-on-micro-optimizations/feed/" rel="self" type="application/rss+xml" />
	<link>http://outofcheese.org/2004/03/07/wasting-time-on-micro-optimizations/</link>
	<description>Redo from start....</description>
	<pubDate>Wed,  7 Jan 2009 10:16:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Anonymous &#38; Coward</title>
		<link>http://outofcheese.org/2004/03/07/wasting-time-on-micro-optimizations/#comment-394</link>
		<dc:creator>Anonymous &#38; Coward</dc:creator>
		<pubDate>Tue, 16 Mar 2004 11:59:47 +0000</pubDate>
		<guid isPermaLink="false">http://outofcheese.org/?p=581#comment-394</guid>
		<description>Even if the code was stated to have an undefined behavior, it's a stupid question. Nobody codes like that since 1970 and I agree it's like asking what value is in PC when you finish a blur filter on a tiff picture in Photoshop 3.0.1.

A wonderful article was published in an issue of Develop (from Bob3 Johnson : Killing the Time Killers IIRC) explaining why this sort of code is deeply stupid.

The FIXME thing is interesting as I'm using a similar method. The issue I see with this is that sometimes I don't remember what fix I needed to make :)</description>
		<content:encoded><![CDATA[<p>Even if the code was stated to have an undefined behavior, it&#8217;s a stupid question. Nobody codes like that since 1970 and I agree it&#8217;s like asking what value is in PC when you finish a blur filter on a tiff picture in Photoshop 3.0.1.</p>
<p>A wonderful article was published in an issue of Develop (from Bob3 Johnson : Killing the Time Killers IIRC) explaining why this sort of code is deeply stupid.</p>
<p>The FIXME thing is interesting as I&#8217;m using a similar method. The issue I see with this is that sometimes I don&#8217;t remember what fix I needed to make <img src='http://outofcheese.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Buggin' My Life Away</title>
		<link>http://outofcheese.org/2004/03/07/wasting-time-on-micro-optimizations/#comment-396</link>
		<dc:creator>Buggin' My Life Away</dc:creator>
		<pubDate>Mon, 15 Mar 2004 17:58:22 +0000</pubDate>
		<guid isPermaLink="false">http://outofcheese.org/?p=581#comment-396</guid>
		<description>&lt;strong&gt;Coding Tricks and Interviewing&lt;/strong&gt;

</description>
		<content:encoded><![CDATA[<p><strong>Coding Tricks and Interviewing</strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Buggin' My Life Away</title>
		<link>http://outofcheese.org/2004/03/07/wasting-time-on-micro-optimizations/#comment-395</link>
		<dc:creator>Buggin' My Life Away</dc:creator>
		<pubDate>Mon, 15 Mar 2004 17:57:30 +0000</pubDate>
		<guid isPermaLink="false">http://outofcheese.org/?p=581#comment-395</guid>
		<description>&lt;strong&gt;Coding Tricks and Interviewing&lt;/strong&gt;

</description>
		<content:encoded><![CDATA[<p><strong>Coding Tricks and Interviewing</strong></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric</title>
		<link>http://outofcheese.org/2004/03/07/wasting-time-on-micro-optimizations/#comment-393</link>
		<dc:creator>Eric</dc:creator>
		<pubDate>Mon, 15 Mar 2004 01:06:56 +0000</pubDate>
		<guid isPermaLink="false">http://outofcheese.org/?p=581#comment-393</guid>
		<description>It'd be a valid interview question if it was along the lines of "This is undefined behavior in C.  Why, and what does that mean?"  Simply giving them the line of code and asking what it does isn't fair, though.  I can't reasonably expect anyone to understand exactly what's undefined in every programming language.  It's like copying code from an obfuscated C contest and asking an interview candidate what it's doing.  They're not going to write code like that (well, hopefully not, and other questions will show that) and we shouldn't have anyone around who'd write code like that.  If they're never going to have to deal with anything like it, it doesn't really matter if they don't know exactly why it works (or doesn't work) in the way that it does.</description>
		<content:encoded><![CDATA[<p>It&#8217;d be a valid interview question if it was along the lines of &#8220;This is undefined behavior in C.  Why, and what does that mean?&#8221;  Simply giving them the line of code and asking what it does isn&#8217;t fair, though.  I can&#8217;t reasonably expect anyone to understand exactly what&#8217;s undefined in every programming language.  It&#8217;s like copying code from an obfuscated C contest and asking an interview candidate what it&#8217;s doing.  They&#8217;re not going to write code like that (well, hopefully not, and other questions will show that) and we shouldn&#8217;t have anyone around who&#8217;d write code like that.  If they&#8217;re never going to have to deal with anything like it, it doesn&#8217;t really matter if they don&#8217;t know exactly why it works (or doesn&#8217;t work) in the way that it does.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brooks Moses</title>
		<link>http://outofcheese.org/2004/03/07/wasting-time-on-micro-optimizations/#comment-392</link>
		<dc:creator>Brooks Moses</dc:creator>
		<pubDate>Sun, 14 Mar 2004 03:01:09 +0000</pubDate>
		<guid isPermaLink="false">http://outofcheese.org/?p=581#comment-392</guid>
		<description>Huh.  It seems like a perfectly valid interview question to me -- one of a sort that I'd be likely to ask, were I interviewing.  It seems a valuable filter for the people who have a proper understanding of the meaning of "operation undefined" (and an ability to recognize when it applies), which is a quality worth filtering for in people one's hiring to do programming.</description>
		<content:encoded><![CDATA[<p>Huh.  It seems like a perfectly valid interview question to me &#8212; one of a sort that I&#8217;d be likely to ask, were I interviewing.  It seems a valuable filter for the people who have a proper understanding of the meaning of &#8220;operation undefined&#8221; (and an ability to recognize when it applies), which is a quality worth filtering for in people one&#8217;s hiring to do programming.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexei Kosut</title>
		<link>http://outofcheese.org/2004/03/07/wasting-time-on-micro-optimizations/#comment-391</link>
		<dc:creator>Alexei Kosut</dc:creator>
		<pubDate>Tue, 09 Mar 2004 02:04:30 +0000</pubDate>
		<guid isPermaLink="false">http://outofcheese.org/?p=581#comment-391</guid>
		<description>Yep.  C++ is the one area where ++i vs. i++ matters, since if those operators are overloaded, the compiler can't substitute operator++() for operator++(int), even though that's probably what you meant.  With the STL, ++ is a common operator on objects, although most STL implementations try hard not to make an incidental iterator copy here and there cost too much.  And, of course, in most cases iterator copy cost is not something you need to waste your time optimizing.

I think it's a shame that the C++ language doesn't define some semantic requirements for overloaded operators that would allow the compiler to do these sorts of optimizations, but I guess that wouldn't exactly make C++ any simpler to understand.</description>
		<content:encoded><![CDATA[<p>Yep.  C++ is the one area where ++i vs. i++ matters, since if those operators are overloaded, the compiler can&#8217;t substitute operator++() for operator++(int), even though that&#8217;s probably what you meant.  With the STL, ++ is a common operator on objects, although most STL implementations try hard not to make an incidental iterator copy here and there cost too much.  And, of course, in most cases iterator copy cost is not something you need to waste your time optimizing.</p>
<p>I think it&#8217;s a shame that the C++ language doesn&#8217;t define some semantic requirements for overloaded operators that would allow the compiler to do these sorts of optimizations, but I guess that wouldn&#8217;t exactly make C++ any simpler to understand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: louis</title>
		<link>http://outofcheese.org/2004/03/07/wasting-time-on-micro-optimizations/#comment-390</link>
		<dc:creator>louis</dc:creator>
		<pubDate>Mon, 08 Mar 2004 01:27:45 +0000</pubDate>
		<guid isPermaLink="false">http://outofcheese.org/?p=581#comment-390</guid>
		<description>When I am writing code I often am trying to get the thing running at all, as opposed to totally correctly. So I end up sprinkling a ton of //FIXME's all over my code, which need to be taken care of before it can be committed, but are things I can hardcode or ignore while I am doing the initial bring up. While I am at it, I also tend to leave //PERF's next to anywhere I think that there is a win to be had but that I don't want to deal with because it is either more complex, or I want to see profiling data first. Its a quick hint, and it lets me express my first instincts on optimizations without actually impairing my code readability or complicating my initial debugging.

As for ++i... I need to disagree with you a little on this one. Not about the optimization thing, your right, people who believe the compiler can't transform a post-increment to a pre-increment when it needs to should not be doing that sort of optimization. The thing is that i++ is a more complicated semantic, copy, then increment original. ++I is simply an increment. In general if I have two interfaces that allow me to achieve the same result, but one may have an incidental side-effect that in a particular context I don't need then I use the simpler one, because it means that I am less likely to spend a bunch of time debugging some stupid bug in a copy constructor that I did not even need or want called. This is especially irritating because it is the sort of bug that may go away or come back when you change optimization levels. This is some ways only really an issue because people can overload operators with things that are not semantically compatible with their general arithmetic meaning. I suppose what I am saying is the fewer external functions you invoke the simpler things are to debug.

In any event, I find that the best thing to do generally is to follow the style of the code I am modifying, and to only changes things when there is heavy refactoring going on anyway, because adding something that is "stylistically better" just adds one more inconsistency to the code base.</description>
		<content:encoded><![CDATA[<p>When I am writing code I often am trying to get the thing running at all, as opposed to totally correctly. So I end up sprinkling a ton of //FIXME&#8217;s all over my code, which need to be taken care of before it can be committed, but are things I can hardcode or ignore while I am doing the initial bring up. While I am at it, I also tend to leave //PERF&#8217;s next to anywhere I think that there is a win to be had but that I don&#8217;t want to deal with because it is either more complex, or I want to see profiling data first. Its a quick hint, and it lets me express my first instincts on optimizations without actually impairing my code readability or complicating my initial debugging.</p>
<p>As for ++i&#8230; I need to disagree with you a little on this one. Not about the optimization thing, your right, people who believe the compiler can&#8217;t transform a post-increment to a pre-increment when it needs to should not be doing that sort of optimization. The thing is that i++ is a more complicated semantic, copy, then increment original. ++I is simply an increment. In general if I have two interfaces that allow me to achieve the same result, but one may have an incidental side-effect that in a particular context I don&#8217;t need then I use the simpler one, because it means that I am less likely to spend a bunch of time debugging some stupid bug in a copy constructor that I did not even need or want called. This is especially irritating because it is the sort of bug that may go away or come back when you change optimization levels. This is some ways only really an issue because people can overload operators with things that are not semantically compatible with their general arithmetic meaning. I suppose what I am saying is the fewer external functions you invoke the simpler things are to debug.</p>
<p>In any event, I find that the best thing to do generally is to follow the style of the code I am modifying, and to only changes things when there is heavy refactoring going on anyway, because adding something that is &#8220;stylistically better&#8221; just adds one more inconsistency to the code base.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
