Thread: JS fundamentals
View Single Post
Old 09-24-2012, 10:05 PM   PM User | #33
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,219
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Without quibibling over keywords, is there something else that "classes" do that javascript's constructors cannot?
First of all, don't believe everything you read on Wikipedia. Remember, it's all written by people who have their own axes to grind.

But are there things that classes in the most popular class-based languages (C++, Java, C#) do that a JavaScript constructor doesn't? Yes. Many things, Inheritance, polymorphism, static members, templates, and more. Can most of those things be simulated in JavaScript? Yes. But they aren't natural and native to JavaScript. There are some very very powerful constructs that are native to those three (and some other) languages that are difficult (if not well nigh impossible, c.f. templates, a.k.a. "generics") to do in JavaScript.

Please don't get me wrong. I'm not attacking JavaScript; I'm defending it. But I do recognize the very fundamental differences in a class-based language from the principles of prototypes, et al., that JavaScript is built on.

Use each language for its strengths. Don't try or expect any one language to be all things to all people for all uses.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote