Having written tens of thousands of lines of code in ASP.NET for
commercial sites (
www.deltavacations.com,
www.covacations.com among
them) and being in the middle of writing a new site using RoR, I
believe I can add some hard-earned comments to this discussion:
ASP.NET is very powerful. The library is enormous and it has many
enterprise-ready technologies built into it. The most important of
these is transaction support. .NET 2.0 transaction support is even
better with the lightweight transaction scope. This is perhaps the
biggest gap in RoR's offering. That said, I disagree that ASP.NET is
more productive than RoR. I have been FAR more productive with RoR
after just a few months of learning Ruby and a few weeks of using RoR
than I am with .NET even though I've been coding on the MS platform for
10 years, with half of that time spent almost exclusively working on
web applications.
It is true that ASP.NET provides some great controls (grids, etc) for
web applications and 2.0 has even more (login view, for one). But what
is doesn't provide out of the box is a true ORM layer (from Microsoft
anyway). ActiveRecord is responsible for the great majority of the
productivity on the Rails platform. If I never have to create another
SqlConnection, SqlCommand, or SqlParameter object again, it will be too
soon. Yes, I have rolled my own Data Access layer, but for goodness
sakes, how many DALs have I built in the Windows world in the last 10
years?! Nhibernate is not fun either. Powerful as it may be, it moves
the burden from C# code to xml configuration. If I were to consider an
ORM tool for .NET, it would be LLBLGen.
My second-favorite Rails feature is the architectual guidance that is
built right into the framework. MVC clear as MVC can be, with
directories built right there for you. Yes, ASP.NET is MVC also, but
the PageConroller style generated in ASP.NET using Visual Studio is too
weak for my taste. RoR encourages validation of business rules in the
model, where it can be re-used effectively (read: where it belongs),
whereas ASP.NET's validation controls seem to encourage developers to
validate the rules in the UI. Surely, a case can be made for UI
validation to avoid server roundtrips and workload, but I don't buy
into it. My servers are running at 5% CPU utilization, and my
developers are running at 105% utilization. Of course, I can build my
own Enterprise Templates (a$$uming you have an Enterpri$e Ver$ion of
Vi$ual $tudio) but Rails' approach of sensible defauls (and everything
overridable) clearly wins out here.
The net result is that I *don't need* an ultra-powerful IDE like VS to
develop RoR apps. I do just fine with VIM, thank you. I may not have
IntelliSense or Refactoring, but the time saved on DALs alone more than
makes up for it, and, honestly, I refactor a lot less in Rails because
everything is already in place. If someone told me I had to build a
commercial ASP.NET application with VIM I'd tell them to go fly a kite.
Furthermore, VS does a bunch of weird crap to make interoperability
with Linux/Mono impossible (maybe a non-issue if you're a 'Microsoft
shop'). VS.NET code-behind pages use different attributes which make
building Visual Studio ASP.NET solutions on Linux with mono impossible.
You could argue this is a Mono limitation, I suppose, but the point is
you are pretty much locked in to the MS platform meaning Windows XP on
the development desktop, Windows 2003 on the Server, Visual Studio, and
MS SQl server. Add up the cost of that.
Lastly, I'll mention the default ASP.NET push for people to use data
structures such as DataReaders and DataSets. I don't care for them. I
prefer a real domain model, for several reasons. First, it encourages
*real* oo-style programming. Second, and most important, I am in
control of my data structure's internals, not Microsoft. Ask any
VB6/Windows DNA/ASP 3.0 developer how much fun he's having Interop'ing
the old ADO Recordset object with his shiny, new ASP.NET code and he'll
tell you he's ready to blow his brains out. I won't make that same
mistake. I prefer a Hotel object to a HotelDS and an IDictionary to an
SqlDataReader. That way when MS abandons the SqlDataReader I won't
care.
Having said all that, I do think the .NET platform is solid and
enterprise-ready. C# is an enjoyable language to program in compared to
C++, VB, and Java (all of which I have written production code with).
Still, the dynamic power of Ruby and it's cavity-causing syntactic
sugar like Enumerable#collect and Enumerable#partition is hard to
overcome. Don't rule MS out, however. They're busy at work on a Python
version for .NET (IronPython) and Don Box loves him some Ruby. I also
believe MS has made great strides with .NET 2.0, especially wrt
ASP.NET, but I think they have a long way to go to provide the kind of
out-of-the-box, architecturally sound, and simple productiviy found in
Rails. In contrast, most of the architectural guidance coming out of
Redmond these days is constipated -- Enterprise Library, anyone? Again,
nothing in ASP.NET prevents you from writing aesthetically beautiful
and simple web application code, but the feeling I get from the default
Visual Studio web project setup falls short or 'rails myapp'.
In short, if you need transactional capabilities or need to integrate
with some of the other enterprise features (message queueing), build
with .NET and get yourself a good code-generation/ORM tool. If you're
building your standard 3-tier web app, or have a tiny budget, I
recommend giving Rails a serious look.
Cheers,
Christian Romney