Putting Ruby, Rails, C#, and ASP.NET in context

By Claudio Lassala

I’ve noticed there’s quite a bit of misunderstanding among .NET developers as to what Ruby or Rails are, and how those compare to what they came to know and love in .NET. I know I didn’t understand it myself for a while. The following comments, drawn from my two previous posts (Switching to Ruby from .NET and Why should a .NET developer look into Ruby or Ruby on Rails) serve to illustrate my point:

“Had a look at Ruby but no thanks, .NET remains the way for me.”

“…are there demos or samples of Ruby on Rails that can compare with the web apps that I can create with ASP.NET or Silverlight, and components like DevExpress for the ASP.NET MVC? Is there something like that in Ruby?”

While the first comment compares Ruby to .NET, which is a comparison between a language and an entire development platform, the second comment mixes html-based applications with rich client applications built on Silverlight, brings 3rd part visual controls into the equation, and wonders whether such controls are available in Ruby (a language…).

Lots of confusion there, so I hope to clarify those misconceptions in this post.

What’s Ruby?

Ruby is a language. Just like C# is a language. Borrowing a quote from the Ruby language’s website:

“Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.”.

So how exactly does Ruby compare to C#? You’ll find objects in Ruby, along classes, methods, inheritance, etc. You’ll also find elements of functional programming; just like C# got some of that over time through anonymous delegates and lambdas. While C# has always been a static, strongly typed language, and eventually got a couple of dynamic features, Ruby is a fully dynamic language.

You can expect more posts covering how some of these features compare between Ruby and C#. You can start by checking out the .NET to Ruby: Classes post here on RubySource.

Who does Ruby belong to?

Ruby is an open source language, and as such, it evolves based directly off the needs of its community, whereas C# belongs to Microsoft, who has the final say as to what goes into the language.

With that being said, though, besides Microsoft’s implementation of C#, there is also an open source, cross-platform one provided by Mono.

Likewise, there is an implementation of Ruby from its creator, Yukihiro Matsumoto, or “Matz”, as well as Rubinius, JRuby (a Java implementation), and IronRuby (a .NET implementation). The fact that IronRuby exists should be an extra reason for .NET developers to look into Ruby, adding it to their bag of tricks when building .NET applications.

What’s Ruby on Rails?

So what is Ruby on Rails? A language? A framework? A platform? A company that transports the bright red color precious gemstone by train? Here we go:

  • Ruby on Rails (or Rails, or simply RoR) is a web application framework that follows the Model-View-Controller (MVC) architecture pattern. Therefore, it compares to the ASP.NET MVC framework;
  • Just like the ASP.NET MVC framework is built on top of ASP.NET, Rails is built on top of Rack);
  • Just like there are other web application frameworks built on top of ASP.NET (such as WebForms, or FubuMVC, there are other frameworks based on Rack (such as Sinatra);
  • Just like ASP.NET is written in C#, Rails is written in Ruby;
  • While “most” web applications built on any flavor of ASP.NET are written in C#, all applications built on any flavor of Rack are written in Ruby.

Who owns Ruby on Rails?

Rails is an open source framework, and much like Ruby, its development is driven by the community. New features are added to the framework based off real world needs faced by their users.

What kinds of application can I build with Rails?

Since people ask questions such as “can I build applications similar to Silverlight with Rails?”, I assume clarification is needed there. To just say “you can build web applications” isn’t enough anymore. Is it a web application because it’s hosted on the web? Or because it runs in the browser? Or because it is html-based? Or because it accesses data that comes from the web?

A typical Rails application has the frontend part, which is html-based. As such, it runs in the browser. The html-pages are served up by controllers in the web server. These controllers load up models populated with data, which comes from some place the web server has access to (maybe a database in the same box, maybe a web service someplace across the planet). Once the models are up, the controllers select the view template that produces the html that is to be sent down to the browser.

Another typical Rails application may have everything just mentioned in the previous paragraph, except for the html frontend. So the application provides an API (usually a RESTful one) that other applications can call over the web. For the .NET developer, this is kind of like creating ASP.NET Web Services, or WCF Services. In this case, the other applications consuming this API can be of any kind; for instance, an iPhone application, a Silverlight or WPF application, an ASP.NET application, etc.

It is not possible to create a “client-only” application with Rails, such as the ones created using WPF, Silverlight, etc. You can mix and match technologies, though. For instance, the current project I’m working on is mostly built on Rails, but it also has a part written in Silverlight, which consumes and pushes data to a RESTful API created in Rails. The Rails part of the application also consumes an API created in Java by a 3rd part vendor, and this vendor also consumes my API in order to send over some data. Another part of this project will include applications for iOS (iPad, iPhone…) and Android, and this application will also consume the API’s provided by the Rails application.

Are there reusable components?

.NET developers are used to libraries that provide all sorts of specific functionality, such as encryption, imaging, reporting, etc. Similar things are available in Ruby on Rails, and they’re often called “gems”. There are tons of them out there: lots of library that gives you a plethora of functionality that you can add to your applications (Ruby on Rails itself is a gem!)

Recently, .NET developers have also been introduced to NuGet, a library package manager, that facilitates adding external libraries to projects, bringing in also their dependencies, adjusting settings on the project, creating specific code generators, etc. Such a thing has been around in the Ruby world for a couple of years now, and it’s called RubyGems.

What about “visual” components?

.NET developers love their 3rd party visual controls! Those existed in abundance for WinForms, WebForms, WPF, and Silverlight. Far less options exist for ASP.NET MVC. I have not run into any such thing for Rails. However, as far as I’ve seen, Rails developers are quite happy with simply using CSS and jQuery in order to create awesome websites (which are things that .NET developers are using in their ASP.NET MVC applications as well).

There are always developers who want to get the “ubber 3rd part grid that can show a gazillion of rows from a database”. To tell you the truth, I used to be like that. Not anymore. If I have a situation where I need to handle a ridiculous amount of data in a grid on the client side, that means I’m doing something wrong. I talk more about that on my “You have been deleted!” post.

Is Rails cross-platform?

The short answer is yes. Here’s the long answer:

  • Any machine can access a Rails application: a Mac, a PC, a smart device…
  • Usually, Linux servers host these applications, even though they can be hosted in other operating systems;
  • These applications can be developed on any platform, even though Mac and Linux are by far the most popular environments. I’ve done Rails development on Windows for a couple of months, and even though that worked out to an extent, certain things either didn’t work as well as they do on a Mac, or were just too slow (such as when running automated tests).

Summing up

Ruby on Rails is just a web application framework, similar to the ASP.NET MVC framework, except that Rails has been around for a longer time. I hope this post helped clarifying how some of the bits and pieces of Ruby on Rails relate to the things .NET developers are used to.

  • Excellent article Claudio! And a great summation of what Ruby, and Rails is, and how it stacks up against .NET.

    Ruby/Rails is not for everyone, but there’s so much to be learned from picking up a framework or language that isn’t the one you work on at your day job. My ability to code in .NET increased significantly just by looking into Ruby, and playing around with the language and Rails. One example is that Ruby helped me to grok patterns and concepts that were used commonly between .NET and Ruby.

    • Thanks, Gavin.

      Yup, I totally agree. I do believe my code in .NET has improved after working with Ruby, too.

  • Excellent article.
    Thanks for that. Keep up the good work.


    1. Microsoft keeps on releasing new versions of MVC very often.
    2. ASP MVC 3 is good, a lot of copies/ideas from Rails, but still behind.

    • Thank you, Panayotis. Glad to know you enjoyed it.

      You’re correct. The ASP MVC team at Microsoft is probably one of the best teams in there. But yes, they *are* still behind, and they don’t take in commits from the community. :-/

  • frostymarvelous

    nice article.
    Personally a php fan, but tend to read articles from other languages.
    I believe personally that to get better at any kanguage, we need to look at others. You pick great concepts not available in your language of choice.
    Rails is an item on my must learn list.

    • Thanks!

      Once in a while I get asked how Rails compares to PHP, but I know pretty much zero about the latter. I’m planning on looking into it so I understand the differences and similarities.

  • Jose Gonzalez

    This is exactly what I was looking for. Thank you for writing this article Claudio. As I started to look into Ruby, I kept hearing all these buzz words (RoR, Synatra, Ruby Gems, etc.). I was confused which discouraged me to look further. I didn’t know you could create wcf-like services, which I think it’s pretty damn nice.

    I (still) like the .NET comfort zone. But the more posts I see from you and Gavin, the more I like it.

    I’ll leave the religious (.NET vs X ) wars to the zealots while I enjoy learning something freaking cool.

  • kunal

    Awesome article Claudio! Helped a ton..

  • Interesting article, but it sounds pretty biased. Ruby is driving me nuts currently… the dynamic, anything-goes attitude causes a huge number of problems. We all know what those problems are, and they are the reason strongly typed languages were invented. Why the fervor to go back to the dark ages?

    I mean… really… the fact that this is allowed is a big problem… what is the data type of X? Who cares, right?

    x = 3
    x = “a string”
    x = [“an”, “array”]
    y = x + 3

    What the hell will that code do? Why is that allowed?

    • In one line: With Great Power, Comes Great Responsibility.
      When given raw power, some people will get the cold feet, but that does not mean that a dynamic language is something that should not exist, and the golden rule is: If you are not comfortable don’t use it. OR try and understand what the purpose behind such features is. :)

Get the latest in Ruby, once a week, for free.