Why I think AJAX breaks REST

The recent interest in AJAX (or however else people prefer to call client-side applications hosted in web browsers) has made me thinking about its relation to REST. Its current popularity for building Web applications is indisputable since all major players in the Web applications space build and/or experiment with applications that make use of the approach. 

However, AJAX promotes a style of Web applications that, I believe, violates the principles of REST. Still, I haven’t heard any of the REST purists complain. Is this because AJAX “demonstrates” that the architectural superiority of the resource-oriented Web prevails over other styles of distributed application development (e.g. service-orientation)? How come we see attacks against SOAP and the WS-* world and not AJAX-based applications?

The Web is a hypermedia application. According to REST, following a link you should be transferred to a state representation which is associated with a particular URI (in the case of the Web, a URL). As it happens, together with that state representation we may also get some code that our hypermedia document viewer (the browser) executes. Depending on the interactions with the end-user, another program, the environment, etc. the executed code may make use of asynchronous calls to change the represented state that our viewer has loaded. It does so by usually fetching more state, possibly in a REST-friendly way (i.e. HTTP requests). However, during the user-application interactions, the URI remains the same even though the state representation that is rendered on our screens has obviously changed. Now, some AJAX applications may force a change in the URI effectively simulating a state transition but most of the ones I have used do not.

Check Google maps as an example. As you zoom in/out the represented state changes; the client-side application fetches different data as a result of the user’s actions. However, the URL remains constant. You have to follow a specific link on that page in order to get a URL that represents your current state. Surely this is not what Roy Fielding had in mind when he defined Representational STate Transfer. No?

Don’t get me wrong. I don’t disagree with the AJAX approach. On the contrary; I believe that rich client-side applications are very important. Such applications may offer rich interaction models with end-users that can go beyond the ones based on Web page transitions. Information is exchanged between clients and supporting services via asynchronous messaging. Effectively this is a model for Web applications closer to MEST rather than REST (we still need to think of the client-side applications as services in order to fully comply with the MEST principles). I believe that the introduction of XAML and similar technologies will allow us to do even more interesting things at the client side. If you’ve played with Google‘s Virtual Earth you’ll see how powerful is the combination of asynchronous messaging and client applications providing a rich end-user experience.

So, what to the RESTferians think? Am I wrong in my assessment? If yes, then please let me know why. If not, then why haven’t we seen the same level of dissatisfaction against AJAX that we have seen against service-oriented architectures and Web Services?

Recent Posts

Digital Twin (my playground)

I am embarking on a side project that involves memory and multimodal understanding for an…

2 months ago

“This is exactly what LLMs are made for”

I was in Toronto, Canada. I'm on the flight back home now. The trip was…

9 months ago

AI is enhancing me

AI as an enhancer of human abilities.

10 months ago

“How we fell out of love with voice assistants”

The BBC article "How we fell out of love with voice assistants" by Katherine Latham…

1 year ago

Ontology-based reasoning with ChatGPT’s help

Like so many others out there, I played a bit with ChatGPT. I noticed examples…

1 year ago

Break from work

Hi all… It’s been a while since I posted on this blog. It’s been an…

2 years ago