<?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: JavaScript Inheritance Performance</title>
	<atom:link href="http://www.broofa.com/2009/02/javascript-inheritance-performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/</link>
	<description>(Thoughtful musings, if you&#039;re lucky)</description>
	<lastBuildDate>Mon, 16 Jan 2012 19:17:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Rob</title>
		<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/comment-page-1/#comment-2845</link>
		<dc:creator>Rob</dc:creator>
		<pubDate>Wed, 17 Nov 2010 06:41:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.broofa.com/blog/?p=237#comment-2845</guid>
		<description>Inheritance is one method of code reuse in object-oriented languages, and Javascript has the power and flexibility to mimic classical inheritance quite effectively. But in trying to add classical inheritance to a language that doesn&#039;t have it we may be adding rigidity and complexity without gaining much benefit.

I would agree with Jonathan that parasitic inheritance is a powerful code reuse pattern in Javascript, although I think that calling it &quot;inheritance&quot; isn&#039;t very accurate.  Words like &quot;augmentation&quot; and &quot;composition&quot; fit much better.  I have heard the argument that parasitic inheritance is slow, but I have never seen any statistics that show meaningful differences between it and other techniques.  For me, I find it to be a clean, easy, powerful way of reusing code.

@Broofa The way to call a &quot;super&quot; method would look like this:

var foo = obj.foo;
obj.foo = function() {
    foo();
    this.onAfterFoo();
}

If you really wanted to you could use a library like Underscore and call the .wrap() method: http://documentcloud.github.com/underscore/#wrap

Overall I think this is a great post.  But I would argue that in most cases a parasitic, prototypal or functional approach is more powerful than trying to retrofit Javascript with classical inheritance.  Crockford has some good articles and talks on this, located here:

http://javascript.crockford.com/inheritance.html (notice the comment at the bottom of the page)
http://yuiblog.com/crockford/ (Act III is really good)</description>
		<content:encoded><![CDATA[<p>Inheritance is one method of code reuse in object-oriented languages, and Javascript has the power and flexibility to mimic classical inheritance quite effectively. But in trying to add classical inheritance to a language that doesn&#8217;t have it we may be adding rigidity and complexity without gaining much benefit.</p>
<p>I would agree with Jonathan that parasitic inheritance is a powerful code reuse pattern in Javascript, although I think that calling it &#8220;inheritance&#8221; isn&#8217;t very accurate.  Words like &#8220;augmentation&#8221; and &#8220;composition&#8221; fit much better.  I have heard the argument that parasitic inheritance is slow, but I have never seen any statistics that show meaningful differences between it and other techniques.  For me, I find it to be a clean, easy, powerful way of reusing code.</p>
<p>@Broofa The way to call a &#8220;super&#8221; method would look like this:</p>
<p>var foo = obj.foo;<br />
obj.foo = function() {<br />
    foo();<br />
    this.onAfterFoo();<br />
}</p>
<p>If you really wanted to you could use a library like Underscore and call the .wrap() method: <a href="http://documentcloud.github.com/underscore/#wrap" rel="nofollow">http://documentcloud.github.com/underscore/#wrap</a></p>
<p>Overall I think this is a great post.  But I would argue that in most cases a parasitic, prototypal or functional approach is more powerful than trying to retrofit Javascript with classical inheritance.  Crockford has some good articles and talks on this, located here:</p>
<p><a href="http://javascript.crockford.com/inheritance.html" rel="nofollow">http://javascript.crockford.com/inheritance.html</a> (notice the comment at the bottom of the page)<br />
<a href="http://yuiblog.com/crockford/" rel="nofollow">http://yuiblog.com/crockford/</a> (Act III is really good)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul Grenier</title>
		<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/comment-page-1/#comment-2801</link>
		<dc:creator>Paul Grenier</dc:creator>
		<pubDate>Thu, 23 Sep 2010 18:13:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.broofa.com/blog/?p=237#comment-2801</guid>
		<description>Thanks for the testing samples.  I was able to add my inheritance pattern to the list and got some interesting results (in the chart as App):

http://tinyurl.com/2fv9uqd

While instantiation was slower, the method calls were the fastest.  I expected the slower instantiation because I do a mixin to preserve the constructor in a subClass&#039;s prototype.  But being faster on method calls was a nice surprise.</description>
		<content:encoded><![CDATA[<p>Thanks for the testing samples.  I was able to add my inheritance pattern to the list and got some interesting results (in the chart as App):</p>
<p><a href="http://tinyurl.com/2fv9uqd" rel="nofollow">http://tinyurl.com/2fv9uqd</a></p>
<p>While instantiation was slower, the method calls were the fastest.  I expected the slower instantiation because I do a mixin to preserve the constructor in a subClass&#8217;s prototype.  But being faster on method calls was a nice surprise.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael .H</title>
		<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/comment-page-1/#comment-2086</link>
		<dc:creator>Michael .H</dc:creator>
		<pubDate>Sun, 13 Dec 2009 10:44:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.broofa.com/blog/?p=237#comment-2086</guid>
		<description>@Oleg On my IE8 and FF 3.5 (Windows based) it did not performed as better as Dojo and Base2</description>
		<content:encoded><![CDATA[<p>@Oleg On my IE8 and FF 3.5 (Windows based) it did not performed as better as Dojo and Base2</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oleg Slobodskoi</title>
		<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/comment-page-1/#comment-2072</link>
		<dc:creator>Oleg Slobodskoi</dc:creator>
		<pubDate>Fri, 11 Dec 2009 15:44:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.broofa.com/blog/?p=237#comment-2072</guid>
		<description>well, here are results on my mac and FF 3.5.5:
My implementaion:
http://tinyurl.com/yeer83v
Dojo:
http://tinyurl.com/y9sykqd
Base:
http://tinyurl.com/yb47245
J3Class2:
http://tinyurl.com/yaphcyw

It variates from time to time, but if I test some rounds I see appr. this results. 

@Michael .H you not?</description>
		<content:encoded><![CDATA[<p>well, here are results on my mac and FF 3.5.5:<br />
My implementaion:<br />
<a href="http://tinyurl.com/yeer83v" rel="nofollow">http://tinyurl.com/yeer83v</a><br />
Dojo:<br />
<a href="http://tinyurl.com/y9sykqd" rel="nofollow">http://tinyurl.com/y9sykqd</a><br />
Base:<br />
<a href="http://tinyurl.com/yb47245" rel="nofollow">http://tinyurl.com/yb47245</a><br />
J3Class2:<br />
<a href="http://tinyurl.com/yaphcyw" rel="nofollow">http://tinyurl.com/yaphcyw</a></p>
<p>It variates from time to time, but if I test some rounds I see appr. this results. </p>
<p>@Michael .H you not?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael .H</title>
		<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/comment-page-1/#comment-2070</link>
		<dc:creator>Michael .H</dc:creator>
		<pubDate>Fri, 11 Dec 2009 12:52:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.broofa.com/blog/?p=237#comment-2070</guid>
		<description>@Oleg Slobodskoi from your tests it results that is not faster than Base2 and Dojo. Whith what other implementations did you compared?</description>
		<content:encoded><![CDATA[<p>@Oleg Slobodskoi from your tests it results that is not faster than Base2 and Dojo. Whith what other implementations did you compared?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Oleg Slobodskoi</title>
		<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/comment-page-1/#comment-2025</link>
		<dc:creator>Oleg Slobodskoi</dc:creator>
		<pubDate>Sun, 15 Nov 2009 18:35:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.broofa.com/blog/?p=237#comment-2025</guid>
		<description>Hello guys.
I have also wrote one classical iheritance implementation :) There is a lot of them, I know, but I like my way more :)

The most important points of my implementation are:

1. User will work with constructor to create a class, not with object - private class variables and functions are possible.
2. I think at the moment when browser rendering any constructor it hasn&#039;t to initialize all the stuff the constructor contains
3. I can use more classical order pattern inside of the constructor. (first private variables, then privileged, then public methods and then private methods)
4. access overwritten methods via _super
5. Pass any variables to constructor, so they can be used everywere in the class, without to have to map over them, like if you do it over init method


Speedtest shows that my implementation is slower than j3Class or wr Class, but it still much faster than all other famous implementations.

Probably you have some Ideas how I can impove the performance without to change the usability?

http://dev.ajaxsoft.de/classtest/</description>
		<content:encoded><![CDATA[<p>Hello guys.<br />
I have also wrote one classical iheritance implementation <img src='http://www.broofa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  There is a lot of them, I know, but I like my way more <img src='http://www.broofa.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The most important points of my implementation are:</p>
<p>1. User will work with constructor to create a class, not with object &#8211; private class variables and functions are possible.<br />
2. I think at the moment when browser rendering any constructor it hasn&#8217;t to initialize all the stuff the constructor contains<br />
3. I can use more classical order pattern inside of the constructor. (first private variables, then privileged, then public methods and then private methods)<br />
4. access overwritten methods via _super<br />
5. Pass any variables to constructor, so they can be used everywere in the class, without to have to map over them, like if you do it over init method</p>
<p>Speedtest shows that my implementation is slower than j3Class or wr Class, but it still much faster than all other famous implementations.</p>
<p>Probably you have some Ideas how I can impove the performance without to change the usability?</p>
<p><a href="http://dev.ajaxsoft.de/classtest/" rel="nofollow">http://dev.ajaxsoft.de/classtest/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hokaoiwgrnvw</title>
		<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/comment-page-1/#comment-1878</link>
		<dc:creator>hokaoiwgrnvw</dc:creator>
		<pubDate>Tue, 06 Oct 2009 00:58:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.broofa.com/blog/?p=237#comment-1878</guid>
		<description>nmishbektjjs</description>
		<content:encoded><![CDATA[<p>nmishbektjjs</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan</title>
		<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/comment-page-1/#comment-1862</link>
		<dc:creator>Stefan</dc:creator>
		<pubDate>Wed, 30 Sep 2009 23:51:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.broofa.com/blog/?p=237#comment-1862</guid>
		<description>Just FYI, using tinyurls in an image src is not a good idea. Some people (like me) have a preference cookie from tinyurl.com, which will load the redirect page at preview.tinyurl.com instead of redirecting to the original URL. The redirect page is HTML, and so the images in your benchmark won&#039;t show up.</description>
		<content:encoded><![CDATA[<p>Just FYI, using tinyurls in an image src is not a good idea. Some people (like me) have a preference cookie from tinyurl.com, which will load the redirect page at preview.tinyurl.com instead of redirecting to the original URL. The redirect page is HTML, and so the images in your benchmark won&#8217;t show up.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clean JavaScript inheritance</title>
		<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/comment-page-1/#comment-1830</link>
		<dc:creator>Clean JavaScript inheritance</dc:creator>
		<pubDate>Wed, 26 Aug 2009 17:47:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.broofa.com/blog/?p=237#comment-1830</guid>
		<description>[...] I found a great article that compares inheritance performance of different libraries, here are results with directly called parent method approach ( using vClass [...]</description>
		<content:encoded><![CDATA[<p>[...] I found a great article that compares inheritance performance of different libraries, here are results with directly called parent method approach ( using vClass [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javascript Inheritance benchmarks, redux &#171; Warfangled</title>
		<link>http://www.broofa.com/2009/02/javascript-inheritance-performance/comment-page-1/#comment-1637</link>
		<dc:creator>Javascript Inheritance benchmarks, redux &#171; Warfangled</dc:creator>
		<pubDate>Fri, 27 Mar 2009 15:12:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.broofa.com/blog/?p=237#comment-1637</guid>
		<description>[...] The tests labeled Parasitic are using the JavaScript Inheritance method outlined in my previous post. The other labels are described originally at Broofa.com&#8217;s article on Javascript inheritance performance: [...]</description>
		<content:encoded><![CDATA[<p>[...] The tests labeled Parasitic are using the JavaScript Inheritance method outlined in my previous post. The other labels are described originally at Broofa.com&#8217;s article on Javascript inheritance performance: [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

