<?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 for kuwamoto.org</title>
	<atom:link href="http://kuwamoto.org/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://kuwamoto.org</link>
	<description>music, technology, interfaces, people</description>
	<lastBuildDate>Mon, 19 Oct 2009 16:37:14 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on JavaScript performance optimization, take 1 by Amy</title>
		<link>http://kuwamoto.org/2009/10/09/javascript-performance-optimization-1/comment-page-1/#comment-295662</link>
		<dc:creator>Amy</dc:creator>
		<pubDate>Mon, 19 Oct 2009 16:37:14 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=249#comment-295662</guid>
		<description>Hey Sho. So true about the wrapper functions and CSS selectors (and maybe some day, with wider support of getElementsByClassName, it won&#039;t be).

Especially if you are doing a lot of super-interactive user interface, you might also want to be sure that not only do you not blow away/recreate the event handlers (as you describe above), but that you use capture and bubble effectively. Hopefully you&#039;re already doing that :)

One other idea: tuning your traversals is great, but don&#039;t underestimate the extra performance suck that extra elements can cause. The more extraneous elements you can strip out, the faster everything will be. Including CSS selectors.

You might try also looking thru the other items on this JavaScript performance checklist I put out today: http://slowjavascript.com/

Nota bene: I am the co-author of JavaScript Performance Rocks! (http://jsrocks.com/), a book specifically about this very topic. It&#039;s long and very thorough, you might find it helpful. :)</description>
		<content:encoded><![CDATA[<p>Hey Sho. So true about the wrapper functions and CSS selectors (and maybe some day, with wider support of getElementsByClassName, it won&#8217;t be).</p>
<p>Especially if you are doing a lot of super-interactive user interface, you might also want to be sure that not only do you not blow away/recreate the event handlers (as you describe above), but that you use capture and bubble effectively. Hopefully you&#8217;re already doing that :)</p>
<p>One other idea: tuning your traversals is great, but don&#8217;t underestimate the extra performance suck that extra elements can cause. The more extraneous elements you can strip out, the faster everything will be. Including CSS selectors.</p>
<p>You might try also looking thru the other items on this JavaScript performance checklist I put out today: <a href="http://slowjavascript.com/" rel="nofollow">http://slowjavascript.com/</a></p>
<p>Nota bene: I am the co-author of JavaScript Performance Rocks! (<a href="http://jsrocks.com/)" rel="nofollow">http://jsrocks.com/)</a>, a book specifically about this very topic. It&#8217;s long and very thorough, you might find it helpful. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript performance optimization, take 1 by keith</title>
		<link>http://kuwamoto.org/2009/10/09/javascript-performance-optimization-1/comment-page-1/#comment-295289</link>
		<dc:creator>keith</dc:creator>
		<pubDate>Tue, 13 Oct 2009 16:11:40 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=249#comment-295289</guid>
		<description>Thanks for the clarification sho!

It&#039;s funny: up until I read your article I&#039;ve managed to completely neglect the fact that how the browsers handle CSS selectors may be completely different from how the popular JavaScript libraries handle them. This means that I need to start thinking more about having two different ways of optimizing CSS selectors: one for CSS statements (which are read right-to-left), and another strategy for optimizing the convenience selectors provided by jQuery, etc. Well.. guess it&#039;s time to start digging around more in the jQuery code :)</description>
		<content:encoded><![CDATA[<p>Thanks for the clarification sho!</p>
<p>It&#8217;s funny: up until I read your article I&#8217;ve managed to completely neglect the fact that how the browsers handle CSS selectors may be completely different from how the popular JavaScript libraries handle them. This means that I need to start thinking more about having two different ways of optimizing CSS selectors: one for CSS statements (which are read right-to-left), and another strategy for optimizing the convenience selectors provided by jQuery, etc. Well.. guess it&#8217;s time to start digging around more in the jQuery code :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Improved pluralizing in PHP, ActionScript, and RoR by Rob Morris</title>
		<link>http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/comment-page-1/#comment-295223</link>
		<dc:creator>Rob Morris</dc:creator>
		<pubDate>Mon, 12 Oct 2009 18:56:31 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/#comment-295223</guid>
		<description>Perfect.  Thanks so much.  To anyone finding this post at this late date, you may be interested in a post I wrote that expands on this functionality to do intelligent conditional pluralization on phrases containing a number, eg:

&quot;Buy $num hot dog&quot; =&gt; &quot;Buy 1 hot dog&quot; / &quot;Buy 25 hot dogs&quot;

When integrated into Smarty or used to generate vars, can really clean up your code. 

Post is here: http://thecodingway.com/blog/robs-tips-and-tricks/php-pluralizing-with-style/</description>
		<content:encoded><![CDATA[<p>Perfect.  Thanks so much.  To anyone finding this post at this late date, you may be interested in a post I wrote that expands on this functionality to do intelligent conditional pluralization on phrases containing a number, eg:</p>
<p>&#8220;Buy $num hot dog&#8221; =&gt; &#8220;Buy 1 hot dog&#8221; / &#8220;Buy 25 hot dogs&#8221;</p>
<p>When integrated into Smarty or used to generate vars, can really clean up your code. </p>
<p>Post is here: <a href="http://thecodingway.com/blog/robs-tips-and-tricks/php-pluralizing-with-style/" rel="nofollow">http://thecodingway.com/blog/robs-tips-and-tricks/php-pluralizing-with-style/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript performance optimization, take 1 by sho</title>
		<link>http://kuwamoto.org/2009/10/09/javascript-performance-optimization-1/comment-page-1/#comment-295113</link>
		<dc:creator>sho</dc:creator>
		<pubDate>Sat, 10 Oct 2009 16:00:43 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=249#comment-295113</guid>
		<description>Thanks for that info, Jay. Good to know.</description>
		<content:encoded><![CDATA[<p>Thanks for that info, Jay. Good to know.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript performance optimization, take 1 by Jay Freeman (saurik)</title>
		<link>http://kuwamoto.org/2009/10/09/javascript-performance-optimization-1/comment-page-1/#comment-295100</link>
		<dc:creator>Jay Freeman (saurik)</dc:creator>
		<pubDate>Sat, 10 Oct 2009 12:11:30 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=249#comment-295100</guid>
		<description>In point of fact, Opera 9.5, Safari 3.1, Chrome, and Firefox 3 all provide native implementations of getElementsByClassName, as specified by HTML5. Hopefully your JS library is taking advantage of this, but given your performance figures I can only assume it isn&#039;t. It is incredibly unfortunate how much worse the state of browser performance is due to popular libraries refusing to take advantage of browser-specific features, no matter how commonly implemented. For the record, I believe JQuery finally changed their policy on this matter, which may be another reason to switch to it.</description>
		<content:encoded><![CDATA[<p>In point of fact, Opera 9.5, Safari 3.1, Chrome, and Firefox 3 all provide native implementations of getElementsByClassName, as specified by HTML5. Hopefully your JS library is taking advantage of this, but given your performance figures I can only assume it isn&#8217;t. It is incredibly unfortunate how much worse the state of browser performance is due to popular libraries refusing to take advantage of browser-specific features, no matter how commonly implemented. For the record, I believe JQuery finally changed their policy on this matter, which may be another reason to switch to it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript performance optimization, take 1 by sho</title>
		<link>http://kuwamoto.org/2009/10/09/javascript-performance-optimization-1/comment-page-1/#comment-295080</link>
		<dc:creator>sho</dc:creator>
		<pubDate>Sat, 10 Oct 2009 02:33:53 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=249#comment-295080</guid>
		<description>Ah. I forgot to mention why I tried that.

The selectors module in mootools (and I imagine jquery) splits apart the selector into multiple parts and performs the fastest actions first.

If the selector contains an id, the element is recovered using the low level DOM method getElementById(). 

If the selector contains a tag, the list of candidate elements is computed using the low level DOM method getElementsByTagName().

If neither a tag nor an id are provided, the entire subtree must be searched.

For classes and pseudo elements, there is no low-level DOM call to find these, so each element must be checked one by one using JavaScript.

Adding the class to the selector thus helps speed things up by narrowing the list of tags to search through via a quick DOM call.</description>
		<content:encoded><![CDATA[<p>Ah. I forgot to mention why I tried that.</p>
<p>The selectors module in mootools (and I imagine jquery) splits apart the selector into multiple parts and performs the fastest actions first.</p>
<p>If the selector contains an id, the element is recovered using the low level DOM method getElementById(). </p>
<p>If the selector contains a tag, the list of candidate elements is computed using the low level DOM method getElementsByTagName().</p>
<p>If neither a tag nor an id are provided, the entire subtree must be searched.</p>
<p>For classes and pseudo elements, there is no low-level DOM call to find these, so each element must be checked one by one using JavaScript.</p>
<p>Adding the class to the selector thus helps speed things up by narrowing the list of tags to search through via a quick DOM call.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JavaScript performance optimization, take 1 by keith</title>
		<link>http://kuwamoto.org/2009/10/09/javascript-performance-optimization-1/comment-page-1/#comment-295079</link>
		<dc:creator>keith</dc:creator>
		<pubDate>Sat, 10 Oct 2009 02:24:39 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/?p=249#comment-295079</guid>
		<description>Thanks for the tips :) I&#039;m a little suprised that selecting for div.class over .class would improve performance. I used to think that selectors worked left to right, and by being more specific, it would make it easier on the browser. There was an article by Steve Souders (http://www.stevesouders.com/blog/2009/06/18/simplifying-css-selectors/) not too long ago, however, which mentioned that selectors are matched from right to left though. Since that&#039;s the case, wouldn&#039;t it be quicker to just match .class instead of div.class?</description>
		<content:encoded><![CDATA[<p>Thanks for the tips :) I&#8217;m a little suprised that selecting for div.class over .class would improve performance. I used to think that selectors worked left to right, and by being more specific, it would make it easier on the browser. There was an article by Steve Souders (<a href="http://www.stevesouders.com/blog/2009/06/18/simplifying-css-selectors/" rel="nofollow">http://www.stevesouders.com/blog/2009/06/18/simplifying-css-selectors/</a>) not too long ago, however, which mentioned that selectors are matched from right to left though. Since that&#8217;s the case, wouldn&#8217;t it be quicker to just match .class instead of div.class?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Improved pluralizing in PHP, ActionScript, and RoR by Marlin</title>
		<link>http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/comment-page-1/#comment-295030</link>
		<dc:creator>Marlin</dc:creator>
		<pubDate>Fri, 09 Oct 2009 08:46:52 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/#comment-295030</guid>
		<description>Found a funny one:

complex =&gt; complices

Should be complexes, imo. :)</description>
		<content:encoded><![CDATA[<p>Found a funny one:</p>
<p>complex =&gt; complices</p>
<p>Should be complexes, imo. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Avoid ints in ActionScript by Sho</title>
		<link>http://kuwamoto.org/2006/06/15/avoid-ints-in-actionscript/comment-page-1/#comment-293586</link>
		<dc:creator>Sho</dc:creator>
		<pubDate>Thu, 17 Sep 2009 23:55:34 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/2006/06/15/avoid-ints-in-actionscript/#comment-293586</guid>
		<description>Hi Steven. Good point!

The issue is that in many languages (such as C++ or Java), (j+15)/7 *is* an integer operation when j is an int. So for those of us who come from those languages (and who see the strong typing in AS3 as a move toward those languages), this is confusing.

Even if you argue that having this be a floating point operation is &#039;better&#039; than having it be an integer operation, a modern compiler should be able to analyze the code to discover that the result of this operation is stored in an int and do an integer version of the division operation.

If I remember correctly, the player team investigated this approach, and found that it was difficult to get strictly correct behavior in edge cases (like dividing by NaN, etc). As a trade-off, they did an intrinsic conversion to Number in many cases that aren&#039;t strictly necessary.

They may have improved this in more recent version of the VM. I haven&#039;t worked at Adobe for 2 years, so I don&#039;t really know what&#039;s going on these days.</description>
		<content:encoded><![CDATA[<p>Hi Steven. Good point!</p>
<p>The issue is that in many languages (such as C++ or Java), (j+15)/7 *is* an integer operation when j is an int. So for those of us who come from those languages (and who see the strong typing in AS3 as a move toward those languages), this is confusing.</p>
<p>Even if you argue that having this be a floating point operation is &#8216;better&#8217; than having it be an integer operation, a modern compiler should be able to analyze the code to discover that the result of this operation is stored in an int and do an integer version of the division operation.</p>
<p>If I remember correctly, the player team investigated this approach, and found that it was difficult to get strictly correct behavior in edge cases (like dividing by NaN, etc). As a trade-off, they did an intrinsic conversion to Number in many cases that aren&#8217;t strictly necessary.</p>
<p>They may have improved this in more recent version of the VM. I haven&#8217;t worked at Adobe for 2 years, so I don&#8217;t really know what&#8217;s going on these days.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Avoid ints in ActionScript by Steven</title>
		<link>http://kuwamoto.org/2006/06/15/avoid-ints-in-actionscript/comment-page-1/#comment-293583</link>
		<dc:creator>Steven</dc:creator>
		<pubDate>Thu, 17 Sep 2009 23:36:18 +0000</pubDate>
		<guid isPermaLink="false">http://kuwamoto.org/2006/06/15/avoid-ints-in-actionscript/#comment-293583</guid>
		<description>Sho, 

Your blanket statement that Number is better than int is not fair at all.

Your loop is doing an int() cast every single iteration.  Of course this is going to be slow.  Note the difference if you don&#039;t divide by 7 and it doesn&#039;t have to do a conversion.

var now:int = getTimer();
var j:int;
var i:int = 10000000;
while (i--)
{
    j = (j + 15);
}
trace(getTimer() - now);

41ms

If you divide by 7

154ms

Obviously, doing floating point math using Number is faster than doing it with int.  But doing integer math with int is MUCH faster than doing it with Number.

If you&#039;re using floats, use Number. If you&#039;re using integers, use int.</description>
		<content:encoded><![CDATA[<p>Sho, </p>
<p>Your blanket statement that Number is better than int is not fair at all.</p>
<p>Your loop is doing an int() cast every single iteration.  Of course this is going to be slow.  Note the difference if you don&#8217;t divide by 7 and it doesn&#8217;t have to do a conversion.</p>
<p>var now:int = getTimer();<br />
var j:int;<br />
var i:int = 10000000;<br />
while (i&#8211;)<br />
{<br />
    j = (j + 15);<br />
}<br />
trace(getTimer() &#8211; now);</p>
<p>41ms</p>
<p>If you divide by 7</p>
<p>154ms</p>
<p>Obviously, doing floating point math using Number is faster than doing it with int.  But doing integer math with int is MUCH faster than doing it with Number.</p>
<p>If you&#8217;re using floats, use Number. If you&#8217;re using integers, use int.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
