<?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 Is Not &#8220;Truly&#8221; Object Oriented</title>
	<atom:link href="http://www.engfers.com/2008/08/29/javascript-is-not-truly-object-oriented/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.engfers.com/2008/08/29/javascript-is-not-truly-object-oriented/</link>
	<description>» scrumptious blog &#38; code » nothing more, nothing less</description>
	<lastBuildDate>Thu, 26 Jan 2012 18:45:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: esa</title>
		<link>http://www.engfers.com/2008/08/29/javascript-is-not-truly-object-oriented/comment-page-1/#comment-20633</link>
		<dc:creator>esa</dc:creator>
		<pubDate>Sun, 06 Nov 2011 14:11:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.engfers.com/?p=276#comment-20633</guid>
		<description>I wouldn&#039;t go as far as to say that Javascript&#039;s OO is better than that of C++, Java, etc. like Eric Hamilton did although I do prefer prototype-based OO better than class-based.

The actual thing here I think people should keep in mind is that not even the world of OO is pure black and white. Although the mainstream OO community thinks that their dogma of OO is the only true way and that all other kinds of OO are simply just plain heresy that is not the whole truth of OO. To me someone talking about &quot;true OO&quot; just sounds like a someone arguing about who is a &quot;true Christian&quot;.

According to OO experts (who see the big picture instead of just trying to market their own static and compiled class-based OO language) in the industry and academia it is simply not about what is &quot;true OO&quot; but about the fact that there is more than one way of doing OO which is why they don&#039;t spend their time arguing if something is &quot;truly OO&quot; but instead they talk about the family tree of different kinds of OO models.

There is more to OO than class-based OO. There is also prototype-based OO and probably some other less common models of OO as well. There is class-based inheritance, some languages uses delegation while others might just copy attibutes and methods around to achieve the same kind of behaviour on objects and then classify objects based on the kind of interfaces they can be inferred to support based on their available method names.

Is Python truly OO? It doesn&#039;t really enforce encapsulation. Still practically noone seems to have a problem calling it object-oriented. What is the point of having a dictionary if noone cares about what it says about what OO means? Then again Wikipedia is just wikipedia and hardly the final word on the subject.

Which is why saying that &quot;Javascript is not truly OO&quot; at least to me sounds rather problematic. Javascript is OO. Its just not class-based OO. To me speaking about OO thinking that it by default is and can only mean the class-based variant of OO just sounds plain sloppy. Sorry.

To me OO is more like a constantly moving and evolving target of various different modelling, design and coding techniques. Even aspect-oriented programming is usually implemented using OO techniques and used to augment OO as an extension of it. Which is why to me at least talk about what is &quot;truly OO&quot; just sounds like nitpicking. So to me OO is not a definition but more like a way of thinking, a philosophy or even a metaphilosophy. To me any language that allows me to think and to express myself with OO style is OO enough.</description>
		<content:encoded><![CDATA[<p>I wouldn&#8217;t go as far as to say that Javascript&#8217;s OO is better than that of C++, Java, etc. like Eric Hamilton did although I do prefer prototype-based OO better than class-based.</p>
<p>The actual thing here I think people should keep in mind is that not even the world of OO is pure black and white. Although the mainstream OO community thinks that their dogma of OO is the only true way and that all other kinds of OO are simply just plain heresy that is not the whole truth of OO. To me someone talking about &#8220;true OO&#8221; just sounds like a someone arguing about who is a &#8220;true Christian&#8221;.</p>
<p>According to OO experts (who see the big picture instead of just trying to market their own static and compiled class-based OO language) in the industry and academia it is simply not about what is &#8220;true OO&#8221; but about the fact that there is more than one way of doing OO which is why they don&#8217;t spend their time arguing if something is &#8220;truly OO&#8221; but instead they talk about the family tree of different kinds of OO models.</p>
<p>There is more to OO than class-based OO. There is also prototype-based OO and probably some other less common models of OO as well. There is class-based inheritance, some languages uses delegation while others might just copy attibutes and methods around to achieve the same kind of behaviour on objects and then classify objects based on the kind of interfaces they can be inferred to support based on their available method names.</p>
<p>Is Python truly OO? It doesn&#8217;t really enforce encapsulation. Still practically noone seems to have a problem calling it object-oriented. What is the point of having a dictionary if noone cares about what it says about what OO means? Then again Wikipedia is just wikipedia and hardly the final word on the subject.</p>
<p>Which is why saying that &#8220;Javascript is not truly OO&#8221; at least to me sounds rather problematic. Javascript is OO. Its just not class-based OO. To me speaking about OO thinking that it by default is and can only mean the class-based variant of OO just sounds plain sloppy. Sorry.</p>
<p>To me OO is more like a constantly moving and evolving target of various different modelling, design and coding techniques. Even aspect-oriented programming is usually implemented using OO techniques and used to augment OO as an extension of it. Which is why to me at least talk about what is &#8220;truly OO&#8221; just sounds like nitpicking. So to me OO is not a definition but more like a way of thinking, a philosophy or even a metaphilosophy. To me any language that allows me to think and to express myself with OO style is OO enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elina</title>
		<link>http://www.engfers.com/2008/08/29/javascript-is-not-truly-object-oriented/comment-page-1/#comment-18258</link>
		<dc:creator>Elina</dc:creator>
		<pubDate>Sat, 20 Aug 2011 03:31:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.engfers.com/?p=276#comment-18258</guid>
		<description>Hi, my comment will not be very useful, but I like the design of this blog!</description>
		<content:encoded><![CDATA[<p>Hi, my comment will not be very useful, but I like the design of this blog!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Inflatable Bed</title>
		<link>http://www.engfers.com/2008/08/29/javascript-is-not-truly-object-oriented/comment-page-1/#comment-12286</link>
		<dc:creator>Inflatable Bed</dc:creator>
		<pubDate>Fri, 28 Jan 2011 01:27:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.engfers.com/?p=276#comment-12286</guid>
		<description>.&#039;&#039; I am really thankful to this topic because it really gives great information -:-</description>
		<content:encoded><![CDATA[<p>.&#8221; I am really thankful to this topic because it really gives great information -:-</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric Hamilton</title>
		<link>http://www.engfers.com/2008/08/29/javascript-is-not-truly-object-oriented/comment-page-1/#comment-6916</link>
		<dc:creator>Eric Hamilton</dc:creator>
		<pubDate>Tue, 27 Jul 2010 21:37:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.engfers.com/?p=276#comment-6916</guid>
		<description>Javascript is very commonly misunderstood in this way. It actually does support encapsulation via enclasures. JQuery makes heavy use of enclosures - only exposing what is necessary to the global namespace, while the bulk of the internal workings are safely hidden away where no other scripts running on the same page can get at them. There&#039;s a good introduction to tutorials in this excerpt from &quot;Secrets of the Javascript Ninjas&quot; - http://mpathirage.com/files/javascript_ninja/JavaScriptNinja_ch3_Article2.pdf

Here&#039;s the language construct you need to familiarize yourself with to do encapsulation:

var myNamespace = (function(){ // assign the return value of an anonymous function to a var in the global space
function myNamespace(){
// Initialize
}
var hiddenStuff = &quot;my secret&quot;; // anything you define here will be hidden from the global scope.
return myNamespace;
})();

As for polymorphic inheritance, it is actually easy to inherit from an object, and override a parent method.

Parent = function() {
    // bunch of properties
}
Parent.someMethod = function () {
   // some behavior to override
}

var parentObj = new Parent();
var childObj = Object.create(parentObj);
childObj.someMethod = function () {
    // new behavior for child
}

Of course, you can also do all this within the child object&#039;s constructor, and then just do: 

var childObj = new ChildObj();

When you call childObj.someMethod(); you&#039;ll get the child version, not the parent&#039;s prototype version.

Javascript is certainly a different way of working, but once you wrap your brain around prototypical inheritance, you&#039;ll see that: 

1) Javascript can mimic class-based inheritance models, complete with encapsulation and polymorphic inheritance.

2) Prototypical inheritance is actually less verbose and more expressive than class-based inheritance, and...

3) Class-based inheritance cannot easily mimic prototypical inheritance.

In other words - Javascript has BETTER OO than C++ and Java.

If you want to criticize Javascript, there are plenty of valid attacks you can make - for example, Javascript lacks fast matrix manipulation capabilities, because it lacks support for predictable array element lengths (array elements with strong types). It also only supports one number type, (IEEE float), and that number type sucks for doing even basic floating point math.

Until these REAL problems are fixed, we&#039;re never going to see, for example, a high-performance 3D game engine written in Javascript running in the browser. (Although there are people doing 2 1/2 D game engines similar to the original Doom engine even with these limitations).</description>
		<content:encoded><![CDATA[<p>Javascript is very commonly misunderstood in this way. It actually does support encapsulation via enclasures. JQuery makes heavy use of enclosures &#8211; only exposing what is necessary to the global namespace, while the bulk of the internal workings are safely hidden away where no other scripts running on the same page can get at them. There&#8217;s a good introduction to tutorials in this excerpt from &#8220;Secrets of the Javascript Ninjas&#8221; &#8211; <a href="http://mpathirage.com/files/javascript_ninja/JavaScriptNinja_ch3_Article2.pdf" rel="nofollow">http://mpathirage.com/files/javascript_ninja/JavaScriptNinja_ch3_Article2.pdf</a></p>
<p>Here&#8217;s the language construct you need to familiarize yourself with to do encapsulation:</p>
<p>var myNamespace = (function(){ // assign the return value of an anonymous function to a var in the global space<br />
function myNamespace(){<br />
// Initialize<br />
}<br />
var hiddenStuff = &#8220;my secret&#8221;; // anything you define here will be hidden from the global scope.<br />
return myNamespace;<br />
})();</p>
<p>As for polymorphic inheritance, it is actually easy to inherit from an object, and override a parent method.</p>
<p>Parent = function() {<br />
    // bunch of properties<br />
}<br />
Parent.someMethod = function () {<br />
   // some behavior to override<br />
}</p>
<p>var parentObj = new Parent();<br />
var childObj = Object.create(parentObj);<br />
childObj.someMethod = function () {<br />
    // new behavior for child<br />
}</p>
<p>Of course, you can also do all this within the child object&#8217;s constructor, and then just do: </p>
<p>var childObj = new ChildObj();</p>
<p>When you call childObj.someMethod(); you&#8217;ll get the child version, not the parent&#8217;s prototype version.</p>
<p>Javascript is certainly a different way of working, but once you wrap your brain around prototypical inheritance, you&#8217;ll see that: </p>
<p>1) Javascript can mimic class-based inheritance models, complete with encapsulation and polymorphic inheritance.</p>
<p>2) Prototypical inheritance is actually less verbose and more expressive than class-based inheritance, and&#8230;</p>
<p>3) Class-based inheritance cannot easily mimic prototypical inheritance.</p>
<p>In other words &#8211; Javascript has BETTER OO than C++ and Java.</p>
<p>If you want to criticize Javascript, there are plenty of valid attacks you can make &#8211; for example, Javascript lacks fast matrix manipulation capabilities, because it lacks support for predictable array element lengths (array elements with strong types). It also only supports one number type, (IEEE float), and that number type sucks for doing even basic floating point math.</p>
<p>Until these REAL problems are fixed, we&#8217;re never going to see, for example, a high-performance 3D game engine written in Javascript running in the browser. (Although there are people doing 2 1/2 D game engines similar to the original Doom engine even with these limitations).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Alexander</title>
		<link>http://www.engfers.com/2008/08/29/javascript-is-not-truly-object-oriented/comment-page-1/#comment-4276</link>
		<dc:creator>Michael Alexander</dc:creator>
		<pubDate>Thu, 24 Sep 2009 23:38:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.engfers.com/?p=276#comment-4276</guid>
		<description>Dear Mr. Caligula

I find your position untenable. If we all attach our own meaning and definitions to words, what&#039;s the point of having a dictionary and how do we communicate efficiently and effectively with one another?

I&#039;m not familiar with Small Talk. Are you saying it doesn&#039;t support encapsulation and dynamic binding?

Re your last question, if it was sincere and not rhetorical, a scripting language is a language used to control another piece of software, in the case of JavaScript, the software is the browser.


Peace</description>
		<content:encoded><![CDATA[<p>Dear Mr. Caligula</p>
<p>I find your position untenable. If we all attach our own meaning and definitions to words, what&#8217;s the point of having a dictionary and how do we communicate efficiently and effectively with one another?</p>
<p>I&#8217;m not familiar with Small Talk. Are you saying it doesn&#8217;t support encapsulation and dynamic binding?</p>
<p>Re your last question, if it was sincere and not rhetorical, a scripting language is a language used to control another piece of software, in the case of JavaScript, the software is the browser.</p>
<p>Peace</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Caligula</title>
		<link>http://www.engfers.com/2008/08/29/javascript-is-not-truly-object-oriented/comment-page-1/#comment-500</link>
		<dc:creator>Caligula</dc:creator>
		<pubDate>Fri, 19 Sep 2008 12:02:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.engfers.com/?p=276#comment-500</guid>
		<description>&gt; I am tired of people writing stuff in/about JavaScript and calling it Object Oriented without explaining the difference between true object-oriented languages and scripting languages like JavaScript.

And I&#039;m tired of people believing that OO means only one thing.

Is Smalltalk OO? Of course it is--but most implementations have no concept of private variables, instead relying on convention. There&#039;s also instVarAt: and instVarAt:put: messages.

Is Self OO? Of course it is--it&#039;s also a prototypal-inheritance language.

(And what&#039;s a &quot;scripting language&quot;?)</description>
		<content:encoded><![CDATA[<p>&gt; I am tired of people writing stuff in/about JavaScript and calling it Object Oriented without explaining the difference between true object-oriented languages and scripting languages like JavaScript.</p>
<p>And I&#8217;m tired of people believing that OO means only one thing.</p>
<p>Is Smalltalk OO? Of course it is&#8211;but most implementations have no concept of private variables, instead relying on convention. There&#8217;s also instVarAt: and instVarAt:put: messages.</p>
<p>Is Self OO? Of course it is&#8211;it&#8217;s also a prototypal-inheritance language.</p>
<p>(And what&#8217;s a &#8220;scripting language&#8221;?)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: The Main Reason For JavaScript Unreadability at engfer(s)</title>
		<link>http://www.engfers.com/2008/08/29/javascript-is-not-truly-object-oriented/comment-page-1/#comment-444</link>
		<dc:creator>The Main Reason For JavaScript Unreadability at engfer(s)</dc:creator>
		<pubDate>Fri, 12 Sep 2008 13:33:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.engfers.com/?p=276#comment-444</guid>
		<description>[...] we said in another article &#8216;JavaScript Is Not &#8220;Truly&#8221; Object Oriented&#8216;, the difference between prototypal and object-based inheritance is the same difference [...]</description>
		<content:encoded><![CDATA[<p>[...] we said in another article &#8216;JavaScript Is Not &#8220;Truly&#8221; Object Oriented&#8216;, the difference between prototypal and object-based inheritance is the same difference [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

