Tell me more ×
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.

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?

share|improve this question
3  
There is a section on the Javascript Wikipedia article titled "Uses outside web pages", which documents quite a few instances of Javascript used exactly as you describe. Please do some research before asking. – Yannis Rizos Jan 26 '12 at 8:25
3  
Yannis, is there such a rule in SE sites? I think SE aims to be one part wiki as well, meaning that only chatty, off-topic, non-answerable or extremely low quality questions should be closed. – fish Jan 26 '12 at 8:42
2  
@TamásSzelei Actually there is a rule, summarized as "Do your homework". And SE is part wiki, but in the sense that every post is editable by everyone, not in the sense of building a general reference. Jeff Atwood summarizes the "official" policy in this meta answer. – Yannis Rizos Jan 26 '12 at 9:00
2  
@Yannis: I have looked into this topic myself and the resources on the internet pertaining to this subject are severely lacking. Futhermore, I appreciate that the question was asked in a forum where intelligent, knowledgeable members of the computing community can chime in with their experience, opinions, and suggestions. In regards to topics that rely heavily on subjective opinion, I would trust the words of a stackexchange member with 20k rep over a wikipedia article ANY DAY. – ajax81 Jan 26 '12 at 9:19
3  
@ajax81 If there were evidence of previous research in the question, it would have been a perfectly fine question to ask. If you truly value the community as much as you say, I'm certain you don't want to waste anyone's time, and you would have been kind enough to share your research with us and ask only on what is not sufficiently answered in various general reference sites. I'm not suggesting Wikipedia as an alternative to the SE hive mind, what I'm saying is exactly the opposite, we aren't an alternative, ask when Wikipedia is not enough (but please tell us how & why it's not enough). – Yannis Rizos Jan 26 '12 at 9:25
show 5 more comments

4 Answers

up vote 9 down vote accepted

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.

share|improve this answer
I will admit that node.js is generally my first choice for desktop scripting ;) – Raynos Jan 26 '12 at 9:25
@Raynos And we've all noticed :) – Yannis Rizos Jan 26 '12 at 9:40
@YannisRizos I like promoting >_> – Raynos Jan 26 '12 at 10:40
@Raynos Oh, I didn't mean that, but this and more importantly this. – Yannis Rizos Jan 26 '12 at 10:45
@YannisRizos you forgot about this – Raynos Jan 26 '12 at 11:47

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

share|improve this answer

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)

share|improve this answer

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.

share|improve this answer

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.