TrimJunction: JavaScript on Rails

Martin Dittus · 2005-09-24 · links, tools · 6 comments

In June this year I started looking for ways to use JavaScript as a server-side scripting language to replace Perl, PHP and others, and documented my findings in the article "RFE: Server-Side Javascript?". Although all the pieces to bring JavaScript to the server are there, nobody has actually undergone the effort to implement it yet; but it seems there are more and more people interested in trying it, and I guess by this time next year we'll have some stuff to play around with.

The reason I'm posting again is that I just found another related project: TrimJunction, which is a port of the Ruby on Rails framework to JavaScript. Regardless where you stand regarding the current RoR hype and successive attempts to port the framework to other environments (Python has some of these clone projects too), at least it shows that there are people interested in using JavaScript for more than browser-side form validation. I still believe that JavaScript would make a perfect lingua franca of the web, and any attempt to bring it to the server is to be applauded.

If you have some basic knowledge of Ruby on Rails the comparison of Ruby on Rails and JavaScript on Junction syntaxes can serve as a quick overview of what they are trying to achieve. They also have a demo that runs in the browser and that is sort-of working (it's throwing JavaScript errors in Safari, but apparently Firefox works fine).

But it currently looks like they are solely using their framework for client-side scripting, and plan to add server-side deployment at a later stage. Quote from their site:

A Junction-based web application should run, validate input, process data, generate output and do its thing on both the server AND the client. We intend to use the Rhino JavaScript runtime for the server and use your favorite, modern web browser for the client.

I'll now start looking for people who have used Rhino or SpiderMonkey on the server, and maybe I'll install Rhino locally to play around with. (Both are Mozilla projects that provide JavaScript runtime environments; Rhino is implemented in Java, SpiderMonkey in C.)

Anyway, watch the TrimPath blog for updates on TrimJunction.


Next article:

Previous article:

Recent articles:

Comments

i'm not really convinced. i'm doing a lot of javascript programming these days and i'm very frustrated that it's become the standard programming language for web clients. there are multiple ways to do everything (e.g. oop). some really handy things (like associative arrays or abstract classes) don't exist, you have to cheat to come up with something similar. also, i can't seem to find one good information resource for javascript. it's scattered all over the web. javascript is a mess.

also, the power of server-side scripting, in my opinion, does not lie in the programming language itself but the tools that come along with it. which is probably why php became so successful. it offers pretty much everything i need to do server-side programming (http-processing/requests, mail, xml, file/db i/o, lots of string processing, ...).

oriba san, 2005-09-27 18:19 CET (+0100) Link


I usually use this as a reference, never bothered to look for an alternative: http://de.selfhtml.org/

Another option is the EcmaScript language reference, but that's a PDF file.

I wasn't aware that there are no associative array in JS, started searching, and still don't understand what you are complaining about: http://en.wikipedia.org/wiki/Association_list#JavaScript

Yeah OO in JavaScript/EcmaScript is an afterthought, but I still think JS is easier to learn and more readable than Perl ;)

martin, 2005-09-28 04:04 CET (+0100) Link


well, if perl is the general reference...

selfhtml is probably the most comprehensive reference i've seen but still has the coverage of a swiss cheese.

associative arrays is just one example, i could name more. and, yes, you can do it but you use Object which is not really an array so you're basically cheating.

oriba san, 2005-09-28 14:16 CET (+0100) Link


;)

Still don't get why you have a problem with JS hashes. For basic usage it looks just like the hash table syntax of other languages, and you don't need to know that you're actually using Object properties and not a dedicated data structure.

But I get your point. I haven't done bigger JS stuff in a while, but I remember more than one occasion of scratching my head over some of its characteristics. Still, I think it has improved a lot (-> regexes, iterators, etc).

And yeah not having a standard library for file I/O, net access etc is a problem, but if you use Rhino as the JS interpreter you can simply make use of the Java framework: http://www.mozilla.org/rhino/ScriptingJava.html

You comments make me realize that I haven't thought much about the specifics (e.g., how can you import code modules with standard EcmaScript?), but still, I think it's a great scripting language. I don't want to replace Perl (I would love to replace PHP though ;). But I simply would like to have the option of using a widely known scripting language in an additional context.

You can use it in web pages, you can use it to script the operating system (on both Windows and OS X), and there are lots of applications that use it internally (Flash being the most prominent). I don't see why you should be able to use it everywhere except as a server scripting language.

martin, 2005-09-28 15:05 CET (+0100) Link


i just thought of something. maybe one could create a framework where there is no difference between the client and the server. like: you have access to the html dom but at the same time you have access to the server file system or some database (or other functions). before deployment, the framework will decide which parts of your code lie on the server and which ones lie on the client. communication between the client and the server will not be of interest (the framework does this). maybe something like this already exists, i don't know. but that would be pretty cool anyways.

martin, is there a feed for the comments?

oriba san, 2005-09-29 16:20 CET (+0100) Link


forget my last question...

oriba san, 2005-09-29 16:20 CET (+0100) Link


Comments are closed. You can contact me instead.