Saturday, November 24, 2007

ASP.NET and Spolsky’s Law of Leaky Abstractions

For reasons beyond my control I recently found myself developing in classic ASP.  After years of developing in ASP.NET this was obviously a little jarring.  However, what surprised me about the experience was that there were some things about classic ASP that I actually enjoyed.  Most notably I felt I had more control with classic ASP.  Nothing was in my way.  Things that should be simple were simple.  For a moment I imagined that this is what it must feel like to be a PHP developer. ;-) 

I wondered why I felt this way.  After all, the whole the whole point of ASP.NET is to save me from having to deal with “icky” HTML, JavaScript, and CSS…right?  I really like developing in ASP.NET.  I would take ASP.NET over classic ASP any day of the week (and twice on Sunday).  ASP.NET is certainly one of most thoughtfully designed and well implemented frameworks I have ever worked with.  Scott Guthrie is a genius and he has the patents to prove it.  However, I couldn’t ignore the fact that some things were a lot easier to accomplish in classic ASP.

I realized the unfortunate truth that there are some abstractions in ASP.NET (and all frameworks for that matter) that can transform into obstacles.  In order to use these abstractions you end up having to learn a lot about the internals of the framework.  I’m talking about Reflector. You have to codify assumptions about the underlying technologies into your application.  In other words, the abstraction leaks.  I borrow this term from Joel Spolsky’s Law of Leaky Abstractions.  I think that the small sense of empowerment I was feeling when developing in classic ASP came from the fact that I wasn’t forced to dig too deep into, or worse, code around the framework in order to get the job done.  There was no framework. 

Another, even more heretical thought occurred to me during this process.  I wondered if code-behind is always necessary. Is it always essential to separate code and markup?   If you simply replaced VBScript with C# and gave yourself a set of libraries as rich as the BCL, would combining code and markup be more palatable or even more productive in some scenarios?  Can some aspects of ASP.NET be abandoned entirely?  I’m not sure, but I’m now a little more inclined to find out.

#    Comments [0] |