Hawaiʻi's Technology Community

I have been immersed in Rails development for the last several months and I almost always recommend Rails as the best platform for raising a new website from scratch.  Recently, though, an opportunity came up to work on a .NET MVC 4 project. Great, I thought.  I get to switch back to my favorite language (C#) and still develop in an MVC framework.

Below, I will compare some major feature areas of both frameworks:


I think I have to give the nod to Rails here.  Bootstrapping a new rails project is pretty simple -- just drop to the command line and type rails new project.  However, if you are already a .NET developer, it is pretty simple as well.  Just open up the VS 2012 IDE and select Project/New and select MVC 4 application from the project templates.  You'll get a nicely set up application with a sample Home controller.


Again, for simplicity, I have to give the nod to Rails' Active Record.  Its is the default ORM and with rails "convention over configuration", you don't even have to think about your ORM.  Just build a migration with your desired attributes and the database is built for you.  On the MVC project, I was forced to use a legacy database so I didn't get to use the Code First version of Entity Framework (EF).  I've run through several samples and it does work similar to Rails in that you build the model with its attributes and the database portion is generated for you. But, that does leave you building several classes with simple properties whereas Rails only has you supply the name and type of the attributes.  Again, for ease in startup, Rails wins but any .NET developer experienced with EF will probably think I'm just nit-picking.


I think most developers have come to the realization that MVC is the best pattern to use when it comes to building non-trivial websites.  Both platforms separate their project projects into folders for models, views, and controllers and both do an admirable job of guiding the developer to do the right thing in those folders.  In the end, though, there is only so much a framework can do in this area.  If the developer doesn't know MVC or doesn't follow MVC best practices, either framework won't work as intended.


The routing architecture of MVC seems to have been lifted straight out of Rails.  That's why I'm so frustrated with the one thing not provided by MVC - a tool to list all of the current routes to make sure I haven't left any back doors into an area of my application.  Or to make sure that one non-REST-ful route that I needed to add for a convenience AJAX call is going to work as I expect.  I know, I know, if I'm that worried about it, I can just write a test to make sure that my route will be recognized.  And I will.  But, first I just want to play with the routing system a little to see what my options are.  And for this Rails' rake routes command line is my friend.  I miss my friend...


In the Rails community that delivers real applications, testing is mandatory.  And the Rails framework expects that tests will be written.  I use the RSpec framework and usually go with TDD to keep my code lean and on point.  .NET also supports testing frameworks but it still doesn't feel "baked in" the way that it is with Rails.  I constantly find myself having to go back and add tests in the MVC platform instead of writing my tests first.  That may just be relative lack of experience and I think I can get back to TDD even in the .NET platform.

So, that's my two cents on the platforms.  I feel like both deliver on the promise of fast web application development.  I believe a total web application newbie would probably benefit most from Rails "convention over configuration" when it comes to getting a 'Hello World' app up and running.  But, I also believe that anybody experience with using Microsoft tools would be more at home with the MVC framework.

Whichever you use, dig into the architecture and learn how and why these frameworks are so popular.  The more of the "guts" that you learn, the better coder you will be.

Views: 2592


You need to be a member of TechHui to add comments!

Join TechHui

Comment by Douglas Ching on April 8, 2013 at 8:06am

Code First is really a great feature, but one thing I think Active Record has over EF is migrations.  Code First allows for migrations, but I find them more difficult to use.  It's not as automatic as it is in Rails and I often mess them up. MVC also has Gem-like functionality for distributing, discovering, installing and uninstalling packages with NuGet.

For route debugging I've used Glimpse and Route Debugger before.  They are probably not as good as what Rails provides, but Glimpse is pretty neat.

Another thing that I like about Rails is the command line.  With MVC most everything is done through and you kind of need to do MVC.  Rails is more bare bones and you can get started without installing any IDE.

On the other hand, one thing I like about MVC over Rails is the IDE. is really good when you want to trace and debug code.  Intellisense and being able to easily jump to different areas of code is nice.  ReSharper makes it even easier.  That is something I have a difficult time with in Rails even after finding RubyMine.  It might be because I'm more familiar with

I found that the main thing I was able to leverage of my MVC knowledge when working on a Rails site was basic knowledge of MVC and TDD in general.  Most of the set up, configuration, language, database, package management, etc are different enough that I had to learn a lot of new and interesting things.


web design, web development, localization

© 2017   Created by Daniel Leuck.   Powered by

Badges  |  Report an Issue  |  Terms of Service