[Prototype-core] Prototype without browser?

17 views
Skip to first unread message

Rüdiger Plantiko

unread,
Apr 20, 2010, 2:47:37 PM4/20/10
to Prototype: Core
Dear Prototype core team,

I like the syntactic idioms of Prototype, particularly the Enumerable
module. The methods really help to improve the readability of
JavaScript code.

Right now, I am writing a little program in JavaScript which is
thought for running in batch mode, i.e. from the command line.

I wonder whether it's possible to separate the UI part of Prototype -
connected with the browser - from its syntactic core. How much effort
would it be? When running

cscript prototype.js

on my windows machine, I get error because a "window" object is
missing. I hoped that replacing the initial "Browser" and
"BrowserFeatures" declarations by hashs with all properties set to
"false" could solve the problem. But there are more places where the
browser environment is expected.

How difficult would it be to separate the "core" layer from the
"browser-dependent" layer in Prototype? I don't know the mechanism how
the final Prototype.js is built from its code parts: Would it be
possible to build another product from these parts which only covers
the Prototype core?

Thanks for an answer,
Rüdiger

--
You received this message because you are subscribed to the Google Groups "Prototype: Core" group.
To post to this group, send email to prototy...@googlegroups.com
To unsubscribe from this group, send email to prototype-cor...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en

toxcct

unread,
Apr 21, 2010, 4:46:02 AM4/21/10
to prototy...@googlegroups.com
Hi Rüdiger,

Are you sure you are using "Javascript" precisely ?
Aren't you using some kind of ECMAScript instead ?

because Javascript by definition is Browser oriented, and IMO, it doesn't really make sense to try to use Prototype outside of a browser then.


Regards,


2010/4/20 Rüdiger Plantiko <ruediger...@astrotexte.ch>

Tobie Langel

unread,
Apr 21, 2010, 6:41:57 AM4/21/10
to Prototype: Core
Hi, Rüdiger.

This is definitely planned for 2.0.

toxcct, you might want of have a look at a number of really exciting
server side JS frameworks (node.js, narwhal, ringo, etc.).

Best,

Tobie

Rüdiger Plantiko

unread,
Apr 21, 2010, 7:51:16 AM4/21/10
to Prototype: Core
Hi Tobie and toxcct,

> This is definitely planned for 2.0.

Good news! Looking forward to this then. Probably the best way would
be to adapt the build process: Building two different files from the
sources - one for the batch / server side context, and another one for
the browser context. This variant would be better than having one
"prototype.js" with lots of conditionals that have to be executed at
runtime.

>really exciting server side JS frameworks (node.js, narwhal, ringo, etc.).
I will have a look at those, thanks for the info.

@toxcct:

>Are you sure you are using "Javascript" precisely ?
>Aren't you using some kind of ECMAScript instead ?

Well, my scripts are executed with the same library (%systemroot%
\system32\jscript.dll) that is used by the Internet Explorer for
script execution. The only difference is that there is no browser
around and hence no global "window" object, no "document" etc.
Instead, i execute the JS files with the "cscript" command.

You ask which kind of ECMAScript I am using. For me, it is of no
practical use to classify the capabilities of this jscript.dll. It is
sufficient that it understands the ECMA script standard as a subset of
its language scope. Indeed, I can execute my script in Google Chrome,
in Firefox and in IE, as it only uses the ECMAScript core which is
understood by all these user agents. The point is that I don't want to
run the script in a browser. I want to start it as a batch file with
no UI. And the question was about whether I still could use the nice
language enhancements provided by prototype even in this context. This
has been answered by Tobie now.

Thanks and regards,
Rüdiger

Mislav Marohnić

unread,
Apr 21, 2010, 9:48:41 AM4/21/10
to prototy...@googlegroups.com
JavaScript "without a browser" is becoming increasingly more popular (and important) in the industry, so I definitely look forward to seeing language extensions extracted in a separate module/library. If you take a look at the current source tree now, you'll see effort being made in this direction.

nlloyds

unread,
Apr 22, 2010, 9:35:27 AM4/22/10
to Prototype: Core
Rüdiger

Check out Prototype ASP: http://nlsmith.com/projects/prototype-asp/,
http://github.com/smith/prototype-asp/tree/asp. It works in cscript as
well as other places. It's just a quick hack and is not meant to be
it's own product or anything, but it works reliably on jscript and
other non-browser platforms.

Nathan

nlloyds

unread,
Apr 22, 2010, 9:42:34 AM4/22/10
to Prototype: Core


On Apr 21, 6:51 am, Rüdiger Plantiko <ruediger.plant...@astrotexte.ch>
wrote:
> >Are you sure you are using "Javascript" precisely ?
> >Aren't you using some kind of ECMAScript instead ?
>
> Well, my scripts are executed with the same library  (%systemroot%
> \system32\jscript.dll)  that is used by the Internet Explorer for
> script execution. The only difference is that there is no browser
> around and hence no global "window" object, no "document" etc.
> Instead, i execute the JS files with the "cscript" command.

You're right. JScript a decently compliant engine, thought not fast.
It does have the advantage of being installed on every Windows
machine. Classic ASP also uses the same engine. There's a few extra
APIs for ActiveXObjects and basic shell and window alerts (WScript.)

Nathan

Matt Foster

unread,
Apr 22, 2010, 10:54:57 AM4/22/10
to Prototype: Core
I've used the Enumerable methods and the core stuff like Function.bind
and Class.create in whatever ECMA flavor the Adobe programs
use(Indesign & Photoshop) so I'm sure it's possible to leverage some
things from prototype in your program.

http://www.adobe.com/devnet/photoshop/pdfs/JavaScriptReferenceGuide.pdf

--

http://positionabsolute.net

Rüdiger Plantiko

unread,
Apr 22, 2010, 11:37:11 AM4/22/10
to Prototype: Core
Hello Nathan and Matt,

thanks for your suggestions and interesting links. I will study them
and probably
use one of your proposals...

Thanks and regards,
Rüdiger

nlloyds

unread,
Apr 23, 2010, 9:09:59 AM4/23/10
to Prototype: Core
On Apr 22, 9:54 am, Matt Foster <mattfoste...@gmail.com> wrote:
> I've used the Enumerable methods and the core stuff like Function.bind
> and Class.create in whatever ECMA flavor the Adobe programs
> use(Indesign & Photoshop) so I'm sure it's possible to leverage some
> things from prototype in your program.

This may be using some ES5 variant. Many new methods in this new
version of ECMAScript are either inspired by or present in Prototype:

http://www.ecma-international.org/publications/files/drafts/tc39-2009-050.pdf
http://github.com/280north/narwhal/blob/master/engines/default/lib/global-es5.js
Reply all
Reply to author
Forward
0 new messages