By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,793 Members | 1,269 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,793 IT Pros & Developers. It's quick & easy.

Standalone Javascript interpreter for Linux?

P: n/a
I'm looking for a standalone Javascript interpreter like the ones of
Perl and Python. Does such a thing exist for Linux?

Thanks in advance.

-Erik

--
hackerkey://v4sw5hw2ln3pr5ck0ma2u7LwXm4l7Gi2e2t4b7Ken4/7a16s0r1p-5.62/-6.56g5OR
Oct 31 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Ah FFS. For *once* I'm not looking at the headers, and he's
cross-posting with f'up. Anyway, for the archives, here's what I just
unintentionally posted to comp.os.linux.misc...
On 2008-10-31 01:59, Erik Hahn wrote:
I'm looking for a standalone Javascript interpreter like the ones of
Perl and Python. Does such a thing exist for Linux?
Yes. There's Rhino (Java implementation of Mozilla's JavaScript engine),
SpiderMonkey (C implementation of the same, but not really usable as a
scripting environment), and a few other packages that look promising,
but that I haven't tested yet. I'd recommend starting with Rhino.

Mozilla Rhino
http://www.mozilla.org/rhino/

Mozilla SpiderMonkey
http://www.mozilla.org/js/spidermonkey/

JSDB
http://www.jsdb.org/

wxJavaScript
http://www.wxjavascript.net/
- Conrad
Oct 31 '08 #2

P: n/a
On Oct 31, 9:27 am, Conrad Lender <crlen...@yahoo.comwrote:
On 2008-10-31 01:59, Erik Hahn wrote:
I'm looking for a standalone Javascript interpreter like the ones of
Perl and Python. Does such a thing exist for Linux?
<snip>
SpiderMonkey (C implementation of the same, but not really usable as a
scripting environment)>
<snip>
Mozilla SpiderMonkeyhttp://www.mozilla.org/js/spidermonkey/
The demo js interpreter that comes with SpiderMonkey is actually
really easy to extend. I managed to add file IO capabilities
(fopen,fread,fgets,fputs,fseek,fclose) in around 250 lines of code. I
believe this was the origin of JSDB. JSDB looks really nice especially
the unified Streams API that lets you open files on disk as well as
URI.

I myself have been thinking of implementing a simple binary module/
package system for SipderMonkeys js interpreter (instead of directly
modifying the interpreter) so that you can simply "require" a module
and have it loaded. Lots of languages have gone this path,
implementing a very simple interpreter which is turing complete but
can't do much then load features from modules/packages.

Oct 31 '08 #3

P: n/a
On 2008-10-31 02:53, slebetman wrote:
>SpiderMonkey (C implementation of the same, but not really usable as a
scripting environment)>
<snip>
Mozilla SpiderMonkeyhttp://www.mozilla.org/js/spidermonkey/

The demo js interpreter that comes with SpiderMonkey is actually
really easy to extend. I managed to add file IO capabilities
(fopen,fread,fgets,fputs,fseek,fclose) in around 250 lines of code.
Sometimes I really regret that I haven't done more C programming. I
couldn't even build the stupid thing with support for the old File
object :-/
When I was experimenting with the SpiderMonkey jsshell, all I had was
the readline() function. Unfortunately this function isn't nearly as
useful as I had hoped - it doesn't recognize the EOF, and it seems to
automagically convert all input to Unicode. I had to resort to writing a
Perl wrapper that passed the number of lines to be read to the js file.
I myself have been thinking of implementing a simple binary module/
package system for SipderMonkeys js interpreter (instead of directly
modifying the interpreter)
I think the interpreter is meant to be embedded anyway, not modified
directly. I think this is what JSDB is doing. If you go ahead with this
and build a usable all-purpose interpreter, count me in as a beta tester.
so that you can simply "require" a module and have it loaded.
There's a load() function in jsshell. It works, but it's very basic and
doesn't do any fancy stuff like path management.
Lots of languages have gone this path,
implementing a very simple interpreter which is turing complete but
can't do much then load features from modules/packages.
A full scripting environment for JS on the command line would be very
exciting. In time, we could even have module repositories like CPAN =)
- Conrad
Oct 31 '08 #4

P: n/a
On Oct 30, 7:30*pm, Conrad Lender <crlen...@yahoo.comwrote:
On 2008-10-31 02:53, slebetman wrote:
SpiderMonkey (C implementation of the same, but not really usable as a
scripting environment)>
<snip>
Mozilla SpiderMonkeyhttp://www.mozilla.org/js/spidermonkey/
The demo js interpreter that comes with SpiderMonkey is actually
really easy to extend. I managed to add file IO capabilities
(fopen,fread,fgets,fputs,fseek,fclose) in around 250 lines of code.

Sometimes I really regret that I haven't done more C programming. I
couldn't even build the stupid thing with support for the old File
object :-/
When I was experimenting with the SpiderMonkey jsshell, all I had was
the readline() function. Unfortunately this function isn't nearly as
useful as I had hoped - it doesn't recognize the EOF, and it seems to
automagically convert all input to Unicode. I had to resort to writing a
Perl wrapper that passed the number of lines to be read to the js file.
I myself have been thinking of implementing a simple binary module/
package system for SipderMonkeys js interpreter (instead of directly
modifying the interpreter)

I think the interpreter is meant to be embedded anyway, not modified
directly. I think this is what JSDB is doing. If you go ahead with this
and build a usable all-purpose interpreter, count me in as a beta tester.
so that you can simply "require" a module and have it loaded.

There's a load() function in jsshell. It works, but it's very basic and
doesn't do any fancy stuff like path management.
Lots of languages have gone this path,
implementing a very simple interpreter which is turing complete but
can't do much then load features from modules/packages.

A full scripting environment for JS on the command line would be very
exciting. In time, we could even have module repositories like CPAN =)
I'm working on this same idea for Rhino. (Actually my project could
incorporate C implementations as well. I started working on a
Spidermonkey version but moved to Rhino.)

The foundation of what I'm building is a package management client
called xpkg. The intention is this will work like CPAN or apt-get. The
xpkg client I'm building is written in Perl. The language here doesn't
really matter as it is just a command line tool. Clients in other
languages could be written too.

Then the entire JavaScript world of xjs packages can be installed and
managed. The core package does little more than just add "require" and
"load" as host objects. I have packages for a web server, database
access etc. Everything is alpha software and far from feature
complete.

You might be interested in the following.

http://peter.michaux.ca/article/8579

http://groups.google.com/group/xjs-t...75887cd0970b68

Peter
Oct 31 '08 #5

P: n/a
2008-10-31, 01:59(+01), Erik Hahn:
I'm looking for a standalone Javascript interpreter like the ones of
Perl and Python. Does such a thing exist for Linux?
[...]

$ apt-cache search standalone javascript interpreter
kjscmd - A script interpreter using the KDE JavaScript library
spidermonkey-bin - standalone JavaScript/ECMAScript (ECMA-262) interpreter

--
Stéphane
Oct 31 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.