Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Newbie question about avoiding global variables

3 views
Skip to first unread message

hukash

unread,
Apr 8, 2010, 5:47:29 PM4/8/10
to
Hi everyone,

I lately started playing around with javascript (node.js) and got
stuck avoiding global variables. I hope someone can tell me what I'm
doing wrong.

Here's my script:
---
var sys = require('sys'),
fs = require('fs');

var FileReader = {

directory: null,
result: null,
tempDir:null,

start: function (directory) {
this.directory = directory;

this.tempDir = this.checkDirectory (this.directory);
this.result = this.readDirectory (this.directory);

sys.puts("Directory: " + this.tempDir); // output is undefined
sys.puts("Result: " + this.result); // output is undefined

},

checkDirectory: function(directory) {
fs.stat(directory, function (err, stats) {
if (err) throw err;

if (stats.isDirectory()) {
return directory;
} else {
return false;
}
});
},

readDirectory: function (directory) {
fs.readdir(directory, function (err, files) {
if (err) throw err;
return files;
});
},
};

FileReader.start("/Users");
---

this.tempDir and and this.directory are both undefined. So far I can
tell, the functions checkDirectory and readDirectory are working fine.
How do I assign the results of both functions correctly?

Thanks in advance,
Luke

Thomas 'PointedEars' Lahn

unread,
Apr 8, 2010, 6:49:18 PM4/8/10
to
hukash wrote:

> I lately started playing around with javascript (node.js) and got

There is no "javascript".

<http://jibbering.com/faq/>

> stuck avoiding global variables. I hope someone can tell me what I'm
> doing wrong.
>
> Here's my script:
> ---
> var sys = require('sys'),
> fs = require('fs');
>
> var FileReader = {
>
> directory: null,
> result: null,
> tempDir:null,
>
> start: function (directory) {
> this.directory = directory;
>
> this.tempDir = this.checkDirectory (this.directory);
> this.result = this.readDirectory (this.directory);
>
> sys.puts("Directory: " + this.tempDir); // output is undefined
> sys.puts("Result: " + this.result); // output is undefined
>
> },
>
> checkDirectory: function(directory) {
> fs.stat(directory, function (err, stats) {
> if (err) throw err;

The unescaped `throw' statement makes your code not backwards-compatible.



> if (stats.isDirectory()) {
> return directory;
> } else {
> return false;
> }
> });
> },
>
> readDirectory: function (directory) {
> fs.readdir(directory, function (err, files) {
> if (err) throw err;
> return files;
> });
> },
> };
>
> FileReader.start("/Users");
> ---
>
> this.tempDir and and this.directory are both undefined.

No, `this.tempDir' and `this.result' have the undefined value, which string
representation, "undefined", is probably put out by your host-defined or
user-defined method sys.puts() we can know nothing about.

> So far I can tell, the functions checkDirectory and readDirectory are
> working fine. How do I assign the results of both functions correctly?

You forgot to let FileReader.checkDirectory() and
FileReader.readDirectory() return something different from the `undefined'
value to their callers, so their return value is the `undefined' value.

The `return' statements you have are within the function that you pass to
fs.stat() and fs.readdir(), respectively. fs.stat() and fs.readdir() need
to return those return values, so that FileReader.checkDirectory() and
FileReader.readDirectory() can return them to their callers, respectively.

Some recommendations as to code style:

- You should not choose identifiers starting with a capital letter for
non-constructors or non-constants.

- You should remove the white-space between the /MemberExpression/ and the
/ArgumentList/ in the /CallExpression/; include it only when an operand
needs to be parenthesized, e.g. `typeof (foo = x.bar) != "undefined"',
to distinguish method calls from operations.

- Remove the trailing comma from the /ObjectLiteral/ as it is not
interoperable.


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)

Lasse Reichstein Nielsen

unread,
Apr 9, 2010, 1:12:06 AM4/9/10
to
hukash <huk...@googlemail.com> writes:

> I lately started playing around with javascript (node.js) and got
> stuck avoiding global variables. I hope someone can tell me what I'm
> doing wrong.

...


> this.tempDir = this.checkDirectory (this.directory);
> this.result = this.readDirectory (this.directory);
>
> sys.puts("Directory: " + this.tempDir); // output is undefined
> sys.puts("Result: " + this.result); // output is undefined

This means that this.checkDirectory and this.readDirectory returns undefined.

> checkDirectory: function(directory) {
> fs.stat(directory, function (err, stats) {
> if (err) throw err;
>
> if (stats.isDirectory()) {
> return directory;
> } else {
> return false;
> }
> });
> },

You don't return any value from this function.

I'm guessing this is the node.js fs module, and if so, the call to
stat is asynchroneous. You need to either properly chain the execution of
the asynchromeous operations. Something like:
checkDirectory: function(directory, continuation) {
fs.stat(directory, function (err,stats) {


if (err) throw err;
if (stats.isDirectory()) {

continuation(directory);
} else {
continuation(false);
}
});
},

and call it as:

var self = this;
this.checkDirectory(directory, function(tempDir) {
self.tempDir = tempDir;
self.readDirectory(directory, function(result) {
self.result = result;
// ... continue program.
})
});

Alternatively, you could use the synchroneous versions:

checkDirectory: function (directory) {
var stats = fs.statSync(directory);
return stats.isDirectory() ? directory : false;


},

>
> readDirectory: function (directory) {
> fs.readdir(directory, function (err, files) {

Ditto here.

/L
--
Lasse Reichstein Holst Nielsen
'Javascript frameworks is a disruptive technology'

Sean Kinsey

unread,
Apr 9, 2010, 3:24:56 AM4/9/10
to
On Apr 9, 12:49 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:

> hukash wrote:
> > checkDirectory: function(directory) {
> > fs.stat(directory, function (err, stats) {
> > if (err) throw err;
>
> The unescaped `throw' statement makes your code not backwards-compatible.

And why should one expect V8 (the VM running NodeJS) to suddenly
regress failing to support throw?

Antony Scriven

unread,
Apr 9, 2010, 5:00:47 AM4/9/10
to
On Apr 8, 11:49 pm, Thomas 'PointedEars' Lahn wrote:

> hukash wrote:
> > I lately started playing around with javascript
> > (node.js) and got
>
> There is no "javascript".
>
> <http://jibbering.com/faq/>

That's not helpful since 2.1 states `The term "javascript"
is used as a common name for all dialects of ECMAScript.'
And the OP specifies the implementation. --Antony

Thomas 'PointedEars' Lahn

unread,
Apr 9, 2010, 5:25:22 AM4/9/10
to
Antony Scriven wrote:

> Thomas 'PointedEars' Lahn wrote:
> > hukash wrote:
> > > I lately started playing around with javascript
> > > (node.js) and got
> >
> > There is no "javascript".
> >
> > <http://jibbering.com/faq/>
>
> That's not helpful since 2.1 states `The term "javascript"
> is used as a common name for all dialects of ECMAScript.'

That's a bug.

> And the OP specifies the implementation.

They don't.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300...@news.demon.co.uk>

Thomas 'PointedEars' Lahn

unread,
Apr 9, 2010, 5:26:09 AM4/9/10
to
Sean Kinsey wrote:

> Thomas 'PointedEars' Lahn wrote:
>> hukash wrote:
>> > checkDirectory: function(directory) {
>> > fs.stat(directory, function (err, stats) {
>> > if (err) throw err;
>>
>> The unescaped `throw' statement makes your code not backwards-compatible.
>
> And why should one expect V8 (the VM running NodeJS) to suddenly
> regress failing to support throw?

"node.js" can be *anything*.

Johannes Baagoe

unread,
Apr 9, 2010, 8:53:31 AM4/9/10
to
Thomas 'PointedEars' Lahn :

> Antony Scriven :

>> Thomas 'PointedEars' Lahn :

>>> There is no "javascript".
>>>
>>> <http://jibbering.com/faq/>

>> That's not helpful since 2.1 states `The term "javascript" is used as a
>> common name for all dialects of ECMAScript.'

I disagree. Plain "javascript" (not "JavaScript") is widely used that way,
cf. MIME types, and is readily understood. It seems to me that Brendan
Eich has a point when he says that "ECMAScript" sounds like a skin disease.

--
Johannes

Johannes Baagoe

unread,
Apr 9, 2010, 8:59:47 AM4/9/10
to
Thomas 'PointedEars' Lahn :

> Antony Scriven :

>> Thomas 'PointedEars' Lahn :

>>> There is no "javascript".
>>>
>>> <http://jibbering.com/faq/>

>> That's not helpful since 2.1 states `The term "javascript" is used as a
>> common name for all dialects of ECMAScript.'

> That's a bug.

I disagree. Plain "javascript" (not "JavaScript") is widely used that way,

Richard Cornford

unread,
Apr 9, 2010, 9:16:04 AM4/9/10
to
On Apr 9, 1:53 pm, Johannes Baagoe wrote:
> Thomas 'PointedEars' Lahn :
>> Antony Scriven :
>>> Thomas 'PointedEars' Lahn :
>>>> There is no "javascript".
>
>>>> <http://jibbering.com/faq/>
>>> That's not helpful since 2.1 states `The term "javascript" is
>>> used as a common name for all dialects of ECMAScript.'
>
> I disagree. Plain "javascript" (not "JavaScript") is widely used
> that way,

The statement in the FAQ would be true if there was only a single
example of "javascript" being used in that way. However, "javascript"
is widely used in that way.

> cf. MIME types, and is readily understood. It seems to me that
> Brendan Eich has a point when he says that "ECMAScript" sounds
> like a skin disease.

There is also always the matter of connecting with the people who
don't know any better; the ones who are just starting out and have no
idea of what ECMAScript is. While employing the well (and objectively)
defined terminology from the specification is valuable for making
precise statements about javascript the result of taking that to an
extreme (or insisting on their exclusive use) would leave everyone
involved talking their own esoteric language, and incomprehensible to
the uninitiated.

Richard.

Thomas 'PointedEars' Lahn

unread,
Apr 9, 2010, 9:35:25 AM4/9/10
to
Johannes Baagoe wrote:

> Thomas 'PointedEars' Lahn :
>> Antony Scriven :
>>> Thomas 'PointedEars' Lahn :
>>>> There is no "javascript".
>>>>
>>>> <http://jibbering.com/faq/>
>>> That's not helpful since 2.1 states `The term "javascript" is used as a
>>> common name for all dialects of ECMAScript.'
>> That's a bug.
>
> I disagree.

It is pure invention by those who don't know better or don't want to know
better.

> Plain "javascript" (not "JavaScript") is widely used that way,
> cf. MIME types, and is readily understood. It seems to me that Brendan
> Eich has a point when he says that "ECMAScript" sounds like a skin
> disease.

The point is that without telling about the runtime environment the term
"javascript" as a replacement term is pretty useless as statement made
about it can be both completely right and completely wrong, and source code
presented to be "javascript" code can be both syntactically correct and
incorrect, working and not working, concepts described with it correctly or
incorrectly, all depending on the runtime environment. Further, the term
promotes the common misconception that there would be only one language
with "dialects", where the diversity is clearly a lot greater than this.

Referring to Brendan Eich in this matter and manner is an argument at
authority -- obviously fallacious. Even Brendan Eich can be wrong, and the
fact that he thinks "ECMAScript" sounded like a skin disease (and I do not
subscribe to that opinion) bears no relevance on the (in)correctness and
(lacking) precision of the term "javascript".

Thomas 'PointedEars' Lahn

unread,
Apr 9, 2010, 10:03:18 AM4/9/10
to
Richard Cornford wrote:

> Johannes Baagoe wrote:
>> Thomas 'PointedEars' Lahn :
>>> Antony Scriven :
>>>> Thomas 'PointedEars' Lahn :
>>>>> There is no "javascript".
>>>>> <http://jibbering.com/faq/>
>>>> That's not helpful since 2.1 states `The term "javascript" is
>>>> used as a common name for all dialects of ECMAScript.'
>> I disagree. Plain "javascript" (not "JavaScript") is widely used
>> that way,
>
> The statement in the FAQ would be true if there was only a single
> example of "javascript" being used in that way. However, "javascript"
> is widely used in that way.

The main problem with it is a) that it is not generally used as a
replacement term for "ECMAScript implementation" (the term "dialects of
ECMAScript" is plain *wrong*), and b) that the lack of capital characters
is insufficient to make a considerable difference.

>> [...] It seems to me that Brendan Eich has a point when he says that


>> "ECMAScript" sounds like a skin disease.
>
> There is also always the matter of connecting with the people who
> don't know any better; the ones who are just starting out and have no
> idea of what ECMAScript is. While employing the well (and objectively)
> defined terminology from the specification is valuable for making
> precise statements about javascript the result of taking that to an
> extreme (or insisting on their exclusive use) would leave everyone
> involved talking their own esoteric language, and incomprehensible to
> the uninitiated.

On the other hand, not pointing out that they are (probably) using an
implementation of ECMAScript which depends on the environment the code
eventually runs in instead of a single language named "javascript" that
would work the same everywhere (which in common use of the term often
includes DOM implementations) leaves the people who don't know any better
in the dark (especially when miseducated by books) and causes all kinds of
misconceptions and misunderstandings in the process (like "$BROWSER is
broken" when it simply supports another implementation, or another DOM
implementation with its bound objects complying with the ECMAScript
Specification).


PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300...@news.demon.co.uk> (2004)

Sean Kinsey

unread,
Apr 9, 2010, 10:27:06 AM4/9/10
to
On Apr 9, 11:26 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:

> Sean Kinsey wrote:
> > Thomas 'PointedEars' Lahn wrote:
> >> hukash wrote:
> >> > checkDirectory: function(directory) {
> >> > fs.stat(directory, function (err, stats) {
> >> > if (err) throw err;
>
> >> The unescaped `throw' statement makes your code not backwards-compatible.
>
> > And why should one expect V8 (the VM running NodeJS) to suddenly
> > regress failing to support throw?
>
> "node.js" can be *anything*.

If you are unable to deduct that "javascript (node.js)" refers to
"javascript as in the one used in node.js, as in the _name_
"node.js" (http://nodejs.org), as in V8, as in ECMA-262, 3rd edition",
then you are thicker than I thought.


>
> PointedEars
> --
> Prototype.js was written by people who don't know javascript for people
> who don't know javascript. People who don't know javascript are not
> the best source of advice on designing systems that use javascript.

>   -- Richard Cornford, cljs, <f806at$ail$1$8300d...@news.demon.co.uk>

Johannes Baagoe

unread,
Apr 9, 2010, 10:31:01 AM4/9/10
to
Thomas 'PointedEars' Lahn :
> Johannes Baagoe :

>> Thomas 'PointedEars' Lahn :
>>> Antony Scriven :
>>>> Thomas 'PointedEars' Lahn :

>>>>> There is no "javascript".
>>>>> <http://jibbering.com/faq/>

>>>> That's not helpful since 2.1 states `The term "javascript" is
>>>> used as a common name for all dialects of ECMAScript.'

>>> That's a bug.

>> I disagree.

> It is pure invention by those who don't know better or don't want
> to know better.

Also by, among others, the authors of MIME types and by the founders
of this newsgroup - you are, of course, welcome to launch a Request
For Discussion to rename it. On the other hand, we just might agree
that pedantic nitpicking is harmful, unless where it is justified
by a precise point that actually makes a difference.

>> Plain "javascript" (not "JavaScript") is widely used that way,
>> cf. MIME types, and is readily understood. It seems to me that
>> Brendan Eich has a point when he says that "ECMAScript" sounds like
>> a skin disease.

> The point is that without telling about the runtime environment
> the term "javascript" as a replacement term is pretty useless as
> statement made about it can be both completely right and completely
> wrong, and source code presented to be "javascript" code can be
> both syntactically correct and incorrect, working and not working,
> concepts described with it correctly or incorrectly, all depending
> on the runtime environment.

That is true enough, and a request to the OP for clarification would
have been helpful. The flat statement "There is no "javascript""
is not.

> Further, the term promotes the common misconception that there would
> be only one language with "dialects", where the diversity is clearly
> a lot greater than this.

A language is a dialect with an army and a navy.

> Referring to Brendan Eich in this matter and manner is an argument
> at authority -- obviously fallacious. Even Brendan Eich can be wrong,
> and the fact that he thinks "ECMAScript" sounded like a skin disease
> (and I do not subscribe to that opinion)

You don't need to be Eich to see that there is an unfortunate closeness
to "eczema".

On the other hand, he *did* invent the language; it may be argued
that he is entitled to an opinion as to the proper name or names of
his brainchild.

> bears no relevance on the (in)correctness and (lacking) precision
> of the term "javascript".

Sometimes, a certain lack of precision is *precisely* what is intended,
and the inability to express it entails rather ridiculous efforts
like "(s)he". I use "ECMAScript" when there is a precise reference
to the ECMA specifications, "JavaScript", "JScript", etc, when some
vendor-specific version is intended, and plain "javascript" when the
point under discussion is more generic. Which, I am pleased to see,
is exactly what the FAQ suggests.

As for the correction, if one does not simply admit that usage is
the sole criterion and insist that some authority has to decide,
I would argue that Eich's opinion carries more weight than yours.

--
Johannes

Jorge

unread,
Apr 9, 2010, 10:33:17 AM4/9/10
to
On Apr 9, 4:03 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
> (...)

Except for the brain-damaged, ("JaVaScRiPt".toLowerCase() ==
"eCmAsCrIpT".toLowerCase()) yields a big true :-)
You should append a ™ when referring to mozilla's implementation:
JavaScript™.
--
Jorge.

Johannes Baagoe

unread,
Apr 9, 2010, 10:49:43 AM4/9/10
to
Johannes Baagoe :

> As for the correction,

Correction: s/ion/ness/. Pardon my French.

--
Johannes

Lasse Reichstein Nielsen

unread,
Apr 9, 2010, 11:02:50 AM4/9/10
to
Thomas 'PointedEars' Lahn <Point...@web.de> writes:

> Antony Scriven wrote:
>
>> That's not helpful since 2.1 states `The term "javascript"
>> is used as a common name for all dialects of ECMAScript.'
>
> That's a bug.

If the whole world disagrees with you ... it must be them who are wrong!

>> And the OP specifies the implementation.
>
> They don't.

He did. That you don't recognize it doesn't mean that it wasn't there.
The node.js environment counts as a specific javascript implementation
and environment, based on the V8 engine.

Jonathan Fine

unread,
Apr 9, 2010, 11:56:52 AM4/9/10
to
hukash wrote:
> Hi everyone,
>
> I lately started playing around with javascript (node.js) and got
> stuck avoiding global variables. I hope someone can tell me what I'm
> doing wrong.

Hello hukash. I hope you found help in the responses to this thread.

(I've glanced at it and found it mostly off-topic.)

--
Jonathan

Thomas 'PointedEars' Lahn

unread,
Apr 9, 2010, 12:00:10 PM4/9/10
to
Lasse Reichstein Nielsen wrote:

> Thomas 'PointedEars' Lahn writes:
>> Antony Scriven wrote:
>>> That's not helpful since 2.1 states `The term "javascript"
>>> is used as a common name for all dialects of ECMAScript.'
>> That's a bug.
>
> If the whole world disagrees with you ... it must be them who are wrong!

Argument at the silent majority.



>>> And the OP specifies the implementation.
>> They don't.
>
> He did. That you don't recognize it doesn't mean that it wasn't there.
> The node.js environment counts as a specific javascript implementation
> and environment, based on the V8 engine.

It is inference, not deduction, that lead you to believe that "node.js"
means that one library that only runs on that one script engine. AISB,
"node.js" can be anything.

Therefore, The OP's postings should have started like "I have tried the
following code using node.js in Google Chrome ...".


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann

Sean Kinsey

unread,
Apr 9, 2010, 12:05:33 PM4/9/10
to
On Apr 9, 6:00 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:

> Lasse Reichstein Nielsen wrote:
> > Thomas 'PointedEars' Lahn writes:
> >> Antony Scriven wrote:
> >>> That's not helpful since 2.1 states `The term "javascript"
> >>> is used as a common name for all dialects of ECMAScript.'
> >> That's a bug.
>
> > If the whole world disagrees with you ... it must be them who are wrong!
>
> Argument at the silent majority.
>
> >>> And the OP specifies the implementation.
> >> They don't.
>
> > He did. That you don't recognize it doesn't mean that it wasn't there.
> > The node.js environment counts as a specific javascript implementation
> > and environment, based on the V8 engine.
>
> It is inference, not deduction, that lead you to believe that "node.js"
> means that one library that only runs on that one script engine.  AISB,
> "node.js" can be anything.
>
> Therefore, The OP's postings should have started like "I have tried the
> following code using node.js in Google Chrome ...".

You are clearly not familiar with what node.js is, nor have you taken
the time to enlighten your self..

Jorge

unread,
Apr 9, 2010, 12:33:35 PM4/9/10
to
On Apr 9, 6:00 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>
> It is inference, not deduction, that lead you to believe that "node.js"
> means that one library that only runs on that one script engine.

It's not a library genius.
--
Jorge.

hukash

unread,
Apr 9, 2010, 2:27:48 PM4/9/10
to

Whoopsy, it wasn't my intention to start a debate on principles.
Whatever, I don't care why someone wouldn't call it javascript, since
the newsgroup is named comp.lang.JAVASCRIPT and not comp.lang.ECMA262.

Sorry for the misleading subject. I started to play around by using
global variables and everything seemed to work fine. Then I looked up
how to create objects and avoiding global vars and my script failed.

Or did you find it off-topic because I'm using node.js?

Thanks to Lasse, I used the given synchronous example and now it works
how I it was intended to. Maybe learning javascript with node.js is
not the best/easiest way ;-)

Thanks for the help.
Hukash

Hamish Campbell

unread,
Apr 9, 2010, 5:39:20 PM4/9/10
to
On Apr 10, 6:27 am, hukash <huk...@googlemail.com> wrote:
> .. the newsgroup is named comp.lang.JAVASCRIPT and not comp.lang.ECMA262.

And I'm sure it cuts PE up inside.

Sean Kinsey

unread,
Apr 9, 2010, 10:53:53 PM4/9/10
to

The direction the discussion took has little to do with the original
subject being off-topic or anything, its actually quite common here.

To me it seems that ECMA-262 is more like a compulsive disorder to
some people than a tool used to create value.
Just because you test all code in IE5 doesn't mean that you should (or
is in any position) to look down on those who don't. Some people
actually does cost/benefit analyses on what browsers to target you
know.. Starting every discussion with the notion that everyone else
are morons, know nothing, and that they cannot have though anything
through, is quite the character flaw if you ask me...

Garrett Smith

unread,
Apr 10, 2010, 2:56:59 AM4/10/10
to
Richard Cornford wrote:
> On Apr 9, 1:53 pm, Johannes Baagoe wrote:
>> Thomas 'PointedEars' Lahn :
>>> Antony Scriven :
>>>> Thomas 'PointedEars' Lahn :
>>>>> There is no "javascript".
>>>>> <http://jibbering.com/faq/>
>>>> That's not helpful since 2.1 states `The term "javascript" is
>>>> used as a common name for all dialects of ECMAScript.'
>> I disagree. Plain "javascript" (not "JavaScript") is widely used
>> that way,
>
> The statement in the FAQ would be true if there was only a single
> example of "javascript" being used in that way. However, "javascript"
> is widely used in that way.
>

Did anybody else read the meaning of that entry in that way?
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/

Thomas 'PointedEars' Lahn

unread,
Apr 10, 2010, 7:48:34 AM4/10/10
to
Garrett Smith wrote:

The entry is utter nonsense to begin with. There are no "dialects of
ECMAScript", there are (conforming) implementations of ECMAScript. And,
AISB, "javascript" in that context is a very unwise *invention*, not least
because it is used elsewhere by script-kiddies in a completely different
context. This group has seen what ambiguous terms like this lead to, and I
prefer not to see it again. It is the purpose of a FAQ to clarify, not to
make up terms so that they be used later.

SteveYoungTbird

unread,
Apr 10, 2010, 8:49:38 AM4/10/10
to

If you consider this FAQ entry to be "utter nonsense" why on earth did
you answer the OP, who informed us in the title of his post that he was
a "Newbie", with the comment "There is no "javascript"" and a link to
the FAQ?

Steve.

Thomas 'PointedEars' Lahn

unread,
Apr 10, 2010, 9:31:29 AM4/10/10
to
SteveYoungTbird wrote:

> If you consider this FAQ entry to be "utter nonsense" why on earth did
> you answer the OP, who informed us in the title of his post that he was
> a "Newbie", with the comment "There is no "javascript"" and a link to
> the FAQ?

Because of the rest of the text.

Learn to quote.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee

SteveYoungTbird

unread,
Apr 10, 2010, 10:07:05 AM4/10/10
to
Thomas 'PointedEars' Lahn wrote:
> SteveYoungTbird wrote:
>
>> If you consider this FAQ entry to be "utter nonsense" why on earth did
>> you answer the OP, who informed us in the title of his post that he was
>> a "Newbie", with the comment "There is no "javascript"" and a link to
>> the FAQ?
>
> Because of the rest of the text.

None of the rest of the text mentioned the name "javascript". Your
comment and link were specific to the part of the OP that mentioned
"javascript". The rest of the OP's question contained nothing that could
be answered by referring to the FAQ.

> Learn to quote.

Please tell me what is wrong with the way I have quoted.

Steve.

Thomas 'PointedEars' Lahn

unread,
Apr 10, 2010, 10:59:51 AM4/10/10
to
SteveYoungTbird wrote:

> Thomas 'PointedEars' Lahn wrote:
>> SteveYoungTbird wrote:
>>> If you consider this FAQ entry to be "utter nonsense" why on earth did
>>> you answer the OP, who informed us in the title of his post that he was
>>> a "Newbie", with the comment "There is no "javascript"" and a link to
>>> the FAQ?
>>
>> Because of the rest of the text.
>
> None of the rest of the text mentioned the name "javascript".

That's the point.

>> Learn to quote.
>
> Please tell me what is wrong with the way I have quoted.

Signatures, delimited or not, are not to be quoted unless being referred to.

John G Harris

unread,
Apr 10, 2010, 12:36:10 PM4/10/10
to
On Fri, 9 Apr 2010 at 15:35:25, in comp.lang.javascript, Thomas
'PointedEars' Lahn wrote:

<snip>


>The point is that without telling about the runtime environment the term
>"javascript" as a replacement term is pretty useless as statement made
>about it can be both completely right and completely wrong, and source code
>presented to be "javascript" code can be both syntactically correct and
>incorrect, working and not working, concepts described with it correctly or
>incorrectly, all depending on the runtime environment. Further, the term
>promotes the common misconception that there would be only one language
>with "dialects", where the diversity is clearly a lot greater than this.

<snip>

There are no cars.

There are only VWs, and Peugeots, and FIATs, and Jaguars, and Fords, and
Toyotas, and Kias, and ...

To illustrate this, I have seen an advert on a web page offering a
"Toyota Land Cruiser Jeep" for sale.

If someone says "I'm learning to drive a car" they are being hopelessly
imprecise and no-one will be able to give them sensible advice.

John
--
John Harris

Lasse Reichstein Nielsen

unread,
Apr 10, 2010, 1:35:45 PM4/10/10
to
John G Harris <jo...@nospam.demon.co.uk> writes:

> There are no cars.

...
This must be a first! A car anaolgy that fits!

preet

unread,
Apr 10, 2010, 3:42:00 PM4/10/10
to
will the read directory code ever get blocked on nortan antivirus ?

i had tons of problems with the file scripts already.

any inputs will be appreciated


--------------------------
<a href=http://www.eecpindia.com/>eecp</a>


*** Sent via Developersdex http://www.developersdex.com ***

Thomas 'PointedEars' Lahn

unread,
Apr 10, 2010, 5:02:40 PM4/10/10
to
John G Harris wrote:

> Thomas 'PointedEars' Lahn wrote:
>> The point is that without telling about the runtime environment the term
>> "javascript" as a replacement term is pretty useless as statement made
>> about it can be both completely right and completely wrong, and source
>> code presented to be "javascript" code can be both syntactically correct
>> and incorrect, working and not working, concepts described with it
>> correctly or incorrectly, all depending on the runtime environment.
>> Further, the term promotes the common misconception that there would be
>> only one language with "dialects", where the diversity is clearly a lot
>> greater than this.
>

> There are no cars.
>
> There are only VWs, and Peugeots, and FIATs, and Jaguars, and Fords, and
> Toyotas, and Kias, and ...

Your analogy is flawed for reasons already given. You would be well-advised
to read the whole thread carefully before you try a counter-argument.

John G Harris

unread,
Apr 11, 2010, 2:51:00 PM4/11/10
to
On Sat, 10 Apr 2010 at 23:02:40, in comp.lang.javascript, Thomas
'PointedEars' Lahn wrote:
>John G Harris wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> The point is that without telling about the runtime environment the term
>>> "javascript" as a replacement term is pretty useless as statement made
>>> about it can be both completely right and completely wrong, and source
>>> code presented to be "javascript" code can be both syntactically correct
>>> and incorrect, working and not working, concepts described with it
>>> correctly or incorrectly, all depending on the runtime environment.
>>> Further, the term promotes the common misconception that there would be
>>> only one language with "dialects", where the diversity is clearly a lot
>>> greater than this.
>>
>> There are no cars.
>>
>> There are only VWs, and Peugeots, and FIATs, and Jaguars, and Fords, and
>> Toyotas, and Kias, and ...
>
>Your analogy

It's not an analogy : see a dictionary. It's the same foolish reasoning
applied to a different class of classes of objects.


>is flawed

It's foolish, but not flawed.


> for reasons already given.

1 You say 'javascript' is fuzzy, but so is 'cars'.

2 You say the word has been misused, but no-one can say 'cars' has never
been misused. And anyway, so what?


> You would be well-advised
>to read the whole thread

You mean sub-thread, of course. Learn the difference.


> carefully before you try a counter-argument.

It's not an argument, it's an example.

It's not counter, it's the opposite of counter.


John
--
John Harris

RobG

unread,
Apr 11, 2010, 7:23:42 PM4/11/10
to
On Apr 10, 2:00 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:

> Lasse Reichstein Nielsen wrote:
> > Thomas 'PointedEars' Lahn writes:
> >> Antony Scriven wrote:
> >>> That's not helpful since 2.1 states `The term "javascript"
> >>> is used as a common name for all dialects of ECMAScript.'
> >> That's a bug.
>
> > If the whole world disagrees with you ... it must be them who are wrong!
>
> Argument at the silent majority.

No, it's an accurate reflection of the opinions expressed here and not
just in this thread. Consider your statement:

"[javascript] is pure invention by those who don't know


better or don't want to know better."

which is a generalisation aimed at discrediting anyone who disagrees
with your position. It is unsubstantiated by any post here, perhaps
you have a link to a resource that supports your opinion?


> >>> And the OP specifies the implementation.
> >> They don't.
>
> > He did. That you don't recognize it doesn't mean that it wasn't there.
> > The node.js environment counts as a specific javascript implementation
> > and environment, based on the V8 engine.
>
> It is inference, not deduction, that lead you to believe that "node.js"
> means that one library that only runs on that one script engine.  AISB,
> "node.js" can be anything.

And "Thomas 'PointedEars' Lahn" could be anyone, or several people. If
you were confused about what node.js is (I didn't know before this
thread) you could have asked.

If you insist on arguing minutae, you'll find it difficult to reach a
conclusion. I have noticed a trait of technical people to look for
answers by examining issues in ever more detail, forgetting to look at
the big picture to see if the original requirement was actually
satisfied. It is equivalent, in many respects, to premature
optimisation.


--
Rob

Thomas 'PointedEars' Lahn

unread,
Apr 11, 2010, 9:38:00 PM4/11/10
to
John G Harris wrote:

> Thomas 'PointedEars' Lahn wrote:
>> John G Harris wrote:
>>> Thomas 'PointedEars' Lahn wrote:
>>>> The point is that without telling about the runtime environment the
>>>> term "javascript" as a replacement term is pretty useless as statement
>>>> made about it can be both completely right and completely wrong, and
>>>> source code presented to be "javascript" code can be both
>>>> syntactically correct and incorrect, working and not working, concepts
>>>> described with it correctly or incorrectly, all depending on the
>>>> runtime environment. Further, the term promotes the common
>>>> misconception that there would be only one language with "dialects",
>>>> where the diversity is clearly a lot greater than this.
>>>
>>> There are no cars.
>>>
>>> There are only VWs, and Peugeots, and FIATs, and Jaguars, and Fords,
>>> and Toyotas, and Kias, and ...
>>
>> Your analogy
>
> It's not an analogy : see a dictionary.

Well, if was not meant as an analogy (which I seriously doubt; even the
supporters of your case have understood it to be one), that only leaves its
being classified as nonsense.

> It's the same foolish reasoning applied to a different class of classes
> of objects.

No. "Cars" is the plural of an umbrella term which meaning has generally
been agreed on (it can be found in numerous dictionaries on both sides of
the Atlantic); it describes a set of objects with common features. (See
below.)

By contrast, first of all "javascript" is not a plural word, by which it is
running the risk of being misunderstood as a proper name instead of an
umbrella term. Second, even though some regard it as an umbrella term,
there is no general agreement as to its meaning (in particular, the
definition in the FAQ is one of many, and one that is not widely used
outside this newsgroup, if that); as a result, its use can only create
further confusion and misconception, especially here in the newsgroup.
Third, a fact that should not be underestimated, it is running a severe
risk of being subject to misspelling or misinterpretation simply because it
differs from terms with different meaning (common in and outside of the
newsgroup) only in character case.



>> is flawed
>
> It's foolish, but not flawed.

Yes, it is. IOW, it's apples and oranges.



>> for reasons already given.
>
> 1 You say 'javascript' is fuzzy, but so is 'cars'.

Fuzzyness is not the issue, but competing -- among them even nonsensical --
definitions in the same field of application, with the FAQ making the claim
that its definition would be the only relevant one for postings, even if
the posters have not read the FAQ yet. That is not only illogical, it is
utterly absurd, and -- shall we say -- kind of megalomaniac.

By contrast, when talking of "cars" nowadays without a specific context,
everybody knows or can know (by dictionary) that the subjects are
motorized, usually four-wheeled ground vehicles (automobiles). At least it
is clear that some kind of machine-powered transportation is involved, be
it by wheel, railway, cable, airship, or seaship, where the context of use
defines the specific meaning of the word.

[That has been different -- not referring to machine-powered one, but to
transportation still -- before steam-powered railway and later the
automobile entered into and horse-drawn vehicles fell out of common use,
when "car", short for "carriage" or "cart", from Latin carrus/carrum
("four-wheeled baggage waggon"), over Anglo-Norman and Middle-English
carre ("cart") or Gaulish karros ("chariot"), was referring to an animal-
drawn, usually four wheeled ground vehicle.]

Especially, none of various "*.cars" or "*.cars.*" groups on Usenet in
several top-level hiarchies (so also several countries) deal with anything
else but motorized (four-)wheeled ground vehicles; aus.cars even has the
tagline "Petrol heads". A reader there who has not read that newsgroup's
tagline, charter, or FAQ, needs to have a really bad day if they understand
"car" or "cars" in a posting without context meaning anything else than
that. The situation is *very* different in comp.lang.javascript with the
term "javascript" (partially due to its outdated tagline and charter, but
mostly because the term is pure *invention*).



> 2 You say the word has been misused, but no-one can say 'cars' has never
> been misused. And anyway, so what?

I find your argument strewn with gaping defects in logic.

>> You would be well-advised to read the whole thread
>
> You mean sub-thread, of course.

No, I meant the *whole* *thread*.

> Learn the difference.

Learn to read, and to interpret less.

>> carefully before you try a counter-argument.
>
> It's not an argument, it's an example.

A bad one at that.

> It's not counter, it's the opposite of counter.

Unfortunately, you do not know what you are talking about.
In double meaning.

Lasse Reichstein Nielsen

unread,
Apr 12, 2010, 1:15:14 AM4/12/10
to
Thomas 'PointedEars' Lahn <Point...@web.de> writes:

> Lasse Reichstein Nielsen wrote:
>
>> Thomas 'PointedEars' Lahn writes:
>>> Antony Scriven wrote:
>>>> That's not helpful since 2.1 states `The term "javascript"
>>>> is used as a common name for all dialects of ECMAScript.'
>>> That's a bug.
>>
>> If the whole world disagrees with you ... it must be them who are wrong!
>
> Argument at the silent majority.

If you are going to be pedantic, I didn't say that the whole world
disagrees with you (notice the "if").
However, this was not an argument, or a statement of fact, it was
a deliberate over-statement meant as a provocation. I believe English
has the idion "exaggeration promotes understanding" too.

Fact is that I don't remember seeing anyone agree with you yet, and
a lot who disagrees, but still you maintain that you are right and
they are wrong. And this is about the usage of a word, something that
is, in the end, defined by how people actually use it (except in a few
countries).

>> He did. That you don't recognize it doesn't mean that it wasn't there.
>> The node.js environment counts as a specific javascript implementation
>> and environment, based on the V8 engine.
>
> It is inference, not deduction, that lead you to believe that "node.js"
> means that one library that only runs on that one script engine. AISB,
> "node.js" can be anything.
>
> Therefore, The OP's postings should have started like "I have tried the
> following code using node.js in Google Chrome ...".

As I said, just because you don't recognize it, it doesn't mean that
it isn't meaningfull[1]. You obviosuly still don't know what node.js
is (since it's not a library, and it doesn't run in Google Chrome).

Those who do know what node.js is can also recognize it by name, and
can also recognize the code as using the node.js file-descriptor
library.

/L
[1] If we are slinging logical fallacies, this is argumentum ad
ignorantum. Just becuause you don't understand it doesn't make it
non-understandable.

Thomas 'PointedEars' Lahn

unread,
Apr 12, 2010, 7:12:56 AM4/12/10
to
Lasse Reichstein Nielsen wrote:

> Thomas 'PointedEars' Lahn writes:
>> Lasse Reichstein Nielsen wrote:
>>> Thomas 'PointedEars' Lahn writes:
>>>> Antony Scriven wrote:
>>>>> That's not helpful since 2.1 states `The term "javascript"
>>>>> is used as a common name for all dialects of ECMAScript.'
>>>> That's a bug.
>>> If the whole world disagrees with you ... it must be them who are
>>> wrong!
>> Argument at the silent majority.
>
> If you are going to be pedantic, I didn't say that the whole world
> disagrees with you (notice the "if").

The "if" is irrelevant to the classification of the argument as a fallacy.
In either case, the argument is assuming that there would be more people
that disagree with my opinion in this matter (including those that stay
silent) than people agreeing with it.

> However, this was not an argument, or a statement of fact, it was
> a deliberate over-statement meant as a provocation. I believe English
> has the idion "exaggeration promotes understanding" too.

You are evading.



> Fact is that I don't remember seeing anyone agree with you yet, and
> a lot who disagrees, but still you maintain that you are right and
> they are wrong.

Argument ad ignorantiam, see below.

> And this is about the usage of a word, something that is, in the end,
> defined by how people actually use it (except in a few countries).

That is the core problem and my core criticism with making up a highly
confusable term to apply for a domain (here: this newsgroup, in its FAQ),
and making the claim that it can only be understood within that domain as
defined for that domain.

>>> He did. That you don't recognize it doesn't mean that it wasn't there.
>>> The node.js environment counts as a specific javascript implementation
>>> and environment, based on the V8 engine.
>> It is inference, not deduction, that lead you to believe that "node.js"
>> means that one library that only runs on that one script engine. AISB,
>> "node.js" can be anything.
>>
>> Therefore, The OP's postings should have started like "I have tried the
>> following code using node.js in Google Chrome ...".
>
> As I said, just because you don't recognize it, it doesn't mean that
> it isn't meaningfull[1]. You obviosuly still don't know what node.js
> is (since it's not a library, and it doesn't run in Google Chrome).
>
> Those who do know what node.js is can also recognize it by name, and
> can also recognize the code as using the node.js file-descriptor
> library.
>
> /L
> [1] If we are slinging logical fallacies, this is argumentum ad
> ignorantum.

The proper spelling is "argument ad ignorantiam" (argument from ignorance,
or appeal to ignorance), and it does not apply to my argumentation. It
does apply to your argument above, though. That fallacy refers to the
situation of assuming that something is true/false because not it has not
been proven false/true. I have never made such an assumption in this
matter. However, above you are assuming (referring to irrelevant facts),
that I must be wrong because you can find nobody who says I am right.

> Just becuause you don't understand it doesn't make it non-understandable.

(That is not the nature of an appeal to ignorance, see above.)

I have never said that I would not understand the reasons why some people
use this term. Instead, I have said or at least implied repeatedly that I
do understand the reasons, but that I do not accept those reasons because
the argumentations they are justified with are not consistent.

So what we have here instead is a straw man argument of yours, yet another
fallacy. But thanks for playing.

John G Harris

unread,
Apr 12, 2010, 3:16:53 PM4/12/10
to
On Mon, 12 Apr 2010 at 03:38:00, in comp.lang.javascript, Thomas
'PointedEars' Lahn wrote:

<snip>


>I find your argument strewn with gaping defects in logic.

<snip>


>Unfortunately, you do not know what you are talking about.
>In double meaning.

Are these your idea of well-reasoned argument ?

John
--
John Harris

Jorge

unread,
Apr 14, 2010, 5:15:26 AM4/14/10
to
On Apr 12, 9:16 pm, John G Harris <j...@nospam.demon.co.uk> wrote:

> On Mon, 12 Apr 2010 at 03:38:00, Thomas PointedEars' Lahn wrote:
>
>   <snip>
>
> >I find your argument strewn with gaping defects in logic.
>   <snip>
> >Unfortunately, you do not know what you are talking about.
> >In double meaning.
>
> Are these your idea of well-reasoned argument ?

Keep trying...
--
Jorge.

0 new messages