Re: OOPs!! When is a class not a class? (Re: Number/Specificality/Archetypes in Language)
From: | Keith Gaughan <kmgaughan@...> |
Date: | Saturday, September 25, 2004, 7:52 |
Ray Brown wrote:
> On Friday, September 24, 2004, at 08:29 , Philippe Caquant wrote:
>
>> --- Ray Brown <ray.brown@...> skrev:
>
> [snip]
>
>>> 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.
>>
>> As I understood from Flanagan's "JavaScript" (I'm
>> currently at page 344 of the French edition, and there
>> are 955 in all), JavaScript in not a real OOP, but it
>> more or less behaves like an OOP.
>
> Either your Flanagan ain't the David Flanagan who wrote "JavaScript: the
> Definitive Guide" or he's changed his mind or something has gone awry in
> the translation. In "JavaScript: the Definitive Guide" (page 137 of the
> Third edition) he writes:
> "The truth is that JavaScript is a true object-oriented language. It draws
> inspiration from a number of other (relatively obscure) object-oriented
> languages that use prototype-based inheritance instead of class-based
> inheritance."
Nudge to Philippe: take a look at those links I posted up earlier in the
thread. There're well worth the read. They explain prototype-based OO,
and closures, the mechanism that make OO possible in many
prototype-based languages.
>> As I don't know Java
>> neither C++, it's hard for me to explain it smartly.
>> What I know is that JS has no types
>
> Is this your first experience of an untyped language? You've a lot to
> learn :)
And worth it it is.
>> and confuses "+"
>> and "concatenate" (well, it doesn't really confuse
>> them, it only makes it very likely that you will have
>> problems with that some day),
>
> Eh?? But "+" is commonly used for concatenation. I've used it for years
> and so far have had no problems.
What happens in JavaScript is a weaker version of what happens in
Python. Python, as anybody who's used it (and it comes highly
recommended), is a dynamically typed language with strong typing. The
interpreter intuits what the variable type is at the time of first
assignment, and that variable *keeps* that type. So, you won't end up
having problems concatenating two strings that just happen to be made
up solely of digits.
JavaScript does something similar. That's why '+' doesn't screw up in
the language and why it doesn't need a seperate concatenation operator
like VBScript, PHP, Perl, and others.
>> So, when I'l be through with JavaScript, I'll learn
>> Java (probably at least 1500 pages ?) and C++, and a
>> dozen of other things, including DHTML, XTHML, XML,
>> XSL, PHP, MySQL, Perl, Unix, vi, Apache, Tomcat, etc,
Learn Python. It's a dream to use, and you won't regret it. And stick
with JavaScript: it's got a lot of good ideas.
K.
--
Keith Gaughan -- talideon.com
The man who removes a mountain begins
by carrying away small stones...
...to make place for some really big nukes!
Reply