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
Dema wrote:
···
Hi Stephen,
I've seen that aGorilla has pointed you to my blog
(http://dema.ruby.com.br) on this subject.
As I am still working on both platforms, let me give you a summed up
comparison.
I think both ASP.NET and Ruby on Rails approach different ways for
building web apps, but both manage to do it in a very high quality
manner.
In the end, it's much more about developer's taste and less about
technical issues.
For instance, if you're more towards statically-typed languages and are
used to have a compiler and a top-notch IDE (VS.NET) to help you out,
then by all means go with ASP.NET.
On the other hand, if you prefer simpler tools (more text-based),
dynamic languages, and running your app in a interpreted, more agile
environment, RoR might be a good fit.
On the technical side, ASP.NET as we all know has some portability
issues, so, inspite of Mono, your best bet on a production environment
would be on a Windows web server and a SQL Server database. Remeber the
high costs of that.
RoR is based on a completely free, open-source stack (Ruby, Apache,
Lighttpd, MySQL, Postgre, etc) and runs well on pretty much any OS
platform out there, be it Linux, FreeBSD, Windows, MacOS, Solaris, etc.
If your going with RoR, remember to allocate some quality time for
studying the language and the framework and getting used to new tools
and environments and learning how things are done in a open-source
community. It takes some time to get up to full speed, but at the same
time, can be a revealing and rewarding experience.
Of course, these days, I'd recommend RoR, but remember that what best
fits me, and it might be different for you. Anyway, you will be in good
hands if you go with ASP.NET as well.
best regards,
Demetrius
http://dema.ruby.com.br/
Stephen Kellett wrote:
> HI Folks,
>
> Anyone here done both ASP.NET and Rails? Care to compare and contrast?
> I'm not interested in MS bashing, just the pros and cons of both
> environments.
>
> The reason I ask is that I've just read on joelonsoftware that he thinks
> ASP.NET is excellent and is the best solution for server based work
> presented on a website. I wonder if anyone thinks thats a valid
> statement or not and can provide arguments for/against that point of
> view.
>
> If ASP.NET does offer superior things to Rails, what can be done to
> Rails and/or Ruby to change things?
>
> Stephen
> --
> Stephen Kellett
> Object Media Limited http://www.objmedia.demon.co.uk/software.html
> Computer Consultancy, Software Development
> Windows C++, Java, Assembler, Performance Analysis, Troubleshooting