Google apps
Main menu

Post a Comment On: Quinthar

"Christmas Wish: ServerSide JavaScript"

3 Comments -

1 – 3 of 3
Blogger Curtis Chambers said...

I'm not sure if this is exactly what you mean, but I remember reading awhile back about GWT (Google Web Toolkit). I've never actually used it, but from what I hear you basically write all your code in Java, and it compiles into optimized, cross-browser Javascript. Basically it allows you to build and debug an application with a true IDE and programming language, then just plop the generated Javascript into your site.

Actually, now that I've read about it since starting this comment, it's not at all what you need, but still kind of a cool concept. I guess they built GMail and Google Reader with it. Anyway, here's the page about it and a sample Mail application built with it:

GWT
Mail sample

9:53 AM

Blogger Tyler Karaszewski said...

This seems like it might be the best thing that's currently available, but the JS interpreter is in Java.

http://appjet.com/download

I haven't tried it yet, but I keep hoping that someone will come along and do this well. I've considered doing it myself several times, based on the Mozilla SpiderMonkey JS interpreter.

9:52 PM

Blogger David Barrett said...

Wow, AppJet is pretty cool, but not quite what I want. It looks like a slick PHP replacement, but it still seems to emphasize manually writing the HTML response with a series of print statements.

For example, in the sample code, the "storage" and "StorableObject" objects only exist in the serverside JavaScript engine. The HTML response sent to the browser doesn't even contain a single line of JavaScript, not to mention these objects.

What I want is something that automatically captures the state of the serverside JavaScript engine and serializes it to the HTML response such that when the browser reads it, the clientside JavaScript engine is initialized to the same state the serverside engine finished with. This provides a sort of seamless portability where the code you write for the server *is* the code you write for the client.

Anyway, it actually seems rather straightforward to do what I want -- there must plenty of open-source JavaScript engines that could be encapsulated for serverside use. And if we can use the exact same engine as is actually in the browser (perhaps the Firefox JavaScript engine), all the better.

Furthermore, the serialization format is really quite straightforward: at the end of the serverside script just iterate across all global JavaScript classes objects and spit out as JavaScript. Then call the "onload" handler when done.

2:55 PM

You can use some HTML tags, such as <b>, <i>, <a>

This blog does not allow anonymous comments.

Comment moderation has been enabled. All comments must be approved by the blog author.

You will be asked to sign in after submitting your comment.