Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
a module system (difficult to agree)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 81 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Peter Michaux  
View profile  
 More options Jan 29 2009, 7:12 pm
From: Peter Michaux <petermich...@gmail.com>
Date: Thu, 29 Jan 2009 16:12:10 -0800
Local: Thurs, Jan 29 2009 7:12 pm
Subject: a module system (difficult to agree)
From http://www.blueskyonmars.com/2009/01/29/what-server-side-javascript-n...

> JavaScript needs a standard way to include other modules and for
> those modules to live in discreet namespaces. There are easy ways
> to do namespaces, but there's no standard programmatic way to load
> a module (once!). This is really important, because server side apps
> can include a lot of code and will likely mix and match parts that
> meet those standard interfaces.

An include/load/require system is the essential ingredient in
developing an extensible core interpreter. If a standard existed for
how modules load, then more code could be shared.

Unfortunately, people disagree about how this should be done. Some
like the shared global scope with a module in each child scope and/or
namespace is the way to go. I think this is unnecessarily complex and
that a single global scope like the browser has is the way to go and
anything more should come from the language first.

A large discussion about these issues was had on the Helma NG group
with three main participants. The lack of agreement on the module
system issue was a complete spoiler. I believe this is *the* major
issue to overcome.

Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brian LeRoux  
View profile  
 More options Jan 29 2009, 7:20 pm
From: Brian LeRoux <brian.ler...@gmail.com>
Date: Thu, 29 Jan 2009 16:20:37 -0800
Local: Thurs, Jan 29 2009 7:20 pm
Subject: Re: [serverjs] a module system (difficult to agree)
Agreed, and from there package management is going to be a lot easier.

I'm of the belief that continuing on the JavaScript tradition of being
a first class language of the web that loading into a global space
should be the default (as it is today) with the onus of good
namespacing being the domain of the library authors.

Lots of good places for inspiration out there...

http://code.google.com/apis/ajaxlibs/documentation/index.html
http://developer.yahoo.com/yui/examples/get/get-script-simple.html
http://developer.yahoo.com/yui/yuiloader/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robin Berjon  
View profile  
 More options Jan 29 2009, 7:24 pm
From: Robin Berjon <robin.ber...@gmail.com>
Date: Fri, 30 Jan 2009 01:24:57 +0100
Local: Thurs, Jan 29 2009 7:24 pm
Subject: Re: [serverjs] a module system (difficult to agree)
On Jan 30, 2009, at 01:12 , Peter Michaux wrote:

> A large discussion about these issues was had on the Helma NG group
> with three main participants. The lack of agreement on the module
> system issue was a complete spoiler. I believe this is *the* major
> issue to overcome.

Do you have a pointer to it? That way we could read up beforehand and  
avoid going through the same issues :)

--
Robin Berjon
   Robineko (http://robineko.com/)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Michaux  
View profile  
 More options Jan 29 2009, 7:34 pm
From: Peter Michaux <petermich...@gmail.com>
Date: Thu, 29 Jan 2009 16:34:07 -0800 (PST)
Local: Thurs, Jan 29 2009 7:34 pm
Subject: Re: a module system (difficult to agree)
On Jan 29, 4:20 pm, Brian LeRoux <brian.ler...@gmail.com> wrote:

> Agreed, and from there package management is going to be a lot easier.

I almost wrote the same thing. A package system (CPAN and apt
inspired) is the second thing I worked on for my server-side system. I
don't think a package distribution system has any issues that are as
"hot button" as the module loading issue has.

> I'm of the belief that continuing on the JavaScript tradition of being
> a first class language of the web that loading into a global space
> should be the default (as it is today) with the onus of good
> namespacing being the domain of the library authors.

I agree. It is the way the language is and we have already discovered
ways for how to deal with the problems of a global namespace.

Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Michaux  
View profile  
 More options Jan 29 2009, 7:42 pm
From: Peter Michaux <petermich...@gmail.com>
Date: Thu, 29 Jan 2009 16:42:12 -0800 (PST)
Local: Thurs, Jan 29 2009 7:42 pm
Subject: Re: a module system (difficult to agree)
On Jan 29, 4:24 pm, Robin Berjon <robin.ber...@gmail.com> wrote:

> On Jan 30, 2009, at 01:12 , Peter Michaux wrote:

> > A large discussion about these issues was had on the Helma NG group
> > with three main participants. The lack of agreement on the module
> > system issue was a complete spoiler. I believe this is *the* major
> > issue to overcome.

> Do you have a pointer to it? That way we could read up beforehand and  
> avoid going through the same issues :)

It was a doozy spread across several threads.

http://groups.google.com/group/helma-ng/browse_frm/thread/79afcdef68a...

http://groups.google.com/group/helma-ng/browse_frm/thread/6d002cb42a4...

Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Svensson  
View profile  
 More options Jan 30 2009, 12:47 am
From: Peter Svensson <psvens...@gmail.com>
Date: Fri, 30 Jan 2009 06:47:06 +0100
Local: Fri, Jan 30 2009 12:47 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)

Ow. I really don't agree :/ Having said that, I'll take a double helping of
global namespace pollution gladly any day over not getting anywhere :)
In my experience (again, only either hopping on random code on disaster area
projects or using Dojo) is that a short namespaced object hierarchy for
different functions has the benefit of being very clear. Putting everything
in global is a bit like having indexOf in the global namespace instead of on
the String object.

Also, using namespaced object does the obvious; no collission of variable of
function names, or the more probably mistaken one function for another with
a similar sounding name.

I'd rather see;

ssjs.file.open()
ssjs.foo.openup()

than

open()
openup()

Cheers,
PS

http://unclescript.blogspot.com

On Fri, Jan 30, 2009 at 1:34 AM, Peter Michaux <petermich...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Michaux  
View profile  
 More options Jan 30 2009, 2:12 am
From: Peter Michaux <petermich...@gmail.com>
Date: Thu, 29 Jan 2009 23:12:35 -0800
Local: Fri, Jan 30 2009 2:12 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)

This is not the difference folks usually mean when they talk about
namespaces and module loading systems. What you are showing is
simulating namespaces by using an object hierarchy in a global
namespace system. It works in the browser and would work fine in a
server-side system with a global namespace. I'm in favor of this type
of system (though see ssjs_file_open as better than ssjs.file.open in
several ways). These types of namespacing strategies are based on
convention.

When folks talk about "real" namespaces they are usually meaning
systems where code from one namespace has a limited, controlled
channel of interaction with objects from another namespace. There is
language or host support to assist or support the idea of namespaces.
From what I've seen on the ECMAScript mailing list, this sort of
system has been proposed and rejected (at least for now) from
ECMAScript.

Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Svensson  
View profile  
 More options Jan 30 2009, 3:01 am
From: Peter Svensson <psvens...@gmail.com>
Date: Fri, 30 Jan 2009 09:01:20 +0100
Local: Fri, Jan 30 2009 3:01 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)

Then I stand happily corrected :)
Though, concatenating the names in a simulated object hierarchy give nothing
of the benefits of having an actual hierarchy and you're still using one, so
..

Cheers,
PS

On Fri, Jan 30, 2009 at 8:12 AM, Peter Michaux <petermich...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tom Robinson  
View profile  
 More options Jan 30 2009, 6:17 am
From: Tom Robinson <tlrobin...@gmail.com>
Date: Fri, 30 Jan 2009 03:17:01 -0800 (PST)
Local: Fri, Jan 30 2009 6:17 am
Subject: Re: a module system (difficult to agree)
You mention "open()" and "ssjs.file.open()" as possibilities, but you
left out my preference: "file.open()". I think it's perfectly
reasonable to have a few standard objects in the global scope, like
"File", "Socket", "require", etc.

Here's why:

1) While I do think *libraries* of code should be "namespaced", I
don't think that's necessary for what we're trying to do here. In the
browser XMLHttpRequest is a top level object. I'd say this project is
more like adding XMLHttpRequest to JavaScript than writing a library.

2) It's essentially what Ruby, Python, and many other languages do.
You usually don't see things like "Ruby.File.open()".

If we want this to be a standard (de facto or otherwise) we have to
act like it's a standard. Using "ssjs.File" sends the message that
it's not *really* the standard, it's just part of this "ssjs" thing
(also, I think ssjs is a misleading name, since you'll be able to use
it for things other than servers)

3) Some command line JS interpreters already come with a File object,
but they all vary slightly in how they work. Hopefully this project
will standardize them, not augment them. Having "File" and "ssjs.File"
is just confusing.

4) If you force all 3rd party libraries loaded through the package
system to also be part of this "ssjs" namespace, you're not fixing the
collision problem, you're just moving it down one layer.

5) Accessing "ssjs.File" is slightly slower than "File". Probably not
a big deal though.

That's my 2˘

-Tom

On Jan 29, 9:47 pm, Peter Svensson <psvens...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Svensson  
View profile  
 More options Jan 30 2009, 6:22 am
From: Peter Svensson <psvens...@gmail.com>
Date: Fri, 30 Jan 2009 12:22:04 +0100
Local: Fri, Jan 30 2009 6:22 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)

Thanks for giving me another angle to see this from, Tom.

I agree with you that if this is going to be _the_ standard Server-Side
JavaScript definition, then having an extra level of namespace is of no real
use. I think I was mainly trying to emphasize the use of namespacing objects
in general, instead of concatenated function names as namespace.

Cheers,
PS


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stuart Langridge  
View profile  
 More options Jan 30 2009, 6:48 am
From: Stuart Langridge <s...@kryogenix.org>
Date: Fri, 30 Jan 2009 11:48:46 +0000
Local: Fri, Jan 30 2009 6:48 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)

> 2) It's essentially what Ruby, Python, and many other languages do.
> You usually don't see things like "Ruby.File.open()".
> 3) Some command line JS interpreters already come with a File object,
> but they all vary slightly in how they work. Hopefully this project
> will standardize them, not augment them. Having "File" and "ssjs.File"
> is just confusing.

I don't agree there. Python does that because there's only one Python
interpreter. (Well, there are others, but they're explicitly
compatible with CPython.) We have multiple incompatible interpreters.
If there's going to be a global File object then we either wait for
all the interpreters to implement it, or we implement it ourselves as
a wrapper on top of whichever interpreter you're on. As you say, some
interpreters already come with a File object, but the whole point of
standardising an API, to my mind, is to make sure you can write SSJS
to one API and not many. If you're using ssjs.File then you *know*
that it's the standard file object. If you're using File, then you
don't know whether it's the SSJS file object or the interpreter's file
object. Worse, if we override an existing global File with our global
File then anyone who *wants* to make their project
interpreter-dependent is out of luck, because we've overridden the
interpreter's API.

> 4) If you force all 3rd party libraries loaded through the package
> system to also be part of this "ssjs" namespace, you're not fixing the
> collision problem, you're just moving it down one layer.

I don't think that's a good idea (it's certainly not what I'm
proposing). SSJS would be the anointed, simple, API that does the
basics. Other libraries can depend on it if they want to, but I don't
think that they're part of it.

sil


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Miguel Coquet  
View profile  
 More options Jan 30 2009, 7:33 am
From: Miguel Coquet <mcoq...@gmail.com>
Date: Fri, 30 Jan 2009 12:33:54 +0000
Local: Fri, Jan 30 2009 7:33 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)
I must say, I'm personally for the top level objects in global. An
ssjs.* object would "smell" too much like a library or framework.

This being a spec, means that whoever wants a compatible interpreter
will have to implement it to be so, or just stay incompatible, making
the overriding problem a non-issue. Patches can be submitted for the
different opensource projectes and the closedsource world will just
have to make do.

The need for a standard is exactly so people can follow it and not the
other way around.

Cheers

Miguel


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Robinson  
View profile  
 More options Jan 30 2009, 8:11 am
From: Thomas Robinson <tlrobin...@gmail.com>
Date: Fri, 30 Jan 2009 05:11:50 -0800
Local: Fri, Jan 30 2009 8:11 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)
I think the concept of wrapping a bunch of existing incompatible APIs  
in a library is a necessary evil of the browser world, which we should  
try to avoid on the server, because we can.

Many of the things we're planning on doing will require modifying the  
command line shells themselves. In the process I don't have any qualms  
about replacing an old File object API with the new standard one.

But now that I think about it, none of the standard shells actually  
come with a File object. So neither of our arguments on that one are  
valid ;)

- Rhino has java.io.File, of course. No namespace conflict there though.
- SpiderMonkey/TraceMonkey has one that's not included in normal  
distributions, and they don't sound very enthusiastic about it: https://developer.mozilla.org/En/SpiderMonkey/File_object
- V8 doesn't have one (lv8call and v8cgi implement incompatible ones)
- JavaScriptCore doesn't have one.

Those are the "big four" in my mind. What others are there that we  
want to support?

-tom

On Jan 30, 2009, at 3:48 AM, Stuart Langridge wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robin Berjon  
View profile  
 More options Jan 30 2009, 8:11 am
From: Robin Berjon <robin.ber...@gmail.com>
Date: Fri, 30 Jan 2009 14:11:33 +0100
Local: Fri, Jan 30 2009 8:11 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)
On Jan 30, 2009, at 12:48 , Stuart Langridge wrote:

Your argument relies entirely on clashes with identically named  
objects in existing interpreters. I agree that that can be a problem —  
if, say, you redefine File.open() then anything that already relies on  
it in that implementation might break — but disagree that stuffing  
everything into a subnamespace is necessarily the solution: we can  
simply pick names that don't clash with the implementations that we're  
targeting.

--
Robin Berjon
   Robineko (http://robineko.com/)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ondrej Zara  
View profile  
 More options Jan 30 2009, 8:18 am
From: Ondrej Zara <ondrej.z...@gmail.com>
Date: Fri, 30 Jan 2009 14:18:34 +0100
Local: Fri, Jan 30 2009 8:18 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)
My two cents: JavaScript already comes with the concept of
global-level "class" names (Object, Array, Date, ..) and people (we!)
are well used to this. The whole "encapsulate-or-die" stuff is the
result of mixing client libraries, something we want (and can) evade.

So, I strongly opt for [global].File() instead of ssjs.File().

Ondrej


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Hannes Wallnoefer  
View profile  
 More options Jan 30 2009, 8:48 am
From: Hannes Wallnoefer <hann...@gmail.com>
Date: Fri, 30 Jan 2009 05:48:48 -0800 (PST)
Local: Fri, Jan 30 2009 8:48 am
Subject: Re: a module system (difficult to agree)
I think you're aiming too high by trying to get people agree on
namespaces at this time. IMO, what we should do now is talk about what
basic API should be provided - what classes and objects are available,
and what they do. I think namespaces are the last thing we need to
worry about, and in JavaScript it's just one line to turn a foo.File
into a File.

With Helma NG, you have full control how you want to access your
modules. import('helma.file') will put the module into a helma.file
namespace, while include('helma.file') will set up the File
constructor (generally all exported symbols) directly in your local
scope, and you can do var file = require('helma.file') to take control
of the namespace yourself. I personally wouldn't want to live without
this, just like no Python person in one's right mind would trade
python's module system for something less flexible.

Talking about File APIs, the helma.file module is built on top of
java.io.File:
http://github.com/hns/helma-ng/blob/89a30cf8b6f83e8f180a6d87d45d30f57...
It has a few nice extras, like recursive copying of directories and
iterating through the lines of a file. For example, the following line
prints all lines of file README.txt prefixed with '>':

helma> include('helma.file');
helma> for (var line in new File('README.txt')) print(line);

I think it's things like this that are worth being considered as
standards or pseudo-standards.

Hannes

On Jan 30, 12:48 pm, Stuart Langridge <s...@kryogenix.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
pmuellr  
View profile  
 More options Jan 30 2009, 8:53 am
From: pmuellr <pmue...@yahoo.com>
Date: Fri, 30 Jan 2009 05:53:21 -0800 (PST)
Local: Fri, Jan 30 2009 8:53 am
Subject: Re: a module system (difficult to agree)
On Jan 30, 8:18 am, Ondrej Zara <ondrej.z...@gmail.com> wrote:

> My two cents: JavaScript already comes with the concept of
> global-level "class" names (Object, Array, Date, ..) and people (we!)
> are well used to this. The whole "encapsulate-or-die" stuff is the
> result of mixing client libraries, something we want (and can) evade.

> So, I strongly opt for [global].File() instead of ssjs.File().

Shoving everything into the global namespace doesn't scale well,
especially when it comes to users wanting to build their own libraries/
frameworks.  This was the story in Smalltalk, back in the day.  We use
to have to prefix all our classes with product specific strings to
keep some amount of order (AbtXxxYyy, anyone?).  PHP, today, does the
same thing, see the Zend framework for their naming scheme:

   http://framework.zend.com/manual/en/

If you have to end up with prefixes anyway, they might as well be
first-class objects (in the "ssjs" sense) as opposed to prepended
strings in your function/class names.  Objects == good.

As I hope some of the good stuff coming out of this effort might rub-
off on our JavaScript environments in browsers, I'm not terribly keen
on "ssjs" as the prefix though.  "js"?  "std"?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Svensson  
View profile  
 More options Jan 30 2009, 8:53 am
From: Peter Svensson <psvens...@gmail.com>
Date: Fri, 30 Jan 2009 14:53:46 +0100
Local: Fri, Jan 30 2009 8:53 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)

OK. Let's shelve the namespaces for now and focus on features :)

Cheers,
PS

On Fri, Jan 30, 2009 at 2:48 PM, Hannes Wallnoefer <hann...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
nlloyds  
View profile  
 More options Jan 30 2009, 9:29 am
From: nlloyds <nllo...@gmail.com>
Date: Fri, 30 Jan 2009 06:29:53 -0800 (PST)
Local: Fri, Jan 30 2009 9:29 am
Subject: Re: a module system (difficult to agree)

Tom,

On Jan 30, 7:11 am, Thomas Robinson <tlrobin...@gmail.com> wrote:

> - Rhino has java.io.File, of course. No namespace conflict there though.
> - SpiderMonkey/TraceMonkey has one that's not included in normal  
> distributions, and they don't sound very enthusiastic about it:https://developer.mozilla.org/En/SpiderMonkey/File_object
> - V8 doesn't have one (lv8call and v8cgi implement incompatible ones)
> - JavaScriptCore doesn't have one.

> Those are the "big four" in my mind. What others are there that we  
> want to support?

On ASP and other Windows-based JS implementations, COM/ActiveX objects
are used, so on Windows servers there is Scripting.FileSystemObject
(http://www.w3schools.com/asp/asp_ref_filesystem.asp)

For environments that don't include a *real* file API, it's easy to
build a layer on top of the ActiveXObject access. That's what I've
been doing internally for a while, and it will be nice to have an
*official* file API to follow rather than taking random inspiration
from different sources.

Thanks,

Nathan


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robin Berjon  
View profile  
 More options Jan 30 2009, 9:52 am
From: Robin Berjon <robin.ber...@gmail.com>
Date: Fri, 30 Jan 2009 15:52:57 +0100
Local: Fri, Jan 30 2009 9:52 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)
On Jan 30, 2009, at 14:53 , pmuellr wrote:

> Shoving everything into the global namespace doesn't scale well,
> especially when it comes to users wanting to build their own  
> libraries/
> frameworks.

Those are two separate issues. The standard stuff defines a (limited)  
number of objects in the global namespace (e.g. File) and then  
extensions do whatever they want, except that good practice is  
documented telling people not to pollute the global namespace. That's  
how CPAN works, and overall it works really well.

--
Robin Berjon
   Robineko (http://robineko.com/)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Michaux  
View profile  
 More options Jan 30 2009, 10:03 am
From: Peter Michaux <petermich...@gmail.com>
Date: Fri, 30 Jan 2009 07:03:18 -0800
Local: Fri, Jan 30 2009 10:03 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)

On Fri, Jan 30, 2009 at 5:11 AM, Thomas Robinson <tlrobin...@gmail.com> wrote:

> I think the concept of wrapping a bunch of existing incompatible APIs
> in a library is a necessary evil of the browser world, which we should
> try to avoid on the server, because we can.

Since this group is essentially a specification group, that is just a
matter of specifying only one API.

> Many of the things we're planning on doing will require modifying the
> command line shells themselves. In the process I don't have any qualms
> about replacing an old File object API with the new standard one.

> But now that I think about it, none of the standard shells actually
> come with a File object. So neither of our arguments on that one are
> valid ;)

Command shells are applications (just like browsers are) where the
application has a JavaScript interpreter embedded inside the
application.

> - Rhino has java.io.File, of course. No namespace conflict there though.
> - SpiderMonkey/TraceMonkey has one that's not included in normal
> distributions, and they don't sound very enthusiastic about it: https://developer.mozilla.org/En/SpiderMonkey/File_object
> - V8 doesn't have one (lv8call and v8cgi implement incompatible ones)
> - JavaScriptCore doesn't have one.

It is the host application's job to expose access to things
appropriate to the particular scripting environment. A server-side
interpreter can expose a File object. A browser interpreter should
not. So it is good that SpiderMonkey and V8 don't expose File as a
standard host object.

> Those are the "big four" in my mind. What others are there that we
> want to support?

This discussion group won't support JavaScript implementations. Host
applications will choose to support the results of this discussion
group by adding host objects and only if a particular host application
finds doing so worthwhile and beneficial.

Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Michaux  
View profile  
 More options Jan 30 2009, 10:09 am
From: Peter Michaux <petermich...@gmail.com>
Date: Fri, 30 Jan 2009 07:09:17 -0800
Local: Fri, Jan 30 2009 10:09 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)

On Fri, Jan 30, 2009 at 6:52 AM, Robin Berjon <robin.ber...@gmail.com> wrote:

> On Jan 30, 2009, at 14:53 , pmuellr wrote:
>> Shoving everything into the global namespace doesn't scale well,
>> especially when it comes to users wanting to build their own
>> libraries/
>> frameworks.

> Those are two separate issues. The standard stuff defines a (limited)
> number of objects in the global namespace (e.g. File) and then
> extensions

Although a standard File API would be great, the actual File
implementation can be as an extension itself. The only thing that
needs to be added to the JavaScript interpreter is something like
"load" to execute other files of code. One of those files of code
could contain a File object.

> do whatever they want, except that good practice is
> documented telling people not to pollute the global namespace. That's
> how CPAN works, and overall it works really well.

I agree. A library author should not be forced into a straight jacket.
He should be shown how to put on the straight jacket himself. I think
most JavaScript programmers realize a library global function called
"trim" has a good chance of namespace collision and would like to
avoid that.

Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Schultz  
View profile  
 More options Jan 30 2009, 10:18 am
From: Robert Schultz <sembia...@gmail.com>
Date: Fri, 30 Jan 2009 07:18:07 -0800 (PST)
Local: Fri, Jan 30 2009 10:18 am
Subject: Re: a module system (difficult to agree)
It could behave something like this:

import("File")
Import the standard File object directly into the global namespace. So
now you can do
var f = new File("some.txt");
var lines = f.readLines();
or
var lines = File.readLines("some.txt");

Maybe import could have an optional second argument, which object to
insert into:
var myObj = {};
import("File", myObj)
var f = new myObj.File("some.txt");
var lines = f.readLines();
or
var lines = myObj.File.readLines("some.txt");

This way those that are ok with polluting the global namespace for
efficiency sake can just import away.
Those that want things all in a single object like SSJS or something
can do that.

The question then becomes where does import live?
Does it sit in the global object, do we have a tiny few number of
these?
Maybe a command line switch to optionally have import and other
similar functions be put into a new SSJS object in global rather than
directly in global. Again, giving pollution control to those that want
it.

It's trivial to implement both (well it is for v8 and for
spidermonkey, dunno on the other interpreters) and seems ok to me to
implement both.

On Jan 30, 9:52 am, Robin Berjon <robin.ber...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Michaux  
View profile  
 More options Jan 30 2009, 10:20 am
From: Peter Michaux <petermich...@gmail.com>
Date: Fri, 30 Jan 2009 07:20:37 -0800
Local: Fri, Jan 30 2009 10:20 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)

On Fri, Jan 30, 2009 at 5:18 AM, Ondrej Zara <ondrej.z...@gmail.com> wrote:

> My two cents: JavaScript already comes with the concept of
> global-level "class" names (Object, Array, Date, ..) and people (we!)
> are well used to this. The whole "encapsulate-or-die" stuff is the
> result of mixing client libraries, something we want (and can) evade.

> So, I strongly opt for [global].File() instead of ssjs.File().

I mostly agree and would like to agree completely.

I think that CPAN offers a good example to follow. Because CPAN is the
canonical repository, code in CPAN can define a global like "File".
The CPAN maintainers approve new namespaces to avoid collision. If
everyone else in the Perl world uses a prefix containing who they are
then that will never collide with CPAN naming because CPAN naming
doesn't contain any information about who is writing the code. So a
company called XYZ would write an XYZ::File module and that would
likely never collide with any CPAN module because "XYZ" is a company
name and likely not appropriate for a CPAN module. There is still some
risk.

Java takes this to what might be considered an extreme by using
reverse domain names. That same company's class would be com.xyz.File
and this naming convention almost ensures no collisions as domains are
registered with a central service.

For a standardized JavaScript file object, if the desired semantics
are a global file object then it is a matter of choosing a string for
that object's identifier. Choosing "File" would work. Choosing
"std_File" would work. Even "asdf" would work. Some of these are
better than others but they all have the same semantics.

Peter


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thomas Robinson  
View profile  
 More options Jan 30 2009, 10:23 am
From: Thomas Robinson <tlrobin...@gmail.com>
Date: Fri, 30 Jan 2009 07:23:50 -0800
Local: Fri, Jan 30 2009 10:23 am
Subject: Re: [serverjs] Re: a module system (difficult to agree)

On Jan 30, 2009, at 7:03 AM, Peter Michaux wrote:

Yes, but the interpreter doesn't implement the File object, otherwise  
we would all have File objects in the browser. The shell, or some  
library included by the shell, implements it.

That's ideally how it would work, but I suspect if we just release a  
spec and hope for the JS engine developers to implement it themselves  
it will take years. I think we'll need to actively develop at least  
one "reference implementation" of the spec.

But if there are JS engine contributors here who plan to support this  
project, it would be nice to hear that :)

I saw Norris Boyd (creator of Rhino) is on the list, but I don't know  
if he or anyone from the Rhino project plans to actively implement  
this stuff.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 81   Newer >
« Back to Discussions « Newer topic     Older topic »