Brazilian waxing, choosing a JavaScript framework and why I don’t like ASP.NET AJAX
Let me first clarify something. As Jan pointed out I am into Brazilian waxing but please, all you pervert guys stop sending me emails with questions about the subject!
Now that's taken care of, we can get to the matter at hand. A couple of days ago, somebody asked me what the best JavaScript / AJAX framework is to start a new web application project. Because we work mostly with Microsoft technologies the answer should be obvious: ASP.NET AJAX. But I have been working with ASP.NET AJAX for the past few months now and I really don't like it. The first problem with ASP.NET AJAX is rather well known throughout the community: the UpdatePanel. I have found a good article which explains why the UpdatePanel is evil. I would recommend not to use it. It plain sucks. The second fact that I hate about ASP.NET AJAX, including the control toolkit, is the fact that you are cluttering your HTML code with all sorts of custom server controls. I don't want clutter in my ASPX page, I want it to be as clean as possible (thank you ASP.NET MVC). I want my JavaScript in a separate file so I have a clear distinction between presentation (CSS), markup (xHTML) and behavior (JavaScript). I know you don't have to use the drag-and-drop method and that you can use the same ASP.NET AJAX classes in JavaScript, but doing this is painful because documentation is lacking.
These things don't stimulate you in becoming a better (web) programmer. In order to be able to solve the problems you encounter with your software, you have to know how stuff works. It doesn't pay off to be able to open a designer, drag and drop some server controls on it and then wrap them in an UpdatePanel to create a web page using AJAX. You are missing out on a lot of exciting stuff that you encounter when doing client side web programming. You are missing out on JavaScript, a whole new and exciting language. When learning a new programming language you once again have a way of doing things differently, you can see how the new language tries to solve the same problems in comparison to other programming languages and learn from it.
I know it is possible to reference the MicrosoftAjax.js file directly, and write out object oriented JavaScript. Most of the literature mentions that this is possible but very few really go into the matter.
If you compare them to the other JavaScript frameworks out there, jQuery, prototype (with scriptaculous), YUI, … Documentation is abundant and these frameworks don't try to give you the drag-and-drop experience. They just give you a decent framework, which is necessary with JavaScript, to start enriching your web pages. On wikipedia there is a comparison of the different JavaScript frameworks and ASP.NET AJAX isn't even included! I think that says a lot about the popularity and usage of ASP.NET AJAX.
So before choosing a JavaScript / AJAX framework, don't go blindly for the Microsoft solution. It's not the best around, try out the different frameworks and take the one you like. I have been using AjaxPro with prototype for my personal projects but development of AjaxPro has stopped. For new projects I am going to use ASP.NET MVC, which is great by the way, in combination with jQuery. Chad Myers has a very good how to on the matter.
To conclude I would like to share the different books I have been using/reading about the matter:
- Pro JavaScript Techniques (by John – mr. jQuery – Resig)
- JavaScript The Definitive Guide
- Prototype and script.aculo.ous: You never knew JavaScript could do this!
- jQuery in Action
I'll probably be writing a review on one or more of these books, although I'll first have to write about the pussy way of development like I promised Patrick.