Rails, say hello to .NET.
IronRuby went 1.0 at April 12th, and it runs Ruby on Rails for real. I demonstrated it myself to a packed room of (mostly) .NET developers at Community Day. There was a lot of buzz around IronRuby more than two years ago – back then, the hype around Ruby on Rails was at its peak and the .NET developers wanted in. It took a lot longer for IronRuby to go gold than many of us had hoped, and meanwhile ASP.NET MVC made its entry. Many ASP.NET developers were aware that the “webform” abstraction with its events, viewstate etc. is leaky and broken, and when Microsoft finally presented this “official” alternative to webforms they rallied to it and rejoiced, for now they had their own Rails-clone, but with a proper programming language and thorough IDE-support.
My presentation compared ASP.NET MVC to Ruby on Rails. The conclusion is ambiguous. I thought I’d be able to crush ASP.NET MVC with the pure greatness of Ruby and Rails, making it obvious to everyone which was the better framework and language. While Rails do support a lot things that ASP.NET MVC is nowhere near of having, the latter does – at least with the recently released version 2 – have the central elements of a proper MVC framework in place. What’s more surprising is that C# 4.0 is so much less clunky than C# 1.0, so in some comparisons of syntax Ruby is not even the obvious winner when it comes to readability. Take this example:
Before LINQ, C# would have never been able to map a collection in a such an elegant manner. In my biased opinion, I still find the Ruby version prettier and more readable, but the fact is that C# is not that far behind. It’s another syntax paradigm for sure, but it’s compact and it’s readable – that’s not bad at all.
I usually write very long blog posts. Not this time! This is just a small tip, the first of hopefully many learnings I’ll make as I am working with my first project in Rails 3.
Bundler (Github | Website) is the new way to manage gem dependencies in Rails and other Ruby applications. If you haven’t heard about it, there is (of course) a great introduction at Railcasts. It’s pretty easy and straight-forward to use, especially if you are used to the config.gem format of Rails.
However, one very common use case in Bundler’s Gemfile that is not explicitly documented anywhere I’ve seen, is how to configure gems to be installed in both development and test environments, but not in staging and production environments. You have probably seen the examples of how you can assign a gem to a specific environment using the :group option or method. So you’d probably write something like this:
group :test do gem "rspec-rails", ">= 2.0.0.beta.1" end group :development do gem "ruby-debug" end
I have worked professionally with Ruby on Rails for the past 4 years and definitely consider myself a part of the Ruby community. Before that, however, I was a .NET consultant for many years – in fact I worked with .NET from the early betas and I was very exited about replacing VBScript and classic ASP with C# and ASP.NET. Being at MIX 10 – Microsoft’s conference for developers and designers working with web and mobile technologies – has made me realize both how much the .NET community has changed since I left it – and how much it hasn’t. In this article I outline the differences in culture in the Ruby and .NET development communities as I perceive them, and voice my opinion on what could be changed.
I have a good friend named Oliver Kofoed who is a brilliant .NET developer. Oliver is an entrepreneur and has written the entire backend for Nonoba and Player IO, he has written his own object-relational mapper (ORM), templating system, multiplayer game server, content management system and so on. He has also been toying with several experimental .NET languages over the years (such as Boo) and even worked a bit on one of his own. Oliver is both curious and passionate about development, and he was in fact the one who initially told me about Ruby on Rails – I owe you one, Oliver ;)
I occasionally nudge Oliver about releasing some of his work as open source, but it has yet to happen. I don’t think Oliver mind sharing his stuff with the community, but the fact is that it takes a lot of work to prepare your code for open sourcing, especially if you haven’t build it with that in mind from the beginning. You need to take anything out that’s specific to your own applications, you have to write at least some documentation and you probably also have to make the code a bit more configurable and modular. To make that effort you need to get something in return from the community – you have to be reasonably sure that your efforts will be appreciated and that your peers will respect you for sharing valuable code with them.
Hello, I'm Casper Fabricius. I have developed for the web for 10 years, and have been enjoying Ruby on Rails for the past 5.
My experience covers communities, shopping solutions, multi-language sites, heavy back-end lifting and a wide selection of more traditional websites. I like to integrate Ruby with Java and .NET through JRuby and IronRuby when it makes sense. I am passionate about test- and behavior-driven development, but at the same time I am pragmatic and believe in getting things done.
I live in Copenhagen, Denmark, where I work for a fantastic company: Podio. I do not currently take on freelance assignments.