OOPs!! When is a class not a class? (Re: Number/Specificality/Archetypes in Language)
From: | Ray Brown <ray.brown@...> |
Date: | Thursday, September 23, 2004, 18:45 |
(Yes, I'm replying to myself!)
On Wednesday, September 22, 2004, at 08:23 , Ray Brown wrote:
> On Tuesday, September 21, 2004, at 09:32 , Philippe Caquant wrote:
[snip]
>> Yes, looks like that; yet I was very pleased to
>> discover that in JavaScript, the properties of an
>> object belonging to a class can be in contradiction
>> with the general class properties (the prototype ones,
>> if I got it right). As I understood it, if you refer
>> to an object's property, Javascript will first look
>> for an explicit property at the very object level; if
>> it doesn't find it there, it will look for it at the
>> prototype level;
>
> Yes, yes - and classes may be sub-classes of others.
>
> JavaScript has merely taken these ideas over from Java & they've been
> around in object-oriented programming (OOP) for a few decades.
OOPs!! Someone has informed me that JavaScript does *not* have the formal
notion of class in the sense that the term is used in OOP and in the way
that C++ and Java does. I must confess that my object-oriented programming
has been a little in C++ and quite a lot in Delphi and Java. So far I've
done _very_ little in JavaScript, so when Philippe mentioned objects and
classes in JavaScript, I assumed that the terms were being used in the
traditional OOP manner. I should have known better: other than a
resemblance in syntax, JavaScript has nothing to do with Java. (Darned
scripting languages :)
In fact, I discover the way JavaScript deals with objects is quite
different the classic OOP languages. It seems books on JavaScript are in
the habit of using the term 'class' informally for, as I understand it, a
set of objects sharing similar properties & methods. But - {blushes deeply}
- if I had stopped to think about it, Javascript could not have formal
classes because it is such a weakly typed language. (Darned scripting
languages :)
OK - Philippe, if your only experience of using objects is JavaScript,
maybe we had better not continue using the class ~ object analogy
otherwise we are very likely to be talking at cross-purposes, which won't
help anybody.
> But do understand that my analogy to OOP was not intended to relate to the
> Platonic ideas. I was using a different analogy to show that there are
> different ways of looking at these things. Taking different points of view
> can of course be confusing but it can also stimulate further thought.
Yep - and the Clausal Form Logic model adopted by Prolog is yet another
way of looking at things :)
Ray
===============================================
http://home.freeuk.com/ray.brown
ray.brown@freeuk.com
===============================================
"They are evidently confusing science with technology."
UMBERTO ECO September, 2004
Replies