Sign up FAST! Login

Is AJAX dead?

Stashed in: Mobile!, Web Development, The Web, Software!, Awesome, 37signals

To save this post, select a stash from drop-down menu or type in a new one:

I'm going out on a limb by predicting the death of our friend AJAX. She was a good workhorse, but she needs to be put out to pasture. Experienced developers can tell stories about how we were using AJAX before it was named as such. It accidentally became the standard for communicating with the server and updating the html on the client side without a page refresh.

It's a hack, a terrible name (no one uses the X in AJAX, xml, everyone uses JSON, but AJAJ doesn't roll off the tongue as nice), and it's not the right way to do it.

Let's think about the current state of thick-client web development for a minute:

) We use a scripting layer and framework such as Python/Django, PHP/Symphony, or Ruby on Rails to generate HTML to deliver to the client over HTTP. These don't natively speak HTTP, so we have a separate server to handle that.

) We use javascript to listen to events from the user, then construct a request to send to the server over HTTP.

) The server then interprets/deserializes that JSON with the scripting layer, does it's work, then produces a JSON response back to send back to the client, over HTTP.

) Each one of these requests, while they are asynchronous, require a separate transaction, so pushing updates to other user isn't usually done. HTTP long polling is a hacky workaround to avoid the http handshake, but it's suboptimal.

) The client then receives the JSON back, deserializes it, and it must rebuild the HTML using a different templating approach on the client.

This is what front end engineers do all day long. That's just silly. It's an awful lot of serialization/deserialization across different languages. The extra work, CPU (constantly re-establishing HTTP and serializing/deserializing), and number of moving parts is too high.

I think the new approach that will disrupt this paradigm is to use server side javascript (node.js), websockets* as the communication layer, and native javascript/JSON the whole way.


* One language.

* Stop serializing/unserializing javascript/JSON on both sides

* Same templating on both server and client. No more Django/PHP/Rails on one side and then Mustasche/Icanhaz/EJS on the client. Write templates once, and build HTML the same way.

* One language for developers to learn/master. One expertise to hire for.

* Lower overall CPU usage.

* Less moving parts (node instead of Apache + Scripting Layer)

* Less data munging

* Templating on the *client* side

* Async/Event driven approach scales better

* Websockets are a stateful connection, so updates can easily be pushed to users when updates happen.

* Javascript's event driven model makes more sense for highly interactive web pages; theoretically easier to scale. Note: Has anyone seen node.js in a high scale production environment?

This framework Meteor is on the right track, they use a combination of web sockets (unconfirmed), native js execution, backbone.js for managing the models. Check out the screencast to see it in action., and to see what's possible when this paradigm is implemented.

What's in the way of this happening?

* Node.js is still immature, and Operationally it's not production quality

* The frameworks for node.js are still immature. Connect / Express are the current leaders. The community is fragmented and seems to have attracted a lot of the Rails community.

* Event driven programming is hard. My brain doesn't think that way intuitively.

* Browser support. Not all browsers support web sockets. Comet is the best way to gracefully degredate for those that don't. Socket I/O also eases the pain.

* A retraining of stodgy old web developers like us :)

Other opinions and insights appreciated.


Reading: # the best server side javascript platform # popular http framework for node.js # a javascript templating layer that works both client and server

AJAJ could be rebranded as JSON And JavaScript Asynchronously -- JAJA!!

No matter how you slice it, it's all Web.

You might enjoy this (pre-AJAX) post I wrote in 2004 about what I called Weblications:

What was true then is even more true now. The Web is a ring that binds them all.

We could also call the New New Thing AJATT -- All JSON All The Time.

As we build the iPhone version of PandaWhale I'm noticing that all data produced and consumed is JSON.

That's the trend, and it is our friend.

There's also the way known as JAH or AHAH - Just Async HTML

JAH has actually been around for a very long time.

And will be around for a very long time. :)

You May Also Like: