<?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://ajaxian.com/archives/javascript-inheritance-performance/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/javascript-inheritance-performance</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: atwork8</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271634</link>
		<dc:creator>atwork8</dc:creator>
		<pubDate>Wed, 25 Feb 2009 18:22:57 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271634</guid>
		<description>@Covex - Thanks for pointing out the error with my code. I had a chance to look at it today and corrected the problem. It should now be working as expected. I&#039;ve posted it up using your test and it still appears to be the fastest at parent method calling:

http://www.projectcss.net/oop-test/2/

As I said above I&#039;ve been using this for a while with no problems, the reason being, I don&#039;t use parent method calling all that often lol Makes me wonder how useful it actually is? I mean, if parent methods aren&#039;t being called all the time, then it only takes a second to type an explicit call.

@WebReflection - I&#039;m not sure what you mean by &quot;unreasonably fast&quot;? In the context is that an oxymoron? lol

&quot;the trick over toString is not elegant and could fail with the first library that override toString function&quot;

My class implementation is totally modular, relying on standalone OO methods to do the work, so if somebody wanted a more thorough function for copying over methods they can feel free to swap out the one provided. I haven&#039;t run in to any problems with the current implementation and I&#039;ve been using it for a while. I like to keep things as complicated as necessary :o)

&quot;Maybe we could combine both solutions to find the fastest trick maintaining code elegance, can we?&quot;

Not sure if that was aimed at me, but feel free to drop me an email. My address is my username - @hotmail.co.uk

Thanks</description>
		<content:encoded><![CDATA[<p>@Covex &#8211; Thanks for pointing out the error with my code. I had a chance to look at it today and corrected the problem. It should now be working as expected. I&#8217;ve posted it up using your test and it still appears to be the fastest at parent method calling:</p>
<p><a href="http://www.projectcss.net/oop-test/2/" rel="nofollow">http://www.projectcss.net/oop-test/2/</a></p>
<p>As I said above I&#8217;ve been using this for a while with no problems, the reason being, I don&#8217;t use parent method calling all that often lol Makes me wonder how useful it actually is? I mean, if parent methods aren&#8217;t being called all the time, then it only takes a second to type an explicit call.</p>
<p>@WebReflection &#8211; I&#8217;m not sure what you mean by &#8220;unreasonably fast&#8221;? In the context is that an oxymoron? lol</p>
<p>&#8220;the trick over toString is not elegant and could fail with the first library that override toString function&#8221;</p>
<p>My class implementation is totally modular, relying on standalone OO methods to do the work, so if somebody wanted a more thorough function for copying over methods they can feel free to swap out the one provided. I haven&#8217;t run in to any problems with the current implementation and I&#8217;ve been using it for a while. I like to keep things as complicated as necessary :o)</p>
<p>&#8220;Maybe we could combine both solutions to find the fastest trick maintaining code elegance, can we?&#8221;</p>
<p>Not sure if that was aimed at me, but feel free to drop me an email. My address is my username &#8211; @hotmail.co.uk</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WebReflection</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271498</link>
		<dc:creator>WebReflection</dc:creator>
		<pubDate>Fri, 20 Feb 2009 11:22:45 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271498</guid>
		<description>@atwork8, your solution seems to be &quot;unreasonably fast&quot; with Internet Explorer but with new engines it is not that fast. At the same time the trick over toString is not elegant and could fail with the first library that override toString function in the Function.prototype, isn&#039;t it?
Maybe we could combine both solutions to find the fastest trick maintaining code elegance, can we?</description>
		<content:encoded><![CDATA[<p>@atwork8, your solution seems to be &#8220;unreasonably fast&#8221; with Internet Explorer but with new engines it is not that fast. At the same time the trick over toString is not elegant and could fail with the first library that override toString function in the Function.prototype, isn&#8217;t it?<br />
Maybe we could combine both solutions to find the fastest trick maintaining code elegance, can we?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WebReflection</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271497</link>
		<dc:creator>WebReflection</dc:creator>
		<pubDate>Fri, 20 Feb 2009 10:34:25 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271497</guid>
		<description>Covex, thanks to your test I realized I forgot the parent chain and I fixed it instantly :D
Why don&#039;t you try the last version and these classes?
&lt;i&gt;
var wr_Level0 = wr.extend(
    function(name, age){
        this.name = name;
        this.age = age;
    }, {
    foobar: function() {
        return &quot;fubar&quot;;
    }
});
var wr_Level1 = wr.extend(
    function(name, age){
        this.parent(name, age);
    }, wr_Level0, {
    foobar:function(){
        return this.parent();
    }
});
// up to level4
&lt;/i&gt;
In my test my method wins over every other in that scenario ;-)</description>
		<content:encoded><![CDATA[<p>Covex, thanks to your test I realized I forgot the parent chain and I fixed it instantly :D<br />
Why don&#8217;t you try the last version and these classes?<br />
<i><br />
var wr_Level0 = wr.extend(<br />
    function(name, age){<br />
        this.name = name;<br />
        this.age = age;<br />
    }, {<br />
    foobar: function() {<br />
        return &#8220;fubar&#8221;;<br />
    }<br />
});<br />
var wr_Level1 = wr.extend(<br />
    function(name, age){<br />
        this.parent(name, age);<br />
    }, wr_Level0, {<br />
    foobar:function(){<br />
        return this.parent();<br />
    }<br />
});<br />
// up to level4<br />
</i><br />
In my test my method wins over every other in that scenario ;-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Covex</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271496</link>
		<dc:creator>Covex</dc:creator>
		<pubDate>Fri, 20 Feb 2009 10:11:43 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271496</guid>
		<description>@WebReflection, your code does not work as expected =(

&lt;i&gt;function WR_Level0() { }
function WR_Level1() { this.parent(); }
wr.extend(WR_Level1, WR_Level0, { });
function WR_Level2() { this.parent(); }
wr.extend(WR_Level2, WR_Level1, { });
var Obj = new WR_Level2(); // too much recursion&lt;/i&gt;</description>
		<content:encoded><![CDATA[<p>@WebReflection, your code does not work as expected =(</p>
<p><i>function WR_Level0() { }<br />
function WR_Level1() { this.parent(); }<br />
wr.extend(WR_Level1, WR_Level0, { });<br />
function WR_Level2() { this.parent(); }<br />
wr.extend(WR_Level2, WR_Level1, { });<br />
var Obj = new WR_Level2(); // too much recursion</i></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Covex</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271489</link>
		<dc:creator>Covex</dc:creator>
		<pubDate>Thu, 19 Feb 2009 23:00:31 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271489</guid>
		<description>@atwork8: your code works incorrect.
If you will remove j3_Level2::foobar function, then j3_Level1::foobar function will be called twice (try this to check out: &lt;i&gt;var Obj = new j3_Level4(1, 2); Obj.foobar();&lt;/i&gt;)</description>
		<content:encoded><![CDATA[<p>@atwork8: your code works incorrect.<br />
If you will remove j3_Level2::foobar function, then j3_Level1::foobar function will be called twice (try this to check out: <i>var Obj = new j3_Level4(1, 2); Obj.foobar();</i>)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: atwork8</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271482</link>
		<dc:creator>atwork8</dc:creator>
		<pubDate>Thu, 19 Feb 2009 21:09:14 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271482</guid>
		<description>Hi broofa,

I liked your article, however, using John Resig&#039;s Class is a bit unfair. It doesn&#039;t do half the stuff that mootools and prototype do and it&#039;s broken/not complete. In IE it will break if you use a method name that mirrors those with the DontEnum attribute (mootools has the same error). Also it doesn&#039;t return the correct constructor. Both simple fixes, but I bet folk grab that code as it appears to be the fastest and then will run in to problems.

I&#039;ve uploaded another test similar to yours that also tests for the above problems, letting you know if they &quot;Passed&quot; or &quot;Failed&quot;. I&#039;ve also included in the tests my own Class implementation which I&#039;ve been using for a while now and it seems to perform the best, this is due to the way I do parent method calling.

http://www.projectcss.net/oop-test/</description>
		<content:encoded><![CDATA[<p>Hi broofa,</p>
<p>I liked your article, however, using John Resig&#8217;s Class is a bit unfair. It doesn&#8217;t do half the stuff that mootools and prototype do and it&#8217;s broken/not complete. In IE it will break if you use a method name that mirrors those with the DontEnum attribute (mootools has the same error). Also it doesn&#8217;t return the correct constructor. Both simple fixes, but I bet folk grab that code as it appears to be the fastest and then will run in to problems.</p>
<p>I&#8217;ve uploaded another test similar to yours that also tests for the above problems, letting you know if they &#8220;Passed&#8221; or &#8220;Failed&#8221;. I&#8217;ve also included in the tests my own Class implementation which I&#8217;ve been using for a while now and it seems to perform the best, this is due to the way I do parent method calling.</p>
<p><a href="http://www.projectcss.net/oop-test/" rel="nofollow">http://www.projectcss.net/oop-test/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: broofa</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271460</link>
		<dc:creator>broofa</dc:creator>
		<pubDate>Thu, 19 Feb 2009 12:39:58 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271460</guid>
		<description>@Covex: Ah, gotcha.  I didn&#039;t see a need to override the constructor functions in this set of tests.  You can extrapolate what that performance hit will be based on the performance of the calls to the subclass method.  The mechanics of overriding a constructor are no different from that of any other method.  This way, you can get a feel for what the overhead of the constructor process itself is, independent of the method override penalty.

Note, too, that object instantiation is typically a relatively infrequent operation compared to method invocation.  In most cases a performance hit of incurred when creating an object will be much less than the hit you take in subsequent method calls on the object.</description>
		<content:encoded><![CDATA[<p>@Covex: Ah, gotcha.  I didn&#8217;t see a need to override the constructor functions in this set of tests.  You can extrapolate what that performance hit will be based on the performance of the calls to the subclass method.  The mechanics of overriding a constructor are no different from that of any other method.  This way, you can get a feel for what the overhead of the constructor process itself is, independent of the method override penalty.</p>
<p>Note, too, that object instantiation is typically a relatively infrequent operation compared to method invocation.  In most cases a performance hit of incurred when creating an object will be much less than the hit you take in subsequent method calls on the object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Covex</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271445</link>
		<dc:creator>Covex</dc:creator>
		<pubDate>Wed, 18 Feb 2009 20:33:03 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271445</guid>
		<description>@ broofa: I meen, that all classes should contain initialization methods (&quot;init&quot; for John Resig’s solution, &quot;constructor&quot; for Base2 and &quot;initialize&quot; for Prototype.js). And there should be a call to initialization method of parent class from childClass&#039;s initsializator.</description>
		<content:encoded><![CDATA[<p>@ broofa: I meen, that all classes should contain initialization methods (&#8220;init&#8221; for John Resig’s solution, &#8220;constructor&#8221; for Base2 and &#8220;initialize&#8221; for Prototype.js). And there should be a call to initialization method of parent class from childClass&#8217;s initsializator.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: csuwldcat</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271441</link>
		<dc:creator>csuwldcat</dc:creator>
		<pubDate>Wed, 18 Feb 2009 19:26:54 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271441</guid>
		<description>@ robertlovecss

What are you referring to with the &quot;shouldn’t try to mimic classes&quot; line?

I use MooTools, and since I started writing code in the class format they offer that is typical in other languages, my code is waaay more portable, very DRY, reusable, extensible, and clean.  That is the biggest win I got from using the framework thus far.  Classes used in this way give you an edge in my opinion.</description>
		<content:encoded><![CDATA[<p>@ robertlovecss</p>
<p>What are you referring to with the &#8220;shouldn’t try to mimic classes&#8221; line?</p>
<p>I use MooTools, and since I started writing code in the class format they offer that is typical in other languages, my code is waaay more portable, very DRY, reusable, extensible, and clean.  That is the biggest win I got from using the framework thus far.  Classes used in this way give you an edge in my opinion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: robertlovescss</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271440</link>
		<dc:creator>robertlovescss</dc:creator>
		<pubDate>Wed, 18 Feb 2009 19:15:17 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271440</guid>
		<description>OO and class-based don&#039;t mean the same thing. javascript developer&#039;s shouldn&#039;t try to mimic classes. classes are a limitation that javascript doesn&#039;t have.</description>
		<content:encoded><![CDATA[<p>OO and class-based don&#8217;t mean the same thing. javascript developer&#8217;s shouldn&#8217;t try to mimic classes. classes are a limitation that javascript doesn&#8217;t have.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: broofa</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271438</link>
		<dc:creator>broofa</dc:creator>
		<pubDate>Wed, 18 Feb 2009 17:25:41 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271438</guid>
		<description>whups, results here: http://tinyurl.com/bmjwae</description>
		<content:encoded><![CDATA[<p>whups, results here: <a href="http://tinyurl.com/bmjwae" rel="nofollow">http://tinyurl.com/bmjwae</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: broofa</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271437</link>
		<dc:creator>broofa</dc:creator>
		<pubDate>Wed, 18 Feb 2009 17:25:18 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271437</guid>
		<description>@WebReflection: Can you please post the test you&#039;re using that shows inconsistent performance?  I put together a simple consistency test ( http://broofa.com/Tools/JSLitmus/tests/consistency.html ) and don&#039;t see any issues.  Here are my results: 

Note: I&#039;m not saying JSLitmus provides 100% accurate results, btw.  Results will be affected by the browser doing garbage collection, by other apps taking CPU time, and even by OSes that vary CPU speed in response to app demand (typically only seen on laptops.)  But I haven&#039;t seen the particular issue you&#039;re referring to.</description>
		<content:encoded><![CDATA[<p>@WebReflection: Can you please post the test you&#8217;re using that shows inconsistent performance?  I put together a simple consistency test ( <a href="http://broofa.com/Tools/JSLitmus/tests/consistency.html" rel="nofollow">http://broofa.com/Tools/JSLitmus/tests/consistency.html</a> ) and don&#8217;t see any issues.  Here are my results: </p>
<p>Note: I&#8217;m not saying JSLitmus provides 100% accurate results, btw.  Results will be affected by the browser doing garbage collection, by other apps taking CPU time, and even by OSes that vary CPU speed in response to app demand (typically only seen on laptops.)  But I haven&#8217;t seen the particular issue you&#8217;re referring to.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: broofa</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271434</link>
		<dc:creator>broofa</dc:creator>
		<pubDate>Wed, 18 Feb 2009 17:11:35 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271434</guid>
		<description>@Covex - Can you elaborate on why you think these benchmarks are invalid?   I&#039;m not sure what you mean when you say &quot;object constructors should also be overridden&quot;.</description>
		<content:encoded><![CDATA[<p>@Covex &#8211; Can you elaborate on why you think these benchmarks are invalid?   I&#8217;m not sure what you mean when you say &#8220;object constructors should also be overridden&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WebReflection</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271424</link>
		<dc:creator>WebReflection</dc:creator>
		<pubDate>Wed, 18 Feb 2009 13:20:18 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271424</guid>
		<description>There is something wrong with JSLitmus and last executed test which for some reason is always slower than others (I simply moved a couple of tests from top to end and vice-versa, results are systematically slower if placed at the bottom).</description>
		<content:encoded><![CDATA[<p>There is something wrong with JSLitmus and last executed test which for some reason is always slower than others (I simply moved a couple of tests from top to end and vice-versa, results are systematically slower if placed at the bottom).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Covex</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271423</link>
		<dc:creator>Covex</dc:creator>
		<pubDate>Wed, 18 Feb 2009 12:51:45 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271423</guid>
		<description>Benchmarks are not valid, because object constructors should also be overidden</description>
		<content:encoded><![CDATA[<p>Benchmarks are not valid, because object constructors should also be overidden</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ThomasHansen</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271422</link>
		<dc:creator>ThomasHansen</dc:creator>
		<pubDate>Wed, 18 Feb 2009 12:19:37 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271422</guid>
		<description>@sixtyseconds
Yes, definitely. The problem though isn&#039;t about selector engines versus OO speed and such. It runs much deeper unfortunately where it&#039;s a fact that 99% of all the energy spent on Ajax today is being spent on the wrong things. 15 years from now none of us will hardly remember the stuff that hits the main stream media today... :(
.
I guess we can pretty safely conclude with; &quot;so much for building pyramids&quot;...</description>
		<content:encoded><![CDATA[<p>@sixtyseconds<br />
Yes, definitely. The problem though isn&#8217;t about selector engines versus OO speed and such. It runs much deeper unfortunately where it&#8217;s a fact that 99% of all the energy spent on Ajax today is being spent on the wrong things. 15 years from now none of us will hardly remember the stuff that hits the main stream media today&#8230; :(<br />
.<br />
I guess we can pretty safely conclude with; &#8220;so much for building pyramids&#8221;&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sixtyseconds</title>
		<link>http://ajaxian.com/archives/javascript-inheritance-performance/comment-page-1#comment-271421</link>
		<dc:creator>sixtyseconds</dc:creator>
		<pubDate>Wed, 18 Feb 2009 11:52:19 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6007#comment-271421</guid>
		<description>Isn&#039;t it refreshing to see people taking an interest in something other then  selector engines (for speed boosts), for a change?</description>
		<content:encoded><![CDATA[<p>Isn&#8217;t it refreshing to see people taking an interest in something other then  selector engines (for speed boosts), for a change?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

