views:

2102

answers:

11

In terms of quick dynamically typed languages, I'm really starting to like Javascript, as I use it a lot for web projects, especially because it uses the same syntax as Actionscript (flash).

It would be an ideal language for shell scripting, making it easier to move code from the front and back end of a site, and less of the strange syntax of python.

Is there a good, javascript interpreter that is easy to install (I know there's one based on java, but that would mean installing all the java stuff to use),

A: 

In my years I've found most Javascript developers find it quite easy to transfer over to PHP and vice versa - it isn't a direct answer to your question, although if you're working in ActionScript and JavaScript then you're best to stick with something like PHP (if you're not willing to move to Java, and stick with the ECMA base)

d2kagw
+1  A: 

Google's V8 can be used as a standalone interpreter. Configuring with scons sample=shell will build an executable named shell, that can be called like so: ./shell file.js.

William Keller
+4  A: 

There are four big javascript interpreters currently. V8, Squirrelfish, Spidermonkey and Rhino. I think more important than performance is how well it integrates into existing infrastructure, and I guess Rhino with its bridge to Java wins here.

Armin Ronacher
+6  A: 

Of course, in Windows, the JavaScript interpreter is shipped with the OS.

Just run cscript or wscript against any .js file.

Frank Krueger
+1  A: 

You'll need some server-side JavaScript interpreter. Check out the following blog post. Something such as Rhino might be useful for you.

+3  A: 

Try jslibs, a scripting-focused standalone JS runtime and set of libraries that uses SpiderMonkey (the Gecko JS engine).

skymt
FYI, now jslibs uses tracemonkey, the latest JavaScript engine of firefox.
Soubok
+1  A: 

You might try toying around with SquirrelFish or v8, both should be runnable on the command line.

Florian Bösch
A: 

FYI, there is a built-in one already on modern windows platforms. You need to use JScript, but it's close enough. Same environment also allows for VBScript. To run a program you can execute something like:

cscript foo.js

The windows system API is a bit weird and frustrating if you expect the same flexibility as with basic JS objects, but they do have thorough documentation if you can handle digging through the MSDN pages and seeing all the examples in VBScript.

Not sure what's available for Linux/Mac in terms of js shell.

Glenn
+5  A: 

I personally use SpiderMonkey, but here's an extensive list of ECMAScript shells

Example spidermonkey install and use on Ubuntu:

$ sudo apt-get install spidermonkey
$ js myfile.js
output
$ js
js> var f = function(){};
js> f();
Zach
A: 

On the 'easy to translate' theme, there's also Lua.

It's somewhat similar to Javascript, but more 'orthogonal' (closer to functional roots).

The heavy orientation to 'pure' programming theory has made it really small and fast. It's the fastest scripting language around, and the JIT runs circles around the new JavaScript JITs that are starting to appear.

Also, since it was originally thought as an extension language, it has a very nice and clean interface to C, making it very easy to create bindings to any C library you might want to access.

Javier
A: 

Well, for safety reasons, javascript had not been provided with file access right by design. So as a scripting language, it's a bit limited.

But still, if you really want to, spider monkey is your best option. Here is a tuto :

http://developer.mozilla.org/en/Introduction_to_the_JavaScript_shell

e-satis