JavaScript as a Scripting Language

JavaScript is an impressive language. Unfortunately, today its power is limited to the browser. That's the only area where JavaScript is used seriously. Fortunately, this trend is changing. We are beginning to see serious server side javascript implementations - like Rhino on Rails.

Scripting Languages

I work on Linux - so I write a lot of 'throw-away' scripts. They are scripts that you write when you want something done once. You write it, run it and then throw it away - you will not need it again. When writing such scripts, the most important thing you are looking for is writing speed - which made Perl a perfect candidate. But for some scripts(like those that involves screen scrapping) javascript might be a better choice.

I write a lot of automation scripts too. Those scripts require maintenance since you will be using them more than once. I have used a lot of languages to code these scripts - Perl, Python, Ruby, PHP, bash and more. And if they have any GUI part, Tcl/Tk or PyGTK or something like that.

I have not used javascript for either of these uses. I want to change that.


Rhino is an open-source implementation of JavaScript written entirely in Java.
Rhino: JavaScript for Java

To run JS files, the 'custom_rhino' by Dojo is the easiest solution.

Before anything, you must have Java installed on your system for this to work. If you have Java, download the custom_rhino.jar file from Dojo Server. Now you can execute you javascript files using the command...

java -jar /usr/share/java/rhino.jar test.js

I created an alias for this command - so in my system this will be enough...

js test.js

I still have not made any scripts using it - but I am searching for an excuse to take it for a spin.

I am still looking for a way to read and write to a file in this implementation - I still don't have anything on it. Server side javascript functionality is not working. If anyone has an idea, please let me know.

Related Links

blog comments powered by Disqus