<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-5274051535398117366.post5626535186280373947..comments</id><updated>2011-05-13T11:11:21.067-07:00</updated><category term='Python'/><category term='node.js'/><category term='streamie'/><category term='UniversalComet'/><category term='packaging'/><category term='Performance'/><category term='Trackback'/><category term='Attribute Meta Classes'/><category term='Release'/><category term='Cookbook'/><category term='Augment'/><category term='Ext'/><category term='VisualWorks'/><category term='JSCloud'/><category term='Method Modifiers'/><category term='jsonpickle'/><category term='PureMVC'/><category term='Roles'/><category term='Types'/><category term='Testing'/><category term='Joose'/><category term='jsconf'/><category term='Rhino'/><category term='Presentation'/><category term='Documentation'/><category term='Traits'/><category term='HttpRequest'/><category term='JSON'/><category term='Google Gears'/><category term='joosify'/><category term='Offtopic'/><category term='WebWorkers'/><category term='CPAN'/><category term='Logo'/><category term='HTML5'/><category term='database'/><category term='Builder'/><category term='because-you-can'/><category term='speed'/><category term='promotejs'/><category term='jscomp'/><category term='jQuery'/><category term='google gadget api'/><category term='personal'/><category term='JScript .NET'/><category term='WebSocket'/><category term='Profiling'/><category term='OR-Mapper'/><category term='#bchh08'/><category term='NoFlash'/><category term='permanize'/><category term='Joosification'/><category term='widgets'/><category term='Google App Engine'/><category term='PMWA'/><category term='CouchDB'/><category term='Prototypes'/><category term='Omniture'/><category term='Type Coercions'/><category term='recipe'/><category term='Example'/><category term='blok'/><category term='HTML'/><category term='Joose.Storage'/><category term='Trivia'/><category term='bespin'/><category term='JavaScript'/><category term='Exceptions'/><category term='JooseX'/><category term='Old-Style-Interface'/><category term='Meta Classes'/><category term='Block'/><category term='svn'/><category term='Moose'/><title type='text'>Comments on NonBlocking.io - Malte Ubl's Asynchronous Identity Disorder: On Premature Optimization</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.nonblocking.io/feeds/5626535186280373947/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html'/><author><name>Malte Ubl</name><uri>https://profiles.google.com/116910304844117268718</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-tQJAx2-8rqE/AAAAAAAAAAI/AAAAAAAAEhc/T74iWhwXXf0/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>18</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-7750463513855448343</id><published>2011-03-07T11:35:02.145-08:00</published><updated>2011-03-07T11:35:02.145-08:00</updated><title type='text'>I am currently working on a Project that has grown...</title><content type='html'>I am currently working on a Project that has grown over 6 months without basic jQuery optimization, or as you like to call it &amp;quot;premature optimization&amp;quot;. This resulted in 4 jsFiles(each over 600 Lines long) where 85% of the lines started with a jQuery(&amp;quot;#&amp;quot; + something).&lt;br /&gt;This Project banned IE6, but not IE7, and after some more features, it just crashed on startup cause these scripts did so much lookups and where so unoptimized in every regard. It took hours to make those files a) easy readable(is this really the same selector?) b) easy maintainable( Try to change a selector based on 4 strings that where typed out at 90 different positions in a script vs change one variable) and have at least basic performance optimization.&lt;br /&gt;&lt;br /&gt;I would like see &amp;quot;performance awareness&amp;quot;. I agree that you should not use a negative while loop just because some perf test say its 0.5% faster then just a for. But i also think that basic maintainability is way way more important than some premature optimization.&lt;br /&gt;DRY &amp;gt; Premature Optimization * 1e10</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/7750463513855448343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/7750463513855448343'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1299526502145#c7750463513855448343' title=''/><author><name>Alexander</name><uri>http://www.blogger.com/profile/17878375885968184790</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-777091637'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-3508799551909359620</id><published>2011-03-07T08:36:53.005-08:00</published><updated>2011-03-07T08:36:53.005-08:00</updated><title type='text'>I wrote something similar a couple months ago: htt...</title><content type='html'>I wrote something similar a couple months ago: http://blog.millermedeiros.com/2010/10/the-performance-dogma/ - I agree that it is important to do some profiling and test on the production code, sometimes benchmarks and common knowledge can be misleading and sometimes bottlenecks are hard to spot. Cheers.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/3508799551909359620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/3508799551909359620'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1299515813005#c3508799551909359620' title=''/><author><name>Miller Medeiros</name><uri>http://www.blogger.com/profile/06373088149530789409</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1951904617'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-8934312234410400774</id><published>2011-02-20T04:58:48.834-08:00</published><updated>2011-02-20T04:58:48.834-08:00</updated><title type='text'>There&amp;#39;s also an issue of not seing the forest ...</title><content type='html'>There&amp;#39;s also an issue of not seing the forest for the trees - cluttering code with small optimisations makes it harder to make substantial (2x/10x) algorithmic improvements.&lt;br /&gt;&lt;br /&gt;My &amp;quot;favourite&amp;quot; example in the Java world is the horrendous logger.isDebugEnabled() check, which triples or quadruples line count for a debug statement, and therefore degrades code quality. In one project, developers were blindly applying to an admin system which would be used by 2 or 3 people max at any time.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/8934312234410400774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/8934312234410400774'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1298206728834#c8934312234410400774' title=''/><author><name>Michael Mahemoff</name><uri>http://softwareas.com</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1044252042'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-3676385700981344112</id><published>2011-02-20T02:52:34.100-08:00</published><updated>2011-02-20T02:52:34.100-08:00</updated><title type='text'>I made this little experiment, to see where the th...</title><content type='html'>I made this little experiment, to see where the threshold between fast and slow is:&lt;br /&gt;http://pastehtml.com/view/1dal064.html&lt;br /&gt;(the implementation is wrong. should probably not use setTimeout but rather a busy wait, but it is close enough).&lt;br /&gt;&lt;br /&gt;I agree with Michael. A mantra of &amp;quot;touching the DOM is evil&amp;quot; is not the right way. They are also the kind of problems that are easily benchmarked and optimized.&lt;br /&gt;&lt;br /&gt;In jQuery-land I have seen much worse. People often have super optimized code that is still slow. Why? Because it didn&amp;#39;t actually do anything on the current page. Everything started with a selector that didn&amp;#39;t match anything. A good dependency management system need like overhead (some people see all abstractions as overhead) but would have really sped things up.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/3676385700981344112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/3676385700981344112'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1298199154100#c3676385700981344112' title=''/><author><name>Malte</name><uri>http://www.blogger.com/profile/02896910385129311939</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-693778871'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-6879098824003042076</id><published>2011-02-19T19:27:33.183-08:00</published><updated>2011-02-19T19:27:33.183-08:00</updated><title type='text'>All the books say to use string builder over conca...</title><content type='html'>All the books say to use string builder over concatinization. I wanted to find out how important that really was. I built the code using concatinization. It ran in just under an hour. Put in string builder, it ran in 20 minutes. Then rewrote the code to only create the string when it was needed. Down to 7 minutes. Played around with other things, got it to 4 minutes. Got a new computer that was dual core and twice as fast. Original was running 100%, new computer ran in 2 minutes at 50%. Could change the code to multithread it, but agreed with you,it isn&amp;#39;t worth optimizing it.&lt;br /&gt;&lt;br /&gt;Using string builder makes the code slightly longer and in my opinion as easy to read. Taking out the redundancy did increase the complexity and therefore made it less maintainable.&lt;br /&gt;&lt;br /&gt;I agree that optimizing to improve the performance by 2 milliseconds just isn&amp;#39;t worth it.&lt;br /&gt;&lt;br /&gt;I had a case where I changed a 6 tenth of a second process to 2 milliseconds. That was on a daily maintenence process that wasn&amp;#39;t running daily because each time it ran, it took longer and longer to finish and the &amp;quot;daily&amp;quot; job was running over 48 hours.&lt;br /&gt;&lt;br /&gt;Anything in JavaScript should NOT be CPU intensive. I agree, use concatination there. Don&amp;#39;t optimize if you don&amp;#39;t have a good business reason to do so.&lt;br /&gt;&lt;br /&gt;(My business reason in the first case was just me, playing around with software. I did it to find out what impact it would have in a case where I knew there was a lot of string manipulation going on. I wanted to see what kind of impacts optimization could do for it.)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/6879098824003042076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/6879098824003042076'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1298172453183#c6879098824003042076' title=''/><author><name>Ken</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1654014367'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-2414021281581356486</id><published>2011-02-19T04:26:01.771-08:00</published><updated>2011-02-19T04:26:01.771-08:00</updated><title type='text'>Good article. Optimisation decisions are not compl...</title><content type='html'>Good article. Optimisation decisions are not completely black and white - as you note it&amp;#39;s a set of trade-offs.&lt;br /&gt;Experience also gives us a good idea of when the cost (in other regards) of an optimisation is probably very low, in which case it&amp;#39;s often better to write the optimised version first rather than a slow implementation to be revisited later.&lt;br /&gt;When I read about premature optimisation, the message can sometimes seem like &amp;quot;write the slowest code that comes to mind&amp;quot;; of course in reality we code a little more opportunistically.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/2414021281581356486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/2414021281581356486'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1298118361771#c2414021281581356486' title=''/><author><name>Oisín</name><uri>http://www.blogger.com/profile/14940197011612073631</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-15288563'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-7853460699033688448</id><published>2011-02-18T17:32:05.910-08:00</published><updated>2011-02-18T17:32:05.910-08:00</updated><title type='text'>To put it in perspective, a quick benchmark - look...</title><content type='html'>To put it in perspective, a quick benchmark - looking for a specific attribute on 1000 DOM elements takes ~3ms on Chrome on a 5-year old Macbook Pro.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m harping on my example, but I&amp;#39;m also making the broader point that what people sometimes consider &amp;quot;evil&amp;quot; is more of a sentimental frustration that it&amp;#39;s 100x slower than it could be (and therefore is sometimes called &amp;quot;being lazy&amp;quot;, a quality I strive for), rather than something that actually has the slightest impact on the only thing that really matters: user experience.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/7853460699033688448'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/7853460699033688448'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1298079125910#c7853460699033688448' title=''/><author><name>Michael Mahemoff</name><uri>http://softwareas.com</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1044252042'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-9143480384641656523</id><published>2011-02-17T08:32:52.782-08:00</published><updated>2011-02-17T08:32:52.782-08:00</updated><title type='text'>@mike: I&amp;#39;m not sure I follow. I wasn&amp;#39;t sug...</title><content type='html'>@mike: I&amp;#39;m not sure I follow. I wasn&amp;#39;t suggesting that string builders are faster than concatenation or the other way around. I was merely suggesting that normally mutable strings are more maintainable than immutable strings so that you should go with mutable strings when you don&amp;#39;t care about performance (because you haven&amp;#39;t measured that you have to care).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/9143480384641656523'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/9143480384641656523'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297960372782#c9143480384641656523' title=''/><author><name>Malte</name><uri>http://www.blogger.com/profile/02896910385129311939</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-693778871'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-681308151533540432</id><published>2011-02-17T07:38:53.613-08:00</published><updated>2011-02-17T07:38:53.613-08:00</updated><title type='text'>As to your comment on string builder vs concatinat...</title><content type='html'>As to your comment on string builder vs concatination concatenation is faster until string size is &amp;gt; 25 characters to bad you didn&amp;#39;t benchmark this one</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/681308151533540432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/681308151533540432'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297957133613#c681308151533540432' title=''/><author><name>mike</name><uri>http://www.blogger.com/profile/05955366831217723889</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-69117911'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-169396711868816189</id><published>2011-02-17T03:49:31.852-08:00</published><updated>2011-02-17T03:49:31.852-08:00</updated><title type='text'>Some related advice by Brendan Eich in &amp;quot;A min...</title><content type='html'>Some related advice by Brendan Eich in &amp;quot;A minute with...&amp;quot; http://www.aminutewithbrendan.com/pages/20110216</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/169396711868816189'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/169396711868816189'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297943371852#c169396711868816189' title=''/><author><name>Malte</name><uri>http://www.blogger.com/profile/02896910385129311939</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-693778871'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-4114716930381537108</id><published>2011-02-16T14:43:48.142-08:00</published><updated>2011-02-16T14:43:48.142-08:00</updated><title type='text'>For those who say to avoid DOM lookup at all cost ...</title><content type='html'>For those who say to avoid DOM lookup at all cost in my example, fine if the argument is readability/maintenability, but if it&amp;#39;s because of performance, then it&amp;#39;s an example of premature optimisation. An extreme one that may well be justified, but one that shows this isn&amp;#39;t black and white for anyone.&lt;br /&gt;&lt;br /&gt;Everyone&amp;#39;s unique - in my case, for every 100 lines of code I write, here&amp;#39;s my estimate of where it goes:&lt;br /&gt;&lt;br /&gt;* 75 lines will be refactored into something else&lt;br /&gt;* 10 lines will be ultimately posted a pastebin somewhere or uploaded in some obscure part of my homepage.  Few people will ever try it out or see it.&lt;br /&gt;* 10 lines will become a somewhat useful proof-of-concept or demo for people mainly using fast, modern, browsers, but never go beyond that.&lt;br /&gt;* 5 lines will make it into a useful library or web app. This is the only code where speed - such as an extra DOM lookup - *might* matter, and even then, it will probably be unnoticeable to most users.&lt;br /&gt;&lt;br /&gt;Of course, blatant estimate and maybe it seems weird to mix refactored-out code with &amp;quot;live&amp;quot; code, but my point is 5% of the code I write ends up being used anywhere. That&amp;#39;s why I&amp;#39;m heavily biased towards making it quick and simple, and getting it out there.&lt;br /&gt;&lt;br /&gt;To take the opposite of me, if someone was churning out code that has to run fast on IE6, and not experimenting much with new concepts, maybe 50% of their lines of code will become production code, and production code where speed matters a lot. So they might be more inclined to think about &amp;quot;performance in the small&amp;quot; (ie small idioms like this DOM lookup or Malte&amp;#39;s for-loop example).</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/4114716930381537108'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/4114716930381537108'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297896228142#c4114716930381537108' title=''/><author><name>Michael Mahemoff</name><uri>http://mahemoff.com</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-374689118'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-3958524469385040087</id><published>2011-02-16T13:10:15.101-08:00</published><updated>2011-02-16T13:10:15.101-08:00</updated><title type='text'>Nice article.

The bad thing is even knowing this ...</title><content type='html'>Nice article.&lt;br /&gt;&lt;br /&gt;The bad thing is even knowing this will not help to make right decisions. As you already said the perfect balance between performance and maintainability can be only reached throughout own experience. I don&amp;#39;t even believe this can be replaced by any smart books.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/3958524469385040087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/3958524469385040087'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297890615101#c3958524469385040087' title=''/><author><name>Oleg Slobodskoi</name><uri>http://www.blogger.com/profile/03816612363227915946</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-252394422'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-3581310874759224490</id><published>2011-02-16T12:46:07.728-08:00</published><updated>2011-02-16T12:46:07.728-08:00</updated><title type='text'>Related thoughts on what types of metrics we shoul...</title><content type='html'>Related thoughts on what types of metrics we should be looking for when evaluating web performance: http://marcuswest.in/read/four-performance-elements/</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/3581310874759224490'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/3581310874759224490'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297889167728#c3581310874759224490' title=''/><author><name>Marcus Westin</name><uri>http://www.blogger.com/profile/17464221112785078078</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1049751177'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-1513621104394139739</id><published>2011-02-16T12:43:22.735-08:00</published><updated>2011-02-16T12:43:22.735-08:00</updated><title type='text'>Re: Mahemoff — Definitely cache the $(&amp;#39;#x&amp;#39;...</title><content type='html'>Re: Mahemoff — Definitely cache the $(&amp;#39;#x&amp;#39;). The overhead can be huge (depending on the library we’re talking about) and it’s more readable/maintainable that way IMHO.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/1513621104394139739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/1513621104394139739'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297889002735#c1513621104394139739' title=''/><author><name>Mathias</name><uri>http://mathiasbynens.be/</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/openid16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-104655752'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-5791243547152566117</id><published>2011-02-16T12:41:47.123-08:00</published><updated>2011-02-16T12:41:47.123-08:00</updated><title type='text'>I would go on to even say that premature optimizat...</title><content type='html'>I would go on to even say that premature optimization (especially the kind without any concrete data) eventually leads to terrible performance in the long run.  When a project gets large and complex, all those unneeded micro &amp;quot;optimizations&amp;quot; make the code so hard to reason about that the overall architecture gets fundamentally flawed and ends up being slow, buggy, and unmaintainable all at the same time.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/5791243547152566117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/5791243547152566117'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297888907123#c5791243547152566117' title=''/><author><name>Tim Caswell</name><uri>http://www.blogger.com/profile/08183125394521795187</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1009643236'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-5414940963840911070</id><published>2011-02-16T12:06:27.871-08:00</published><updated>2011-02-16T12:06:27.871-08:00</updated><title type='text'>Always treat $ queries like you would treat dom qu...</title><content type='html'>Always treat $ queries like you would treat dom queries: hostile. That advice is library agnostic.&lt;br /&gt;&lt;br /&gt;Nice post Malte</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/5414940963840911070'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/5414940963840911070'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297886787871#c5414940963840911070' title=''/><author><name>Peter van der Zee</name><uri>http://qfox.nl</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-495405245'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-6131543817440307700</id><published>2011-02-16T11:59:29.505-08:00</published><updated>2011-02-16T11:59:29.505-08:00</updated><title type='text'>I would write the latter because it is clearer tha...</title><content type='html'>I would write the latter because it is clearer that $x is the same thing in both cases. If this is the intend the code is much more maintainable and DRY. So in this case the faster code is also better in at least one other dimension.&lt;br /&gt;&lt;br /&gt;Now it becomes a different matter if you cache $x in closure scope. Now the trade off becomes much less clear and it is much harder to say without data which one is the better alternative in several dimensions.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/6131543817440307700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/6131543817440307700'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297886369505#c6131543817440307700' title=''/><author><name>Malte</name><uri>http://www.blogger.com/profile/02896910385129311939</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-693778871'/></entry><entry><id>tag:blogger.com,1999:blog-5274051535398117366.post-3424137363438528306</id><published>2011-02-16T11:55:03.454-08:00</published><updated>2011-02-16T11:55:03.454-08:00</updated><title type='text'>Good point. I went to the school of YAGNI and favo...</title><content type='html'>Good point. I went to the school of YAGNI and favour agile code above performance when beginning a project.&lt;br /&gt;&lt;br /&gt;Just to make it interesting, would you:&lt;br /&gt;&lt;br /&gt;w = $(&amp;quot;#x&amp;quot;).width();&lt;br /&gt;h = $(&amp;quot;#x&amp;quot;).css(&amp;quot;height&amp;quot;);&lt;br /&gt;&lt;br /&gt;or would you pre-cache the DOM value:&lt;br /&gt;&lt;br /&gt;$x = $(&amp;quot;#x&amp;quot;);&lt;br /&gt;w = $x.width();&lt;br /&gt;h = $x.css(&amp;quot;height&amp;quot;);&lt;br /&gt;&lt;br /&gt;On the basis of keeping code concise, I prefer the former in the first instance, but I think many developers would beg to differ.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/3424137363438528306'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5274051535398117366/5626535186280373947/comments/default/3424137363438528306'/><link rel='alternate' type='text/html' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html?showComment=1297886103454#c3424137363438528306' title=''/><author><name>Michael Mahemoff</name><uri>http://mahemoff.com</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://www.nonblocking.io/2011/02/on-premature-optimization.html' ref='tag:blogger.com,1999:blog-5274051535398117366.post-5626535186280373947' source='http://www.blogger.com/feeds/5274051535398117366/posts/default/5626535186280373947' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-457633946'/></entry></feed>
