19

I've used JavaScript and some frameworks (jQuery, Prototype, some node.js) for client-side web programming, but never on the desktop, where I do most of my scripting work in either Python or Bash.

But IMHO, JavaScript would make a great scripting language if used outside of the browser. Has anyone tried this? Can JavaScript be an adequate replacement for Python/Perl/Bash for quick and dirty scripting tasks?

rdasxy
  • 3,343
  • 7
  • 31
  • 41

6 Answers6

23

Yes! You definitely can do that with Node.js or Rhino. For example the coffeescript compiler is nothing but a node.js script.

I will admit that it is not generally my first choice for desktop scripting but I see no reason why it would not work quite well for a number of tasks.

Zachary K
  • 10,413
11

Windows has a component called Windows Scripting Host that allows you to automate administration and even mimic user activity to some extent through JScript.

Update in 2017: OSX now allows you to automate desktop tasks with Javascript. What was previously possible through AppleScript is now possible through Javascript.

rsman
  • 1,309
6

I use javascript mainly for everything because I like it and my daily job is heavily influenced by it. Now what do I mean by saying everything:

  1. Custom tools(with node-webkit you are able to bring desktop experience)

  2. Custom scripts to run on my machine via node.js

  3. Mobile apps. I don't even need PhoneGap as I am pretty comfortable with visiting URL.

  4. Backend for my web apps with node.js . I can access filesystem and databases so what am I lacking? Well.. A mature enough framework and I hope this will be fixed in the feature.

  5. Well of course fancy jQuery stuff for websites.

Misc:

  1. I solve all the coding katas with javascript(project euler, codewars)

  2. I implement algorithms I am interested in Javascript

  3. 3D experiments with three.js and webgl.

Someone will beat me because of performance but I want to satisfy performance of writing code and understanding a topic instead of making it run blazingly fast.

And as for desktop experience, for me working with HTML and CSS for user interface is the most pleasant way.

4

Qt offers QtScript. Wikipedia said:

QtScript is a scripting engine that has been part of the Qt cross-platform application framework since version 4.3.0.

The scripting language is based on the ECMAScript standard with a few extensions, such as QObject-style signal and slot connections.[1] The library contains the engine, and a C++ API for evaluating QtScript code and exposing custom QObject-derived C++ classes to QtScript.

If you don't know what Qt is: It's a cross-platform application framework in C++. It is good in taking complexity out of C++ front-end development, and is also supported on mobile systems. It has been long ago since I last developed with Qt but I liked it.

With QtScript I could imagine that one writes a minimal GUI and does the application logic in JavaScript.

nalply
  • 257
  • 2
  • 9
0

If you're just talking 'purely outside the browser' then look at tools like Appcelerator and Servoy, both of which use Javascript for coding, which ultimately gets turned into Java.

Alan B
  • 436
-1

I am using JScript.net right now to create an intelligent command line interface. Its working out pretty well for this project because eval() comes in handy, but not everything works as you expect (its not pure js). But it does offer some RAD. I think it would make a good prototyping platform. Its kind of weird being in a no-mans-land between js and .net though. (Its obsolete too, so hard to find good resources on it)

Mark
  • 336