{"id":73,"date":"2009-06-18T14:34:51","date_gmt":"2009-06-18T21:34:51","guid":{"rendered":"http:\/\/kai.mactane.org\/blog\/?p=73"},"modified":"2011-05-12T20:40:29","modified_gmt":"2011-05-13T03:40:29","slug":"would-shlemiel-the-painter-optimize-prematurely","status":"publish","type":"post","link":"https:\/\/kagan.mactane.org\/blog\/2009\/06\/18\/would-shlemiel-the-painter-optimize-prematurely\/","title":{"rendered":"Would Shlemiel the Painter Optimize Prematurely?"},"content":{"rendered":"<p>I don&#8217;t want to <a href=\"http:\/\/shreevatsa.wordpress.com\/2008\/05\/16\/premature-optimization-is-the-root-of-all-evil\/\">optimize this code prematurely<\/a>. And &#8220;while you&#8217;re still writing it&#8221; is probably premature. On the other hand, totally ignoring algorithmic complexity is a sure route to a <a href=\"http:\/\/www.joelonsoftware.com\/articles\/fog0000000319.html\">Shlemiel the Painter&#8217;s algorithm<\/a>.<\/p>\n<p>Do I really want to just write the whole thing, and then start profiling it to see where the hot spots are, and then possibly have to re-design the whole thing? That seems like the complete opposite of &#8220;work smarter, not harder&#8221;. Then again, it doesn&#8217;t matter if you write an <span class=\"mathVar\">O(<i>n<\/i><sup>2<\/sup>)<\/span> or even <span class=\"mathVar\">O(<i>n<\/i>!)<\/span> algorithm if <i>n<\/i> is always going to be small&#8230; and in this application, I expect low-to-middling <i>n<\/i> values.<\/p>\n<p>Of course, even if <i>n<\/i> will always be small, and increasing CPU power is my friend&#8230; even if it performs fast enough to make users happy, I&#8217;ll still know there&#8217;s a problem down there in the details. That may be the deciding factor.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I don&#8217;t want to optimize this code prematurely. And &#8220;while you&#8217;re still writing it&#8221; is probably premature. On the other hand, totally ignoring algorithmic complexity is a sure route to a Shlemiel the Painter&#8217;s algorithm. Do I really want to just write the whole thing, and then start profiling it to see where the hot [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[34,37,32,7,4,38],"_links":{"self":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/73"}],"collection":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":4,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":330,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/posts\/73\/revisions\/330"}],"wp:attachment":[{"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kagan.mactane.org\/blog\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}