I am a long time web developer and making a living from it. For my entire programmer life, I looked for perfection for developing applications. I remember back in 2002, I was struggling about if thick clients or web clients were better for typical form processing. At that time richness of thick clients were more attractive than these days since we did not have all ajax goodies, flex, silverlight etc.
Time passed and I decided to go for web apps. and I have no regrets so far. Not that I am claiming it is a better way but I am just happy for my personal development.
Then came the next question: I need to go with some platform/framework etc. I've worked with a lot of technologies: ASP, ASP.NET, PHP, Java frameworks (Wicket, struts, Echo, plain JSP) , Flex, silverilght, Perl CGI. I felt uncomfortable with the number of choices since it is impossible to specialize all of them and it was extremely hard to predict which of these technologies have a future (and even now). Selecting a technology is difficult, you need a very good eye for that. Common sense says: "use right tool for right job". And yes frameworks are tools. But unlike that analogy, these days frameworks are so powerful that most of them claims to be suitable for "every job". For instance, you can write executables with PHP, you can write desktop applications with Flex via AIR and with .NET and Java you can do almost everything you can imagine and even you can write operating systems with them ( SharpOS, Cosmos, Singularity, Jnode ).
I started web programming with Perl /CGI then I quickly moved to PHP and then Java and then as a requirement of my job I first met with ASP.NET 1.1. And I hated it. Then came ASP.NET 2.0. I was extremely impressed with ASP.NET 2.0 at that time. It really seemed to me that
MS really did a good job with it. But after sometime passed, I missed neatness and good design in Java frameworks. ASP.NET 2.0 was very practical but it completely ignores good design practices which leads to unmaintainable crappy code. Specifically talking about webforms since it was the only thing running on ASP.NET.
Finally, I've met Ruby on Rails. I've done some projects with rails and I really really liked it! Everything smells correct with rails. And it is much easier than java or .net. I also like linux so I thought I was finally off the MS lock in. However, later while dealing with ruby, I start to feel uncomfortable on things like dealing HTML manually , unicode problems, and green threads. It was painful to use a multi select html selectbox with rails where you use nested arrays for that and it looks ugly.
Finally I returned back to ASP.NET forms but with a different eye! I quit following MS practices ,instead I applied things that I learn java and rails. I feel much happy now and Webforms is my favorite platform. This article will be comparison of webforms with "others" based on my personal experience. I might be wrong so feel free to correct me.
But first lets dispell some myths:
Myths for ASP.NET Web Forms:
ASP.NET runs only in Windows: This is a major problem to many people. I am a linux fan and I use linux and develop on linux everyday. And we have great Mono project runs asp.net successfully on every platform. It is quite up to date too. Everything works there including Ajax, Ajax control toolkit, asp.net futures, asp.net mvc (although illegal to do so) . The only missing parts is Web parts and the new listview control (listview implementation is underway!).
ASP.NET Web Forms are easy: Unlikely the demos made by MS, dragging and dropping stuff, ASP.NET is extremely complex, but also powerful.
You can only use C# and VB with ASP.NET: You can use C#, VB.NET, IronPython, IronRuby, Boo, Nemerle with ASP.NET. There are possibly others but these are the ones I know working.
Pros for ASP.NET Webforms:
- It uses .NET platform so entire .NET library is at your command.
- Extremely well documented and main stream
- Cross platform. With mono it works everywhere
- Mono ASP.NET is open source
- Ajax is extremely easy. Use an updatepanel and you are good to go
- Can be extremely complex. Loading dynamic controls on runtime , view state issues , custom controls , ASP.NET Page Life Cycle are too complex. I mean it!!!
- Viewstate! It helps a lot to emulate a stateful web. But it can be a true performance killer if you are not careful
- Hard to unit test. I was really puzzled for this. Unit testing is important. I invented my own Model View presenter pattern to get around this issue.
And now the comparisons:
ASP.NET WebForms versus Rails:
I really think asp.net is superior to rails. Firstly, when you develop an n-tiered web application, it doesn't have to be a web application at all in future. That's why we have n-tieres. We could replace the UI layer with any other thing. You can convert it to a thick client application a socket server or what ever you like. Rails is a web framework period! You develop a web application and you have to live with it. Most of the time this is not a big deal since your purpose is developing a web application anyway. But I like the flexiblity of n-tiers.
Secondly, Rails, actually ruby has no real threads and it is 200x slower than C code. In fact,this has never annoyed me in practice but I feel more relaxed that I could use real threads with .NET. Additionally, unicode is breeze with .NET where rails fail miserably.
Rails use a template approach that if you intended to generate html pages, which gives you a nice clean seperation of your ui from controllers. But you have to type a lot of html and yes I am aware of HAML. ASP.NET allows you to build components and those components can talk each other with events only. This leads to a very good isolated design. Also things like output caching allows you partially cache some parts of your pages. I see no equivalent of this in rails.
Furthermore, Rails' Ajax is not as easy as asp.net. You deal with RJS templates although you can use things like JQuery or Ext or YUI , that way you make a language switch.
Ruby is a better language than C# imho. C#, although 3.0 version is fantastic is a bit verbose compared to Ruby. But I still like C# very much. But if you want power there are much better languages than ruby in .NET/Mono world like Boo and Nemerle. They are extremely powerful and you can develop asp.net apps. with them.
And for backend, Rails has ActiveRecord but so does ASP.NET: Castle ActiveRecord.
And even with .NET you have something better than Activerecord . Enter DB4O!
No more mapping , with db4o you can truely ignore you persistance layer and store your objects as they are which is difficult to implement with rails.
Another point is internationalization, and multi langauge applications are very easy with asp.net via Resources. Rails has globalize plugin for that and works well but it creates some messy tables in the db.
ASP.NET WebForms versus PHP:
I am sorry for PHP fans but syntax is really ugly. PHP doesn't feel like an OO language. PHP 4 was an hybrid lang and PHP 5 implemented full blown OO stuff. But still I don't feel OO paradigm with PHP. It also suffers the same problem with Rails. Too much dealing with HTML. PHP has rails like or even ASP.NET like libraries. But still too low level for my taste. One good thing about PHP is it's extremely wide-range of library support. Other than that I see no reason to you php except for dealing legacy applications.
ASP.NET WebForms versus Java stuff: JEE versus ASP.NET is a long time debate actually. Java has a lot of decent web frameworks. They are mostly component oriented like asp.net. I can't bash them but ASP.NET Webforms looked much better than JSF, struts. and yes .NET has NHibernate and Spring .NET. Also C# is a better language than Java (just side by side language comparison not runtimes!).
ASP.NET WebForms versus Flex: Flex is extremely powerful. And it archives things that ASP.NET can only dream of. Very componentized, very elegant! The only thing I dislike about Flex and disconnected frameworks like ExtJs or Qooxdoo is that you have to serialize your Domain entities. And if you have bi-directional associations those objects cannot be serialized into JSON or XML. WCF provides a workaround for that but I doubt it will be useful with anything besides .NET. Then you have to build with DTO's. Same problem happens to be with Rails + Flex or Rails + Extjs. Rails creates DTO's on the fly with toXml or toJson thingies.
ASP.NET WebForms versus ASP.NET MVC or MonoRail:
First it is illegal to run ASP.NET MVC on linux so you are locked into Windows. Second ASP.NET MVC and Monorail although can use ASP.NET components they cannot use Postback controls. Then you drop to HTML once more for many things. Ayende "The Great" (that's what I call him), rightfully complains the complexities of WebForms and he prefers MonoRail . I can totally understand him. His points against web forms are valid. But I think this is a matter of a personal preference when you compare pros and cons.
Well this is the end. Feel free to criticize and correct me. Happy web programming !