RFE: Server-Side Javascript?

Martin Dittus · 2005-06-30 · commentary, tools · 6 comments

I just read another rant about the many weaknesses of PHP, and of course I'm in complete agreement. Over the last years I've come to use PHP more often than I would have liked to, simply due to the fact that it's pretty much the only scripting language that is available virtually everywhere; and in contrast to Perl I don't have to look up function calls and the language reference as much, simply because it is closer to what I'm normally using (namely the C languages, and Java).

But the reason I'm posting this is not my urge to awaken old language discussions, but rather an interesting sidenote on the page linked above: Why isn't JavaScript the most popular server-side scripting language? To which my reply is: yeah, why not?

I'm not actually in a position to compare the technical merrits of each of the popular scripting languages available, but I couldn't care less which of them has briefer syntaxes for string operations, better database support, better libraries etc. What I do care about is the amount of time it takes me to get into the zone with the tools I'm using. I'm changing contexts on a regular basis, which means I have to be fluent in a lot of tools, not necessarily in-depth, and the amount of time it takes me to get re-acquainted with a software is directly related to my productivity.

And that's what I like about JavaScript: it's so easy to use, even if you don't use it that often. Everybody who did some web development at some point has at least a remote acquaintance with it, and it's popping up in more and more context so that it should really be the scripting language of choice for everything. We already have it in Flash, where it is named ActionScript; it is available as one of the languages of the Windows Scripting Host which is Microsoft's answer to Apple's AppleScript; and of course it is used in virtually every browser available. It's remarkably close in syntax and language properties to Java and the C languages. It even is an international standard. So why is it not used on the server?

I'm aware that you can already use JavaScript in various Microsoft server technologies, but that's not what I'm asking for. I don't want to depend on a single commercial server vendor to use this. I'm also aware of Whitebeam, but that's not JavaScript for the server, that seems more like an obscure XML-based content infrastructure.

I'm asking for the simple scripting language for everybody, one that is relatively clean, and easy to learn. One that allows me to write small 50-line scripts that process some data and print it. And I don't want to keep using PHP for this. If it's my choice I'd rather not even program my scripts in Perl, Python, Ruby, Java, ASP, or any other of the more popular languages. I'm asking for mod_js.

And while we're at it: could someone please develop a Javascript replacement for AppleScript? One that uses all the right hooks, that supports application dictionaries and is integrated into the OS X scripting environment? This is actually one of the very few things that I miss from the Windows world: OS scripting in Javascript. I didn't actually use it on my Windows PCs, but now that I have a Mac I found the joys of application scripting, and I hate it that I have to use AppleScript. Which, besides the fact that it's damn ugly, for me has the same disadvantage as PHP: I have to look up too many things every time I want to do even small things.

Note: as I'm writing this, the article mentioned above seems to have been remove from Jens' blog. I have no idea why this happened, and neither archive.org nor Google seem to have the page in their caches; but I can direct you to some other reactions instead.

Update: found a great comment on language syntax in an article about Ruby on Rails deployment on the Theobroma blog:

My experience with Cocoa has made me a real believer in the value of reducing ambiguity and syntax complexity. One of the reasons I don't use Perl is that there's just too much special-purpose syntax. I don't object to that because it's hard to learn, but because it's not great when you're looking at someone else's code. I think one of the reasons Objective-C is so effective is that there's very little syntax. If you understand the syntax for one Cocoa app, you understand almost all of them.

Update2: See, I told you so: (via the O'reilly Radar)

It seems every Perl hacker I spend any more than five minutes with these days is neck deep in JavaScript. [...] It's not simply that JavaScript is on the rise in general amongst scripters and non: there's something about innate messiness, ubiquity, and hidden powers that just appeals to those who use Perl.

Update3: Great minds think alike. This is getting more and more interesting.

Next article:

Previous article:

Recent articles:


I just found that the Apache Cocoon framework uses JavaScript to control the application flow; it embeds the Mozilla Rhino interpreter for this. See e.g. http://cocoon.apache.org/2.1/userdocs/flow/using.html

martin, 2005-10-11 14:23 CET (+0100) Link

Since then, Rhinola has seen the light of day, which essentially provides you with the mod_js you've asked for:

You will probably also like Helma, and maybe even OpenMocha:


Chris, 2005-10-29 14:30 CET (+0100) Link

great news! Thanks for this comment, I've had a quick glance and it looks interesting. See http://dekstop.de/weblog/2005/10/rhinola_javascript_for_the_server/

martin, 2005-10-29 17:28 CET (+0100) Link

Although I'm a PHP fan (that's what I've first and mostly learned, and I have a harder time with Javascript, though maybe it is because I have, by necessity, not needed to deal with the DOM and its usual separation of content from script), I do think it would be great to have a unified system to avoid having to learn something new. And it is really puzzling why SSJS is not more popular...

It would in fact be incredible to see an Applescript-like Javascript. For those of us not on Linux (I am guessing Linux must have something like this), having a non-proprietary and ideally already familiar and cross-platform standard would be great. I think this is being approximated though to some degree already with Firefox and its extensions (which use Javascript). I say Firefox instead of Mozilla due not only to the former's greater popularity, but also to my perception of a lack of integration between the components in the latter (which is what a suite would be ideal for). Anyhow, with Firefox, you can access the filesystem (like an OS) and with Theora, Vorbis, and SVG, we're starting to get, I think, to a point where any kind of data could just run inside of Firefox--a (perhaps only temporary) surrogate for a wholly independent system like Linux, and as such, in my judgment, may just have a better chance of becoming a standard, given its potential, due to its infiltration from the inside (i.e., many of us are learning it from within a commerical OS), for weaning away commercial users from proprietary dependency. Now if only XUL would be managed by the W3C (maybe commercial browsers could benefit from it too)

One small point...Although Javascript (EMCAScript) is somewhat internationalized, the European Union isn't quite the world. Why hasn't the W3C taken it on? (With XForms and all, I see they're trying to make it easy enough for people to do without scripting in certain instances, but still...)

Brett, 2006-02-19 06:27 CET (+0100) Link

Also, in regards to Firefox, someone has even done a widgets extension--one more thing seeming more and more like an OS (at least Apple).

Brett, 2006-02-19 06:35 CET (+0100) Link

wxJS provides a mod_wxjs which makes it possbile to use JavaScript on the server.

Franky Braem, 2006-06-30 16:06 CET (+0100) Link

Comments are closed. You can contact me instead.