Wednesday, January 21, 2009

Why Ajax is evil

"Ajax or not Ajax?"

Making my yet another Swing app on Java, I've been thinking on an answer to a question:

Honestly, what the hell Ajax thing is so special, so many people
are rushing in to use it just right everywhere?

So much time went away since ESR wrote his excellent "HTML Hell" page. I am just wondering who is reading this?..

I found this Ajax thing is not just mostly bad idea, but actually it is that evil. To the company of public resources it is not yet that much harmful, but for the enterprise it is. Because it simply has no future, whilst your enterprise is already poisoned by this stuff, probably. Hence you have to support it or spend some more money to rewrite your project. Here a list of main issues (too lazy to write much):
  • There is no real integration with a desktop, but through a web browser. Hence, your application acquires all the limitations.
  • While Ajax website is more fun to use, yet you're nearly have to pray for your browser worked properly with a particular website.
  • Issues with off-line and on-line modes. To write entire application in a JavaScript that sits in a memory of the browser is not really a thing you want to go.
  • Your browser is not working as designed: history issues, refresh will destroy everything etc. Of course, there are (expensive) workarounds to avoid state loss on refresh, but history won't work anyway.
  • Google won't index your website much, once your HTML has nearly one tag, like: <script></script>
  • There are no real widgets, except standard HTML ones. There is an emulation of such.
  • It suppose to deliver only an user interface. However, in practice it often takes place much wider scope, thus interfere with other paradigms.
  • Quirky, full of hacks and tricks JavaScript code and CSS stylesheets. Once browser's vendor changes something that breaks your page, you have to fix it.
  • It is very expensive ("time" equals "money", you know) because of its heterogeneity. Typical Ajax application is a hodgepodge of various stuff: XML, CSS, HTML, JavaScript and a thing on a server-side (call it yourself: Java, Python, PHP, Ruby... whatever).
But the main issue with Ajax is:

There are NO standards!

Very "good" at enterprises, right? You might say: there IS a standard specs: ECMA Script, CSS, XHTML etc. Yes. You're completely right till the point of... different browsers differently spits on those specs. Look at the reality: today we have 21th century, while the best open source browser (Firefox) can not hit even 80% of Acid 3 test! What browser is the most popular at a regular Windows box and how much percents this thing can hit of Acid 3 test?..

When you select a technology for your online perfume shop, then maybe you have to think how often your site random people are going to use. At that time Ajax DHTML stuff with plain alternative would be OK. However, if it is an enterprise under controlled network, I doubt any browser is the best Virtual Machine for scripting.

The future is quite different. If you increment that O'Reilly's buzzword one more time up to "Web 3.0", you will find that there is just no Ajax. There is JavaFX. There is Java Swing and a Java Web Start. There is Adobe Air and all the rest of Adobe multimedia streaming magic. There is even Microsoft Silverlight that works pretty well. But there are no Ajax...

If tomorrow there is no Ajax, maybe you should not bother much with it, but go to the next level? Thus, before you rush to follow everybody's hype and bubble just "to be as everybody else", better really think about it twice. Or more.

"I hate what you just saying, it's all lame!"

OK, dear social networker, to raise a finger on a problem is not a big deal, I agree with that. Thus some solution should be proposed. I could drop you a few lines why I would choose Java Swing + web services versus Ajax stuff at enterprise. As well as why I would choose JavaFX, if I need funky RIA for fun. Keep in mind for yet your perfume shop can be just as damn great without any Ajax thing, you know... — simply look at and take it as an example for yourself. :-)

Here you go:
  1. You anyway want to go SOA, no matter what type of UI you have in a front.
  2. Java Swing has a rock solid internal standards and runs identically on various platforms.
  3. Swing is homogeneous. Your employees can be specific to Java only and do not need to know a mixture of various stuff and be proficient in each.
  4. You can make whatever hell widgets you want with any possible shapes and behaviour, because the whole thing is just a plain canvas, that simply listens to input events, after all.
  5. You can use only Ruby or only Python as well (JRuby or Jython), if you really like to do so.
  6. You can create Swing GUI literally in minutes in front of your customer's or manager's eyes, using NetBeans and Matisse editor.
  7. You still have clear MVC and you distinguish what is business data, and what is just a way to deliver it to user.
  8. You have clear desktop integration.
  9. Your internal company network is highly controlled, so you do not need to worry something is randomly missing on random machines (otherwise fire your system administrators ASAP because they are just morons).
  10. ...I can continue this list till you fall asleep. :-)

If I would have say what is the future of Ajax, then I would say:
Ajax is a very expensive way to pimp your business network resource and this way of data delivery will eventually die on web applications market.

Have a fun!

No comments: