Why not just use Ruby on Rails?

I have been following a couple projects lately who attempt to make .NET look and act more like Ruby on Rails.  The first one is the Castle Project who have their implementation of ActiveRecord and a Rails-like MVC (model view controller) web framework MonoRail.

Another project is SubSonic which is basically a utility that generates a Data Access Layer for your project and turns your database tables into entities in code.  SubSonic was inspired by Ruby on Rails and the creator is trying to apply some MVC principles to it.

There is an ongoing debate between both of these camps as to why MonoRail is the purest ASP.NET MVC framework and why the SubSonic implmentation is not, Ayende makes some great points here.  Make sure to read the comments as Rob Conery, the SubSonic creator has good follow-up.

I created a test web application using MonoRail and this implementation is as close to Rails in .NET that I have seen.  It takes advantage of handlers and makes the controller be the central point of control in a .NET web application unlike ASP.NET WebForms, where the view is the obvious controller. 

SubSonic does a good job but I don’t think it’s fair to say they are even close to implementing an MVC pattern, data broker yes but not MVC.  This is OK, nothing wrong with the implementation.  I have done a couple small projects with SubSonic and it works very well.

Jeffrey Palermo talks about Microsoft creating an MVC framework for ASP.NET.  I was surprised to see this but I guess Microsoft wants in on the Rails goodness too.

So with all of these people trying to “cash-in” on Rails and all that is good, why not just use Rails?  Why try to take an architecture, ASP.NET WebForms, and make it something it is not?  The square peg in the round hole idea comes to mind.  Using a tool that is right for the job makes the most sense.  Sure, MonoRail comes close but it is not Rails, it is not as clean an MVC implementation as Rails from a developer stand point.  Why not use Rails when it’s the right tool? 

What about IronRuby?

Since hearing about Microsoft’s IronRuby project and bringing a supported implementation of Ruby on the CLR I can only imagine the possibilities.  Once the implementation is Ruby 1.8.x feature-complete it will only be a matter of time when Rails is running on IronRuby, this will be a good day for the MVC fans indeed.   This will be the day it all comes together for Ruby and C# or whatever your favorite CLR language is, to be writing code it it will all just play nicely together.  I think the most important aspect to Microsoft’s success with Ruby will be keeping pure and focusing on the core Ruby path and not adding the Microsoft-esque features probably desirable by the internal language group.  While Jon Lam is driving the product I think they will be good.

Martin Fowler has an interesting post about Ruby Microsoft as does Ola Bini and Charles Nutter (Mr. JRuby).

I don’t talk about JRuby as I am not a Java guy and don’t spend any time writing Java code.  My feeling is that JRuby was really validated once Rails ran on it.  Since Rails is the Ruby “killer app”, it stands to reason that once you can run Rails you have arrived.   This will be the arriving point for IronRuby, running Rails.

I don’t know if we will ever see a truly embraced MVC implementation on the CLR if it is not Rails or some future Rails-derived-cousin.  Some people think Microsoft won’t let Rails be successful on the CLR, which is pure garbage.  When all is said and done, Microsoft wants to sell server licenses and if they do it because of ASP.NET WebForms or Rails on the CLR, it doesn’t matter to them and frankly, shouldn’t matter to the developer.  Again, pick the right tool for the job on a platform you can support.

Rails will run on the CLR one way or another, either from Microsoft or another open source project.  It is just a matter of time.

Advertisements

12 responses to “Why not just use Ruby on Rails?

  1. nice post.

    I think your point – “pick the right tool for the job on a platform you can support” is a good one.

    That being said, to most of us and our day jobs – we dont have a choice what platform we use. so, when we see other frameworks out there offering some really great architectural solutions we want to drink from that well too, if ya know what I mean.

    I’ve discussed MVC recently over at my blog scribesonic.com if you want to read more.

  2. Thank you.

    I understand the issue with the day job and not having choice. I guess part of my point is we spend a lot of time chasing MVC on ASP.NET when if we take a bit of that time to learn a true MVC (Rails), it will end up on the CLR anyway.

    Part of the fun is the pursuit. It’s all good.

  3. What prevents MonoRail from being a true MVC in your opinion?

  4. Sorry for my mis-worded reply. What I meant to say, was why we are wasting out time trying to make ASP.NET into something it is not, MVC.

    I think learning a “true” MVC was not trying to imply MonoRail is not an MVC or one not worthy of learning but spend your time learning an MVC that is Rails and the Rails family. If it be MonoRail, that’s great or if it is Ruby on Rails then great too.

    I would like to hear about fairly high transactional sites running MonoRail. Where can I get details? Ruby on Rails has Twitter. Who runs MonoRail on a decent scale?

  5. http://www.traderydex.com for one. More can be found on the forum (topic ‘Who is using’)

    And btw, Twitter might have a heavy load, but it’s definitely not ‘transactional’,

  6. Yeah, saw the forum topic of “Who is Using” but none seemed impressive, most seemed like sample sites just to say, hey I use MonoRail. I will check out Traderydex.com, thank you.

    OK, if you want to challenge semantics, no…Twitter is not transactional but I think you understand what I am meaning when I said what I said. I will be more careful next time. Twitter is a heavy load and a great display of what can be done with Rails. This isn’t to say it can’t be done with MonoRail, as it probably can. I certainly would like to see such a high profile example.

    I will have a better feel for MonoRail once I produce a good running solution with it.

  7. Possibly because Rails apps don’t really tend to be very MVC (the business logic seem to tend to end up in the controller rather than the model so it just devolves into something more like “template seperate to code” than anything really MVC), so people who actually want to do MVC development will tend to use something else.

    Possibly also because they want to use a DAO layer that’s designed to support foreign keys and sensible database design rather than laughing at
    them.

    There are a lot of things to like about rails but it’s often easier to re-implement those on top of a mature platform than it is to fix the glaring failures of rails for applications on any complexity – I can think of quite a few people using perl and the Catalyst MVC framework who came from rails because it was too limited for their requirements, and I imagine the motivation is similar.

  8. What glaring failures do you see for a Rails application on “any” complexity? I do not have a production Rails application at this point, I would like to hear the details so I can be better prepared.

  9. I posted the below thoughts on Scott Belleware’s blog based on my experiences in trying out RoR:

    I think Rails is cool and is useful to try out and learn from. But there is no way it meets the bar for the majority of enterprise web applications built today. Here are just a few of the big issues I have with it:

    1) The Rails ActiveRecord implementation for SQL Server and Oracle is spotty and pretty much unsupported. Put any decent load on the application for a sustained period of time and you will start throwing runtime errors. When I reported these errors to Rails team members I was told “yeah, you should really only use MySQL or Postgres”.

    2) Prepared statements are not supported with ActiveRecord, and connection pooling support is weak, which means your database really groans.

    3) ActiveRecord is a leaky abstraction, and the Rails implementation requires you to step out of the abstraction a lot. If you are going to do any advanced reporting scenario, or perform any optimized query, you need to write embedded SQL that you exec. When you do this you are on your own to handle escaping SQL values and protecting yourself against SQL injection attacks. The code you end up writing here is ugly and not at all DRY.

    4) Migrations (which are a cool idea BTW) don’t handle primary key/foreign key relationships, which means they quickly become useless as your schema grows beyond the trivial. Test fixtures in Rails likewise end up choking as you introduce foreign keys into the mix. Most Rails developers (and a lot of Rails tutorials) simply avoid using referential integrity at all in the database layer. I am fine doing this with my home photo album application. It is inexcusable IMO for enterprise development. It really sucks that the Rails framework team doesn’t have any interest in fixing this.

    5) Support for Windows authentication and Active Directory integration is weak and hard to configure. I gave up after 8 hours of trying to configure a forward proxy between IIS and my Mongrel server.

    6) Asynch network execution isn’t supported in Rails, which means any network access to a REST or SOAP backend blocks the server process that calls it (and each server process in Rails is usually at least 30-50MB in size, and only processes one request at a time).

    7) Rails and Ruby code execution is slow. Read any of the reviews/feedback about ThoughtWork’s new Mingle application and you will almost certainly see the feedback “and…it’s a little slow”:

    http://www.infoq.com/news/2007/07/mingle-released

    http://www.itwriting.com/blog

    ThoughtWorks has more Rails IQ than any other shop out there right now. If they can’t make a (still pretty feature basic) project management web front end run decently with only a few browsers accessing it, I really worry for the rest of us…..

    There is an easy way to address all of the above issues, though, which is to use MonoRail on .NET. It provides the same clean MVC web architecture, but has much better database and ORM support, great performance, much easier deployment, and allows you to use ReSharper with VS.

  10. Great comment. I did see your comment on Scott’s site.

    This is the kind of information I was looking for. Too often comments are so biased it is hard to get a good feel for the real technology behind-the-scenes where a technology has it’s weakness.

    I am going to commit to learning MonoRail better and check out the ProMesh.NET framework to see how MVC can be done well on .NET. I am impressed by some of the sites I have seen running MonoRail. One in particular is http://www.flaglerschools.com, nice and fast.

  11. Pingback: Repsonding to Comments About Rails - Scott Bellware [MVP] « Accidental Technologist

  12. Just to be clear I didn’t liken anything I did RE the MVC templates to MonoRail. Some people don’t like ActiveRecord – those templates were for them.

    @Robert – your critique of Rails is ridiculous:
    “But there is no way it meets the bar for the majority of enterprise web applications built today” – define “Enterprise web application” for me please…

    Critiquing Rails for not playing nice with SQL Server is like ripping ASP.NET (and Visual Studio) for not playing nice with MySQL. BTW – which DB is more widely used do you think?

    Connection pooling “is weak” – explain that please.

    “and the Rails implementation requires you to step out of the abstraction a lot” – you cited reporting, but that’s not “a lot”. There are a multitude of ways to work with Rails doing rollups etc – it sounds to me like you didn’t try this.

    Point 4 is completely uninformed. You set relationships in your model, not the DB. Also, if you don’t set a PK, one is set for you. While I like DRI in the database, one could argue that it’s OK to push this to the app layer – EBay does. Either way Rails doesn’t prevent you from setting FK relationships in the DB.

    “I gave up after 8 hours of trying to configure a forward proxy between IIS and my Mongrel server” ummmm – what? IIS doesn’t proxy to ports other than 80. Why use ActiveDirectory on a platform that’s NOT based on windows? If you want this – use ASP.

    “Rails and Ruby code execution is slow” – on windows, yes because of the lack of CGI support. In general this is not the case.

    I’m normally a little more reserved with my thoughts, but dude if you’re going to write stuff like this, do your homework.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s