In my 2.0 isn’t a silver bullet post, Alex Lowe made it clear that my enterprise development perspective, while valid, only represents a portion of the ASP.NET developer community. The reality is that Alex is right, but should he be? Alex argues that there are plenty of sites that “should be written using ‘crappy’ SqlDataSource control, DataSet, ‘improper’ paging, etc.” I honestly wonder, should these sites be written in ASP.NET to begin with?
I say it often, but ASP.NET is really hard. Sometimes I wonder if I over exaggerate how hard it is, or if I’m the only one who sees, but time and time again I see such horribly written code that I know I’m right. I joke not; today I’ll get to maintain an application that uses:
And that’s just one of literally hundreds of ASP.NET WTFs I’ve run into over the past 5 years. In my experience, the dont-get-its far outweigh the get-its and I have a hard time believing I’ve just been really unlucky. Visual Studio 2005 and ASP.NET 2.0 have done their best to make things better, but the difficulties are so fundamental that no amount of abstraction is going to work. Worse, the abstraction is so high level, and the details so low, that you often get pretty serious leaks.
Almost all of the features that make ASP.NET a superior enterprise choice are significantly more difficult than what’s offered by the alternative web technologies. The page lifecycle is an incredibly powerful tool when understood and harnessed, otherwise it’s just a stupid pain in the ass that’s going to get in your way. Postback and viewstate are great, but it’s a significant shift from simply posting to a different page. So much so that 2.0 lets you do cross page postbacks simply because the paradigm shift was too much. But crosspage postbacks are a perfect example of leaky abstraction – the first time you use it, it’ll make a hell of a mess.
The issue runs much deeper than ASP.NET. C# and VB.NET are relatively hardcore languages. The entire VB6 support fiasco is more than enough proof. VB.NET is much harder than VB6, VBScript or PHP. Drag and drop gets you so far, then you are stuck having to deal with exceptions and classes. If you are one of the developers Alex is talking about, you are likely much better off with an untyped, procedural language. Even turning off Option Explicit/Strict won’t get you 1/2 way there. Then there’s the .NET framework itself with the thousands and thousands of methods, which you’ll need to use. Whether it’s encoding ADO.NET, XML or IO you’ll have to get your hands somewhat dirty.
In my very humble opinion, PHP is a far better alternative to ASP.NET when it comes to the type of application Alex is talking about (I’d say classic ASP too if it was still being developed and probably Ruby on Rails if I knew more about it). As a language, despite some claims, it isn’t at all an OO framework or much of an OO language, it’s exception handling is pretty primitive and it’s untyped. It’s also a traditional web structure, doing away with complicated bound controls, postbacks and server controls. What to display 10 rows? loop through your record and echo out some tr’s and td’s – simple. The only hang up with PHP some might have is getting it installed and the language if you’re a VB’er – but again, you’ll have serious language issues in ASP.NET anyways.
Everything .NET is simply amazing. I love ASP.NET, C#/VB.NET, ADO.NET and SQL Server. I can’t imagine doing web programming without writing HttpHandlers, code generating my domain layer and creating a lot of simple custom server controls. I’m amused that anyone would attempt to do serious enterprise architecture in a language/framework that wasn’t so powerful and complete (there are other alternatives, PHP isn’t one). Like most development tools however, try as they might, Microsoft will never make ASP.NET the best enterprise tool while at the same time the best mom-and-dad solution (or even close to).
ASP.NET is cool, but if you don’t get it I’d strongly urge you to use something else – I keep hearing amazing things about Ruby on Rails. Remember, it’s in Microsoft interest to tell you how great their products will be for you, but it might not really be the case. Use the right tool for the right job, and if you don’t even understand the tool, than it isn’t the right one!