Browse by year:
A word about the 'richness' of AJAX
Sandeep Dasgupta
Tuesday, October 2, 2007
Rich Internet Applications, or ‘RIA’ as it is more commonly known, is the new buzzword in the Web technology world. What then is ‘rich’ web application?

I am sure, those of you who are familiar with it begin to think, “Oh no, not another explanation of RIA and AJAX!” Fear not. We will not be discussing the technology and its explanation here. There is enough documentation available in the form of books, web pages, and forums to help anyone learn this technology, so that should not be a problem for someone wanting to know more about them. Rather, we will discuss about the need, the typical use, and the future of this technology.

AJAX – The evolution and need
AJAX is short for ‘Asynchronous javascript and XML’ and is essentially a mix of three main ingredients – javascript, XML, and the most important one, the asynchronous HTTP call. All you have to do is write some javascript code to communicate with the server in asynchronous mode using XML message payloads and voila, you have a powerful new way of writing web applications!

I know a lot of readers will be surprised to know that though AJAX has become popular in fairly recent times, neither the concept nor the technology are new. Readers familiar with IIS and ASP will know that this concept has been around in the Microsoft web technology for quite some time now. But it was restricted to the Microsoft world, and was only supported by Internet Explorer, thus reducing the usage and awareness about this in the web community.

It was the usage of this technology by popular websites like Google, and the quite recent support for this by all the common browsers that really propelled this technology to the forefront. You might have come across a customer who has looked at ‘Google Maps’ and wants the website you are building for him to have the same interactivity and responsiveness, thus driving the demand for such RIAs. It is purely a case of the bar having been raised, and now every self-respecting web application needs to take this technology seriously, unless it wants to be relegated to the class of old-style web applications.

So what is this ‘richness’ that we are talking about? All you have to do is visit either ‘Google Maps’ or ‘Yahoo Mail beta’ to see for yourself what I am talking about. In Google Maps, parts of the screen refresh themselves independently of others; you can place markers and see pop-up windows come up to show more information about a location. Yahoo Mail beta looks almost like Microsoft Outlook! You can drag and drop items across folders, do previews of folders, and see the unread count refreshed automatically.

Actually, the best way to describe ‘rich’ applications is that they are very close in look-n-feel and in their responsiveness to desktop applications. The users can see parts of the screen update independently, and the whole screen need not be refreshed or reloaded.

In the days before RIA, this was possible only through applets that got downloaded to the client machines. This did give the necessary richness to the interface, but also had its own problems with security, portability and non-intrusiveness, besides the fact that this made the client very thick. AJAX has gone a long way in making similar user interfaces possible in a thin client.

Writing AJAX applications – how is it different?
Well, if you have been coding in the time-tested html world, you may think that AJAX is just another way of doing the same. Not really. Firstly, javascript itself is unfamiliar to many web programmers coming from the html world. Learning and mastering javascript is the first step towards AJAX, since this is quite different from html and is a powerful language by itself. Next comes the whole business of getting used to the asynchronous request-response mode of communication. Sure, it is great to be able to fetch the data as the user is typing and “auto-complete” entries change one part of the screen based on data in another part and do validations on the fly. However, this also brings in the additional complexity of managing multiple simultaneous asynchronous requests and responses, with no guarantee of the order of responses. This may lead to problems unless an effort is made to ensure that the interface does not presume certain responses arriving ahead of others. For example, if we request for some data during the initialization of a frame, thinking that the rendering and display would be quicker that way, we may find that the frame is getting displayed even before the response comes back with data, leading to weird results!

Another thing to keep in mind is that interactivity is great, and a rich user experience is worth a lot, but all this come at a cost – the time required to fetch and display all these graphics and textual effects. Therefore a balance must be achieved between the richness of the interface and the amount of data fetched and rendered on the screen.

It is also important to remember that the power of javascript makes it possible to build-in a lot of processing and logic into the client itself. Just like everything else in life, this can be both good and bad, depending on circumstances. It is very useful in doing complex client-side validations and calculations but, on the other hand, it can be dangerous if sensitive and confidential logic is put into this layer, since this is easily visible on the client browser, and can be misused. Therefore, business logic built into javascript should be given careful consideration for appropriateness. Of course, this specific aspect of javascript is not limited to AJAX, but is actually a common problem with all client-side scripting.

Alternatives to AJAX
Of course, AJAX is not the only way to create RIA. Options like Flex and .Net are equally powerful and noteworthy. The major difference is that AJAX comes from the open source world, while the others are still primarily licensed, proprietary products. But in cases where there is a need for an extremely rich set of widgets and components, Flex and .Net may prove to be more apt than AJAX.

All in all, AJAX and RIA are new waves to hit the “web” world, bringing in a breeze of fresh air, and answering the prayers of users wanting the usability of a desktop application coupled with the portability of the web application. Things can only get more interesting from here, and we can look forward to many more intelligent, interactive, and adaptive applications on the web. Think what it could do to the way information is viewed and manipulated on the web! And while you are in the thinking mode, do give a thought to what it could do to your career prospects and market value! So, if you belong to the web development fraternity, this is one technology you cannot afford to ignore. Go ahead, put your RIA hat on, and prepare to ride this new-age technology wave!

The author is Senior Engineering Manager, Tavant Technologies. He can be reached at sandeep.dasgupta@tavant.com
Share on LinkedIn