We’re having an internal discussion on the editor’s list about JavaOne news and mood, and there’s a thread on AJAX that I think is remarkable because it’s based in profound misconceptions. I’m disagreeing with everyone here, first with two of my bosses, and then with the community at large, so let’s take those in order.
I reported on list that one of the themes we heard from a couple of people on the pavilion floor was that “all you guys care about anymore is AJAX.” One of the replies on-list was that the AJAX revolution is passing Java by, and that “I’d love to see those Java programmers stop disparaging Ajax and figure out how to feed into it (as google is doing.)”
Frankly, the “as Google is doing” isn’t nearly strong enough. It looks to me like the enterprise Java community is wildly behind AJAX. Consider some of the following projects, all of which have large followings:
- Google Web Kit — surely the story of JavaOne 2006, this remarkable framework allows you to code in Java and emit JavaScript and HTML. Google calls it a “Java software development framework that makes writing AJAX applications like Google Maps and Gmail easy for developers who don’t speak browser quirks as a second language.” Cooper blogged on this, and I hope to get an ONJava article from him about it as soon as possible.
- Java EE blueprints — this “best practices” project from Sun has been positively obsessed with AJAX lately, offering up a set of plug-and-play AJAX components for JSF
- Direct Web Remoting (DWR) — this framework abstracts away enough of the client-side browser muck to allow you to essentially make RPC-/RMI-like calls from your JavaScript. The new version introduces a “reverse AJAX” paradigm that allows the server to call into the browser (can you say “callbacks”? how ’bout “remote events”?). We covered this in a java.net article and hope to do more
- JSON — this format converts Java objects into string representations and has a JavaScript version, which facilitates exchange of complex objects between server-side Java and client-side script, as seen another java.net article.
There are many more examples, but suffice to say, if this is disparaging, I’m sure other programming paradigms (REST, AOP, etc.) would love to be so disparaged.
I think the mistake is thinking too much of client-side Java as threatened by AJAX. Frankly, client-side Java is a pretty small part of the Java world right now. The server-side Java guys and gals certainly don’t mind a more capable client-side approach… if anything, pushing more work out to the browser is a hugely appealing concept, if it can be made to work well and consistently, which is probably why Java developers tend to prefer these frameworks that take on the challenge of working with browser incompatibilities and hide the developer from them.
That said, taking off my editor’s hat and putting on my Java client developer’s hat, I’m still not entirely comfortable with AJAX. It’s not that I don’t like AJAX, but I don’t particularly trust it.
Analogy: the first non-fiction book I really enjoyed was Jon Freeman’s Playboy Winner’s Guide to Board Games. No, no nudie pictures — whatever the reason for the branding, this was a book with great insights into board gaming circa 1975. In its chapter on role-playing games, he reviewed “Dungeons and Dragons” and said it wasn’t really playable in its published form, and needed the players to adapt it to their style. But looking at would-be rivals, he noted that most attempts at simplification made matters worse. In the case of “Melée”, he noted that it simplified battles by relying on numerical superiority alone: a party of 21 could beat an infinite progression of 20-character parties, with no damage to itself, no awareness of effects to members, or their effects on the battle.
Here’s where this analogy is going. While client-side Java may not have the right answers to key questions, it at least knows which questions to address, and chief among these is compatibility. AJAX’s concept of compatibility is a sort of “well, all modern browsers kind of do these things more or less this way… the differences aren’t that bad, so you figure it out”. Like Melée simplifying combat by ignoring it, AJAX simplifies compatibililty by ignoring it. What AJAX gains in its key story, deployment, I think it loses in compatibility, to say nothing of lurking gotchas like accessibility. Maybe this isn’t a problem now when your AJAX app is running on the computers of you and your tech-savvy friends, but when you’re on a government contract that has to support accessibility modes that AJAX is blissfully unaware of, or when you doom level one tech support to telling Grandma how to upgrade her copy of IE for Windows 98 (”it came with the computer, I don’t know what version it is!”), I suspect we’re going to see some serious unintended consequences. Either that, or we’re in for another decade of “your browser is not compatible with this website; you must be using the latest version of IE for the latest version of Windows.”
Java deployment is a damn nightmare, no question about it, but once installed any applet, WebStart’ed app, etc. should run the same spec’ed way everywhere. That’s the point of Java. So far as I know, AJAX doesn’t have anything like the Acid test, some reference to definitively say that your app does or doesn’t work in accordance with some stated concept of how AJAX works. Instead, it all relies on a sort of trust/esteem network between app developers and browser makers. That’s powerful, but is it designed to take care of the end user? I remain unconvinced.


We just completed building an Ajax game powered by Java on the backend.
www.sinkmyship.com
I think it will be an interesting challenge to see who offers better functionality to web app developers (the client-side AJAX library vendors & frameworks or the server-side Java-based frameworks like Google's). I couldn't imagine people completely abandoning desktop-based or Web-Started apps, but I can see AJAX-based offerings seriously helping people who develop many company-internal web-based applications.
The idea of AJAX is great but what it lacks is a true standard that nails what it to the floor so to speak. What may work on one browser will just fallover on another...and so on. I like some of the AJAX stuff but what it boils down to is that AJAX is just trying to work round the problems of HTTP request/response and make it feel more like a continuous connection
What I would like to see is some new standards for browsers to implement that does away with the FORM post/get methods etc and brings in a whole new set of tags for handling html events between the client/server
Its way overdue!
I got my first grey hairs writing my first dhtml single page web application that had to look "just like this bespoke Visual Basic application" and run on Netscape 4 and IE 4+. I was really pleased that I wrote a data grid on the page that was a sort of Excel workalike - using Netscape layers and IE DIVs rather than inputs. We even got hold of a beta release of the first VMWare server to host our own quality assurance lab with every version of those browsers that we could find.
Immediately after that project I found a startup on the web that had written a spreadsheet in dhtml than ran in all browsers and worked beautifully. Gee I was impressed at their cross browser javascript libraries - having cobbled together my own crude attempts. That was the year 2001.
So the whole "cannot trust the browser" stuff in the article seems a bit Chicken Little to me. Every new developer trend brings both opportunities and risks. J2EE is great. Have you ever had to work on a big j2ee app where the developers didn't get it and wrote their own poor MVC framework? Nasty. Ajax is great. Did you hear the one about the developers that wrote their own javascript library for Ajax and it didn't work in any browser that they did not have installed at their offices? Same thing. Fools rush in with their own code. Wise men find a stable framework or library (commercial if you must - opensource for preference) and code to that. Then they focus on the value added in their application rather than on re-inventing their own version of the wheel.
At the end of the day for most folks if your competition has a rich Ajax web app that work in 9/10 browser and you have a basic web app that work in 10/10 you are going to go out of business. (Clearly government projects don't have any competition so they don't have any pressure to have a rich app.) So to me Ajax is here to stay. What I have yet to see is any articles about how to take the approach of "Ajax when we know the browser is one we tested against, else don't do Ajax but old school html" without lots of duplicated code. That is to say "how do I write a site that runs as Ajax in compatible browsers and plain html where it is not - without me having to maintain two versions of my site". That would be a killer framework...
AJAX is interesting framework that most of our current application can leverage it. In the contrary framework/technology will come at its own cost. AJAX is very much vulnerable to errors if the framework is used for
1. High visibility sites
2. Cross Browser and different version compatibility.
To mitigate the above pitfalls, I believe that developer need to use both normal/existing flow and also enabled with AJAX. If AJAX is not supported then it would take normal approach.
We’re having an internal discussion on the editor’s list about JavaOne news and mood, and there’s a thread on AJAX that I think is remarkable because it’s based in profound misconceptions. I’m disagreeing with everyone here, first with two of my bosses, and then with the community at large, so let’s take those in order.
I do not agree. Go to http://www.buyworkz.info/idiot_Spain/maquis_Comunidad%20de%20Madrid/strass_Madrid_1.html