Monday, January 23, 2006

Why AJAX was hard

WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.


I just listened to
episode 12
of the Ajaxian podcast, where they interview Thomas Fuchs of Scriptaculous. In it they talk a bit
about how after the AJAX craze started, Microsoft and others came out
and said building AJAX is for rocket scientists. Thomas rejects that and states that it's trivial - it's just a call to a server.
I'm one of the people who came out and said that AJAX is hard - in fact I said it
during the keynote demo at JavaOne where I showed Creator's AJAX
support. So, I thought I'd clarify why I said it since at the time it was clearly true.



AJAX applications typically consist of asynchronous server trips (via XMLHttp), CSS, XML,
and JavaScript. It's the JavaScript which makes AJAX hard. JavaScript itself is easy - the
problem is with the browsers.
Even during the interview, Thomas talks about how Internet Explorer
has issues - they have all kinds of hacks in place for IE, sending a separate CSS stylesheet
to it to deal with quirks and so on.



In my own AJAX work, I quickly discovered that while it was really easy
to get the component to work well on Firefox, getting it to work on
IE was harder. Getting it to work on both was harder still. And then
throw in the fact that Safari has its own quirks. Even Mozilla 1.1 and
Mozilla 1.4 behaved differently in the kind of JavaScript code I was
writing. And when you add a workaround for one you've gotta make sure
it doesn't break the others. On top of that, even if Firefox has a decent
JavaScript debugger, that doesn't help you when the bug only shows up
in IE (or Opera, or Safari, or Konqueror, ...).
You also need to be well versed in browser bugs such that you for example
know to avoid the memory leak issues you can run into with IE.



THIS is what I meant by "AJAX is hard". No, asynchronous is not hard.
XML is not hard. CSS is not hard. It's cross-browser stable, performant
JavaScript that is hard.



So why am I using past tense - "AJAX was hard" as opposed to "AJAX is hard" ?
The reason for that is that a number of great cross-browser JavaScript libraries
are emerging. These have done most of the hard work for you. I still strongly
believe that a library approach to AJAX is not enough - you really want components
that do all the AJAX plumbing for you as well. I'll have more to say about that soon.


3 comments:

  1. hi tor,


    welcome back! hope things are ok with you.


    With webwork's latest release touting new AJAX features, rubyOnRails's support for AJAX(through prototype and script.aculo.us) and hopefully spring/DOJO's combination, we should be in pretty good shape to develop, debug and ship AJAX apps in 6 months.


    BR,

    ~A

    ReplyDelete
  2. Hi Tor,
    Wishing your son a quick recovery!
    Haroon

    ReplyDelete
  3. Hi Tor,
    The Scriptaculous etc. libraries are definitely making this area easier, I'm really interested to see how this plays out. One thing that concerns me is whether the component approach of JSF will lead to a "mess" of Ajax components that don't play well together - for example, if component A wants to incorporate prototype 1.3 and another wants to incorporate prototype 1.4 etc.
    I'd love for you to cover these potential issues in your future comments on this topic.
    Thanks,
    Chris
    PS - I'm guessing that Thomas' comments in the podcast regarding Java being "too hard for anything" caused a smile ;-)

    ReplyDelete