Check out my
new book!
HTML5 Games book
AppJet, Server-side JavaScript and YouTube Annotations Whenever I've needed something small done on the server-side, I've always ended up with PHP since I know it, there's no setup and it can do a whole bunch of stuff. I just don't enjoy writing PHP in any way and I just wish I could do stuff on the server with JavaScript as easily as with PHP. Last time I went looking (long time ago) there wasn't really any options that looked good enough but it seems that things have changed a bit. There are more than a few server-side JS solutions available today, but two of them struck me as interesting even if they were not exactly what I was looking for. One of them was AppJet which launched its service late last year. What it does is let you write your server-side JavaScript application in a simple online IDE and then host it at http://<appname>.appjet.com/ all with just a few clicks.

I wouldn't attempt to put the next Facebook or Twitter on AppJet, but for the purpose of writing small and simple applications on the server in JavaScript, I think it's just awesome. The small app I wrote (click the "source" link at the bottom to view the source) to test it out is a proxy of sorts for the YouTube annotation script I posted a few months ago, and it was quite a pleasant experience due to the very short path from idea to actually seeing something happen. AppJet has of course all the needed JavaScript functionality and also provides a few extra features like persistent storage and HTTP access. Nothing really impressive, but there's also a directory of user written JS libraries that you can import to add more functionality. Anyway, this YouTube annotation application simply retrieves the XML from Google's server, converts it to JSON data and either spits it out raw or calls a specified callback function. I've modified the proof-of-concept YouTube annotation player to use this instead of the PHP proxy it was using earlier, simplifying the client-side JS a lot.

The other SSJS solution I've been looking at is Aptana Jaxer which is something entirely different. I have only just gotten it up and running, but I hope to get time to take a deeper look at it when I return from a bit of vacationing in Paris next week. If you have any experience with any of the server-side JavaScript options, please leave a comment and share your thoughts!
⇓ 13 comments pedro

// just to let you know -- the example links at json-ytann.appjet.net need a small correction, prefix them with "json-"

August 2, 2008 at 7:48 AM
Jacob Seidelin

Ah, you're right. Thanks.

August 2, 2008 at 8:59 AM
Anonymous

Thanks Jacob for pointing out AppJet. I found something very similar a while back, but totally forgot what it was called. I think it's a great way of building small server-side JavaScript apps.

I thought Jaxer was great too. From what i have been able to tell, It's just like writing JavaScript on a normal HTML document, except you can run some bits on the server. Unfortunately i haven't found any service provider which explicitly supports Jaxer, so unless you are making some serious, new, money making Web 2.0 app then i wouldn't consider it. Not to mention the "script at" stuff looks a bit odd.

Another solution which i suggest you check out is haXe. It's an ECMAScript / ActionScript / JavaScript-2.0-like language and compiler which outputs to JavaScript, Neko, Flash, and even PHP. You can write server-side stuff with it, and it's even been used in a few commercial web games. I've not stress tested the server-side stuff on it though, so for all i know it might fall short.

Generally speaking, writing everything in JavaScript seems like a great idea, but you still have to deal with Client <-> server interoperability and such.

August 2, 2008 at 9:45 AM
Jacob Seidelin

james: Please let me know if you remember the name of that other thing. While AppJet is cool, there are a few things that could be better (libraries could be better and the global scope is way polluted, ..)

Yea, I looked briefly at hosting options for Jaxer and the only thing I found was a post on their board about hosting on Amazon EC2, and if I understand the pricing for that, it's just too expensive for the kind of hobby stuff I'm doing here.

I'll have to take a look at haXe some day. Maybe after I've played around a bit with Jaxer.

August 2, 2008 at 10:05 AM
richtaur

AppJet looks cool but the idea of someone else hosting (and therefore owning) my code is unacceptable to me... which makes me feel like a hypocrit because I'm working on the Yahoo! Application Platform. :P I guess it's not that simple. Still, I'll be looking into Jaxer before Appjet.

August 2, 2008 at 10:34 AM
Unknown

Agreed. AppJet is underrated and it almost seems like there is an intentional media blackout.

August 4, 2008 at 5:02 AM
Kevin

Appjet doesn't own your code when they host it. You retain the rights to it, although anyone can see the source.

August 22, 2008 at 1:16 PM
s|mono

http://www.helma.at

it does JS serverside and you have full access to any java library you might want to use (it's using rhino, a JS interpreter written in java).

i've done a couple of projects with it - appjet looks very similar

August 29, 2008 at 4:23 AM
Anonymous

Maybe I'm missing some requirement that you stated and I just plain missed it. But why not use mod_js or if you want to run server-side js like perl cgi of yore, get the Spidermonkey stuff from mozilla.

...maybe the requirement is that you don't have access to the server??

August 30, 2008 at 9:23 AM
Jacob Seidelin

@simonO: Thanks. I had heard mention of Helma but haven't looked into it yet. I must do that.

@anon: mod_js is nice but from what I understand it provides nothing other than core JS, no extra libraries or anything. PHP, horrible as it may be, has lots of functionality in the builtin libraries and extensions (http://www.php.net/manual/en/funcref.php). Jaxer provides some standard, needed things like DB, file and socket access, and Helma looks like it also has everything you need through Java libs.

August 30, 2008 at 9:41 AM
Anonymous

Jaxer has HUGE backing, both commercial and free and open source, so I would imagine it is going to replace anything for all you Javascript freaks out there, that must program everything (even server side) in javascript. (geeez, why so anti PHP?)

Although, there are no hosting ( or none that I know if ) that host jaxer, why not get a cheap virtual dedicated server? It is like having a dedicated server, but is virtual, so conciderably cheaper.

Since all of this is 'hobby work', the need for a huge server able to handle millions of hits a day is not needed. Although,renting a dedicated server, optimized can handle such loads for only $100 a month.

I see some amazing, 'experiments' here with javascript. The potential to replace (or attempt to) FLASH, as to keep it Free and Open, is certainly there.

November 25, 2008 at 1:54 PM
Jacob Seidelin

Yes, Jaxer does look like it has a lot to offer but the lack of hosting really bugs me. I guess I'm just spoiled with PHP being almost universally available (see, it's not all hate :-)).

November 26, 2008 at 1:36 PM
Cref

Need to run serverside javascript?
Every Windows installation has the Windows Scripting Host (WSH) on board which is used to execute scripts. If jou have JScript.dll (comes with IE and IE comes with Windows :) ) you can run stand-alone javascripts, Windows Scripting Components (WSC) and use serverside javascript on IIS through ASP with language="JScript". The most recent version of JScript is 5.8 which is part of IE8 and this is roughly the equivalent of JavaScript 1.5.

March 3, 2009 at 9:14 AM
Post a Comment