A few days ago, Simon Tokumine, a Ruby On Rails developer from UK who had to build a web app using, as he calls it, .NET MVC (ASP.NET MVC as we usually calls it), wrote a nice post that makes a comparison between RoR and ASP.NET MVC. Actually it was not really a comparison, more a “ASP.NET MVC for RoR developers” kind of post.
He was a foreigner that came into the .NET country and visited the city called ASP.NET MVC, and he gave his opinion on his first (or second) visit. But not being a local he only used what the tourist guides (the MSDN and the official docs) told him and he didn’t know where the locals gather and what they do make their life easier.
In this post I’m going to give him and to other RoR developers that want (or are forced to) evaluate and eventually use ASP.NET MVC in a project the tips that they need to do as locals do, and I’m going to do address, among the topics that he used in the original post, only the ones that need a response (the others were pretty obvious, like “Learn C#” or “C# is more verbose compared to Ruby”). So, head to his post to read the whole article.
.NET MVC is actually .NET VC
He is right, ASP.NET MVC is addressing only the Controller and the View part of the MVC pattern. I think that there are good reasons behind this decision: .NET developers have always been used to having a lot of freedom, especially in the data access side of things. And I might say that .NET developers don’t like “conventions” that much. ASP.NET MVC is a huge step toward a more “opinionated” and convention-based mindset, but including also a convention-based approach to data access would scared many .NET developers away. Furthermore, there are so many ORM in the .NET space, either opensource, commercial and even from Microsoft. Finally, unlike RoR world, .NET developers have to deal with legacy codebases, and while rewriting the UI side of things is easy and most companies do it every 3-4 years anyway, rebuilding the data access and domain logic is less likely to happen. Just as proof of this, at the moment I’m working on the rewriting of a web app, but most of the services for data retrieval are still in COM+ components built in 1997 by people that left the company. Something that probably RoR developers have the luxury to ignore.
But now that I took the defenses of ASP.NET MVC, let me say that, there is a way to accomplish automatic data validation, binding from request; it’s not baked with the framework, but there is: the way I found the best (at the moment) is using xVal, which allows you to use any validation rule engine and any validation notification library. I used it combined with jQuery validation plugin and the Enterprise Library Validation Block.
Anyway, Microsoft has a data access story for ASP.NET: it’s called Dynamic Data. And there a version of Dynamic Data for ASP.NET MVC (beware, still a preview) in the works. If I’m not wrong, it should rely on EF, but will also allow the developer to use he’s own Domain Model. And there is also the scaffolding feature to help you quickly write your views based on the Presentation Model you want to pass to the view.
And you still want a fully convention-based approach (like RoR’s ActiveRecord), I suggest you have a look at S#arp Architecture, which uses NHibernate as ORM and is based on ASP.NET MVC, or even have a look at FuBuMVC, which is loosely related to ASP.NET MVC and is supposed to take the same RoR approach of being a one-size fits all application framework (not sure the state of the development tho).
The community is extremely anemic
That is quite unfair, probably you didn’t look around enough. There is stackoverflow.com, there is the ASP.NET forum. There are quite a few blogs and blog networks that I suggest you to give a look at: CodeBetter and devlicio.us to name a few. And then there is nice series (in think of almost 50 posts) of tips about ASP.NET MVC by Stephen Walther and one by LA.NET, on most of the aspects of the framework. Another good source of information is the ALT.NET mailing list: even if not devoted to ASP.NET MVC only, it is worth registering to it.
Also, if you look at CodePlex, there are a few projects for ASP.NET MVC, but they are mostly about libraries to enhance the framework itself. I agree with you that there are not as many as many plugins, but what would you expect from a library that shipped less than a week ago?
Documentation is rudimentary
The framework shipped last week, and you based your description on a RC release. The MSDN doesn’t have anything yet, but there are is a quite good documentation on the asp.net/mvc site.
ASP.NET MVC is not OpenSource
Yes, it is not OpenSource, but it is public source (released under the Microsoft Source License). You cannot contribute, but since to code is available you can look at it and fix any bug you find or add your own conventions. The only think that you cannot do is releasing the modified code. But most of the times you’d not need it. Almost everything in ASP.NET MVC is extensible, and you can easily add your own conventions by extending or replacing some parts of framework, like, to name a few, controller factory, action invokers, result invoker, view engines, model binder and so on.
It would have been nice if it was properly opensourced, tho. Not for a technical reason but more for a philosophical one.
Ajax is done by hand
I’d hated if all javascript was abstracted away with a server-side wrapper. But with jQuery and all the plugins there is no need to use that. And, if you use xVal, the client-side validation is written for you, so you don’t need to deal with that boring stuff.
Passing variables to the view can be extremely laborious
That is right, I think this issue as not been solved yet. Together with the “component” story. The best way at the moment is creating a Presentation Model for each view that needs to be rendered, and have this contains all the bits of data needed. It can become a bit tedious for small views, or if you have many views, but better than the looseness of the dictionary of data. I admit this would be easier with Ruby, where you can build the presentation model without creating the class, using the dynamic-ness of the language. There is an extension to ASP.NET MVC to support IronRuby, but it’s still in an early stage. So we’ve to either wait IronRuby or C# 4 dynamic types, whichever comes first.
It’s hard to convert ASP.NET developers to use .NET MVC
I totally agree with you on this: web forms developer have a different state of mind. But this should not be an issue for RoR devs
There is a worry that MS will drop the project if forced to make a cost cutting decision
Now that it is shipped, it’s almost impossible that it happens. Also, there are already plans to a ASP.NET MVC v2 inside ASP.NET 4.0. And finally, if they stop developing on it, they will not cut it, they will just leave it untouched as they did with remoting and they are going to do with Linq2Sql
I hope I helped adding some pointers to resources that were missing in Simon’s post.
But all in all, Simon is right: ASP.NET MVC is not as mature as RoR, mostly for the community standpoint. For most of the people around, that consider things only after they reach the RTM status, ASP.NET MVC is a 5 days old framework, while RoR exists since 5+ years. But I hope that ASP.NET MVC becomes a great community as the RoR one is.