Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

It seems to me it would be very useful to use Javascript for general server side scripting tasks as it has more or less the same features as Perl and Python. But AFAIK there are no generally available Javascript interpreters for the major machine architectures. I guess the other problem may be lack of libraries but surely these would come if the interpreters were there. Google's V8 maybe could be a starting point. Does anyone think we'll see this soon?

share|improve this question
1  
And by the way: almost no one "interprets" JavaScript these days, pretty much all browsers compile it into native code just in time. –  Joachim Sauer Aug 27 '12 at 7:27
2  
In a sense there is an interpreter in Windows - see Jscript. It's not exactly Java Script, but it's close. –  nhinkle Aug 28 '12 at 3:44
1  
Sounds of things indicate Windows 8 will have just that to some degree built in since you can build JS apps for native desktop use. –  Rig Aug 28 '12 at 12:52

5 Answers 5

up vote 65 down vote accepted

Node.js is exactly what you're asking for ... and more.

In addition to being a JavaScript runtime it also provides APIs for common operations, such as file system access (JavaScript on the browser doesn't really need that) and network IO.

It's marketed for building network application (and it's great at that!), but it's really a general purpose JavaScript runtime that you can use to build anything you want. Also, it is based on V8.

share|improve this answer
1  
Huh, yeah I only thought of node as for network apps as they are clear from their homepage on out that that's what it's for. –  MebAlone Aug 27 '12 at 7:40
5  
@MebAlone: that's their main purpose, true. But node.exe (or just node on Unix-y platforms) is basically a simple JavaScript runtime. node myJavaScript.js runs myJavaScript.js and what more do you need from a runtime system? (Ok, you need debugging and libraries, but Node.js has those covered as well ;-)). A good indication for this is that many projects use JavaScript scripts (run in Node.js of course) as their build system. –  Joachim Sauer Aug 27 '12 at 7:41
    
nice, thanks :-) –  MebAlone Aug 27 '12 at 7:57
1  
NodeJS runs on Google's V8. You can use V8 to do whatever you want. So even if NodeJS isn't a fit for you V8 might be. –  Andrew Finnell Aug 27 '12 at 12:19
1  
@Andrew: from what I know V8 doesn't ship any binaries, only source. So you'd have to build it yourself (or find third-party binaries). If you don't care about node, it's very easy to just ignore the libraries and use node as a pure JavaScript runtime. I don't see how you can do that with equal ease with V8. –  Joachim Sauer Aug 27 '12 at 12:28

There is a javascript interpreter written for Java apps (called Rhino) and it seems to be designed to write server code in javascript, but have it execute as java code.

Personally, I think you're much better off with node.js as that is awesome. For a quick introduction, you can do much much worse than read the (free) NodeBeginner book.

share|improve this answer
    
For completeness' sake: Rhino does not make Javascript execute as Java code, it's a Javascript interpreter, i.e. it executes Javascript in a JVM environment. Of note is that it's not very fast, compared to more low-level interpreters like V8. –  Cthulhu Sep 9 '12 at 12:50
    
good free book. –  Andrew_1510 Sep 15 '13 at 4:35

In addition to node.js, there is also gjs, which is a GNOME-oriented runtime giving access to GNOME, GTK, and GLib libraries, among others. I believe you can use with it any library that supports GObject introspection.

Gjs is used widely in the GNOME3 desktop.

share|improve this answer

As mentioned by Joachim, node.js is exactly what you ask for.

It appears to not be well known when compared with Python and especially Perl for this type of thing, but perhaps that is simply because JavaScript isn't widely considered to be very good.

enter image description here

share|improve this answer
47  
+1 for the awesome photo :D –  sevenseacat Aug 27 '12 at 11:31
2  
The Good Parts make up for all the other things Javascript has going on... that and CoffeeScript. Oh CoffeeScript! –  Spoike Aug 27 '12 at 12:40
3  
+1 for the Kinect on a stack of books. I have the definitive guide sitting under my monitor to raise the monitor height a little bit. –  Phil Aug 27 '12 at 13:35
2  
-1, despite the funny photo, this answer is essentially a fancy way of saying 'cuz it sucks', and doesnt really contribute anything. –  GrandmasterB Aug 27 '12 at 18:13
3  
No, that's not what he's saying at all. –  Kyle Aug 27 '12 at 19:06

Windows Script Host has included a JScript (javascript) engine since at least Windows 2000 out of the box, allowing you to do sysadmin tasks using javascript.

http://en.wikipedia.org/wiki/Windows_Script_Host

It's also possible to embed this into a windows application using the WScript.Shell ActiveX/COM object.

share|improve this answer
    
ah, very cool ! –  MebAlone Aug 27 '12 at 21:14
3  
WSH also lets you use a number of other scripting languages (like vb); and if I'm not mistaken more can be installed (en.wikipedia.org/wiki/…). You can also use it to script other windows apps, like media player, word, etc. –  frozenkoi Aug 27 '12 at 22:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.