8 Reasons I love Ruby
In the last year I abandoned .NET for Ruby in my side projects and actual job. In the interest of not explaining my rationale over and over again, I'm going to talk here about why I love Ruby so passionately.
Ruby is vastly more productive than Java or .NET.
I had heard that Ruby was more productive for years. Each time I rolled my eyes, confident these developers lacked my Resharper/Automocking/Generics/Fluent API Magic. Then l developed in Rails at GiveCamp last year and holy dear god I was nearly as productive in this framework I barely knew as I was in ASP.NET MVC, a platform I knew inside out. What the hell was I doing with my life?
I am not an outlier in feeling this way. Never in the history of man has a software developer said "I'm stuck doing Ruby for my day job but I'm really hoping to find a job in .NET or Java."
Thoughtworks, a company I'm pretty sure only employs geniuses, conducted a survey on the productivity of their Ruby projects. Out of 30 projects surveyed, 80% reported being at least 50% more productive because they used Ruby instead of Java or .NET with more than 60% claiming a productivity increase of 2x or greater. (Only one project (3.3% of projects) reported actually being slower for using Ruby, while 90% of projects reported some increase in productivity.)
In my own estimation, I'd say Rails is somewhere between two and three times more productive than ASP.NET (MVC or Webforms). That means I believe a 5 month .NET project could be done in 2 months in Ruby!
Why is Ruby so many times more productive than .NET or Java?
1) Gems
There have been rumblings about .NET's need for a package management system, but that is not what makes the gem ecosystem.
What makes Ruby Gems awesome is that, for various reasons, there are gems for everything! So many problems are already solved!
Video of me whenever I run "gem install"
Some recent requirements I solved with a simple "gem install":
- PDFs. gem install pdfkit, add two lines of code and bam, I can add .pdf to a route and get a pdf version.
- Excel. just setup the mime type with one line of code, call .to_xls on any collection and I get an excel doc returned!
- Verb conjugation. I need to figure out how to get the past perfect test of a verb. "gem install verbs"
- Here's a hard one: I'd need profile pictures uploaded to amazon s3 and cropped to three different thumbnail sizes. I also need to run asynchronously so my user doesn't wait 30 seconds after updating their profile. And I should show a default picture of the appropiate size if they haven't uploaded one. This would take how many days in .NET? In Ruby I just had to gem install delayed_paperclip and just call one method in my model. I had this working in minutes.
Then there's twitter, devise, pickle, formtastic, friendly_id...
2) Consistency
Ruby tools evolve naturally. Survival of the fittest. The best tools rise to the top; bad tools get ignored. There are different ORMs, view engines, etc, but they usually only exist when they solve a different need. Ruby tools are crafted to fulfill actual needs and don't have to compete with tools dreamed up to be marketable. There is no split in the Ruby community where half the developers use MSRake or MSSinatra. Every single developer knows and uses Rake!
Because everyone knows Rake, ActiveRecord, Cucumber and RSpec, being a Rails Dev actually means something. I have to be very skeptical when interviewing a ".NET developer" and figure out what kind of .NET dev they are.
Every .NET project reinvents the wheel with deployment, ORMs, Migrations, project structure, while every Rails project is nearly identical. This might sound boring, but these inconsequential decisions are already made and free you to solve the actual business problem. (This consistency is also what allows so many gems to integrate so seamlessly) It also lets me be confident any experienced Rails Dev is a good fit for my project. In fact, I hired someone on oDesk this month to help out on a Rails side project. I looked at his github, saw he knew his stuff and he was able to dive in with no ramp up time at all. I would never dream of doing that in .NET.
3) Git/Github
With DVCS and the ubiquitness of github, if I need to add functionality to a project, I just can! I just fork, reference my fork in my GemFile (this lets my repository build my version of the gem instead of the one at rubygems.org) and issue a pull request to the project's owner. Hopefully my change gets pulled into the main repo and I can go back to referencing the main gem. It's not the end of the world if that doesn't happen, thanks to the beauty of git, I can keep pulling in new changes from the main repo. The fact that this project will actually have automated tests lets me be comfortable that my patch did not break any functionality.
On that note...
4) Testing
Testing isn't controversial in the Ruby community. Projects without tests are seldom taken seriously. On Codeplex, it's difficult to find a .NET project with unit tests.
Unit testing in a static language is much harder. For example, you can not use the ActiveRecord pattern, because you would have no way to mock your database operations. You have to wrap every single service in an interface and inject every depdenency. That means wraping things that seem outright silly, like having a class and interface just to wrap DateTime.Now so you can stub it for your tests. In Ruby, you can mock anything at any time. (And for the usecase I just mentioned it's of course solved, simply gem install timecop.)
5) Ruby, The Language
Much is made of this, so I won't dwell here. However the power, the beauty, expressiveness and openness of the language is what allows this community to thrive in the first place, so it definitely shouldn't be overlooked.
6) Things just work
The Ruby community hates configuration and complexity. When I install a gem, it usually Just Works.
Ruby developers seek to ease the pain .NET developers don't even think about. Ruby has made great progress in removing the pain of XML, CSS, JavaScript Includes, running unit tests, managing dependencies, automating deployment and even JavaScript testing,
7) Heroku
This fits in the Things that Just Work bullet, but no place on this planet can you set up a website in 30 seconds with three lines of code. Then once you're set up, you can just click a checkbox to get email notifications of exceptions, or code analysis, or a MongoDB database or a bulk email service. And deployment is just "git deploy heroku." Oh yeah, and its all free until you start doing signficiant traffic. I never dreamed of hosting so many websites so painlessly.
8) Simplicity
Have I mentioned that all these problems are solved and all this shit just works all the time?
I realized how far I had strayed from .NET when a .NET friend told me "Yeah, I got Azure set up in two hours."
I replied, "Ouch, I'm sorry."
"What? I thought that was pretty good."


20 Comments
Also Groovy's "MissingMethod" and "ExpandoMetaClass" allow for all sorts of awesome language tricks.
If you need to live in a world of Java... Groovy / Grails will make you love your job (again?).
I kinda' regret getting started with rails, actually. There's a lot of magic thrown at you all at once (it's all powerful but somewhat overwhelming), so I actually think when learning Ruby and friends it's' easier to start out with Sinatra. There's no frills there, and you just pull in packages as you need them and understand what they bring to the table.
I'll also add a caveat to my "It Just Works" statements with "if you're on a *nix" system." Before I got a Mac I had found that working in an Ubuntu VM was better than working on my Windows machine directly. Ruby 1.9 seems relatively good and fast on Windows, but you might lose some of the seamlessness I raved about.
The other thing is that we as devs are taught by our communities to 'look up to' constipated constructs like design patterns. Nobody ever questions the fact that if our languages were better designed, then we would not need DPs because our code would be simpler, more expressive and have better composability.
The only thing that turned me away from Ruby/RoR was that it was too implicit and magic for my taste. Python and Django was immediately much more palatable because it remains DRY while removing the guesswork and ambiguity. The only thing that sucks about this whole ordeal is having to continue working in .NET to make a living and all the while knowing how futile and counter-productive the platform is when compared to the competition.
Self-reported performance metrics are not very scientific. Is anyone going to report that they are less productive NOW than they were a few months ago? You could probably find the same kind of metrics with any language or any process.
I do think that they were more productive with Ruby, but the survey methodology is wrong and does not prove it. A right way is to collect metrics that cannot be directly influenced by the participants' knowledge.
I'd be interested to hear of any pitfalls of Ruby or Rails - or things you like more about .Net development. Maybe there aren't any.
For example (ear muffs, ruby developers) I find type safety to be very handy in development and refactoring, but some call it a crutch that you don't need in a more expressive language. I've also heard dealing with gem versioning can be a nightmare. Any thoughts?
That being said, when you look at the caliber of apps written in a single weekend in events like rails rumble.. and through my own experience doing things in minutes my .NET wired brain insists will take hours... I find it difficult to not believe those ThoughtWorks survey results.
Well, if you do TDD you build a system correctness safety system instead of a type correctness safety system (the compiler). That being said, even if you don't test.... as Crockford says, the biggest class of errors compilers usually catch are typos.
I do sometimes miss refactoring with Resharper. JetBrain's RubyMine can be a good pick for the IDE inclined and it has refactoring support, but basically it's just an adjustment of "okay, lets pick a good name now so i won't have to change it later." But, with far less code comes the advantage of manual searches not being nearly as bad.
These days bundler and rvm mitigate ruby version issues, so I don't think that's much of a liability either.
Test.
Problem is that there are those of us who have seen the other side and know how easy it can be. But for all the people who has only seen .NET or Java it is all too good to be true. So our praise goes unheard as folly talk by crazy people :/.
Thank you for a good catch of what Rails bring to the developer community.
1. Eiffel made DbC a reality. Congratulations to MS for doing the same thing 25 years later.
2. DbC does not require a static language.
When you say they miss linq do you really mean they miss intellisense? What does linq do that ruby doesn't (other than expression trees)?
I'm just saying what I heard from the others about missing linq (lol).
re DbC: Theorem provers require static languages. It's now matured to MS Contracts. Before that, it was not possible due to computational constraints.
I have taken up Ruby as the programming language of choice very recently; this post further reinforces my decision. I am also taking away a list of Ruby related items to learn about from this post.
heres my latest ruby code...
^*S(*AD(CC ASAS::::ASD??!F(*)AS**%!!(&#(!!
Most of people who invent Ruby are actually claiming that it's just more cool. In some points it truly rocks. But some things that are natural for ruby developers weren't invented by Ruby community itself. The only thing that was truly innovative and rocking the whole Earth is Gem system. Therefore' it lacked a well-written package manager until Bundler came out.
The major difference, as for me, is open-mindness of the community itself. If you ask Ruby developers whether they used some nosql db, 80% would answer "of course, man, i did". with .net / java people, it's not like that most of time.
Most of things you named (consistency, testing, git, things that work, simplicity etc) are actually good engineering practices. they're applicable to Python, Scala, or anything at all. But that's wounderful how Ruby/Rails _make_ people write about Ruby/Rails. It's impossible to stay calm. You either love it or hate it ;)
The windows ruby team has made some real breakthroughs recently, integrating a toolchain that allows gems with native components to be compiled in a *NIX fashion. Early reports are that it is really really good.
Also about Heroku: You can throw money into Heroku to allocate resources to even the free plans. This has made Heroku a bit popular with Facebook developers, and iPhone developers who need data backends (apparently). If your app goes viral, or gets techcrunched, you can put dollars in the meter to ride out the traffic spike.
@josh
Refactoring is a lot easier when:
a) you have 10% of the code of an equivalent Java/.Net project
b) you have less sprawling inheritance hierarchies with shared method signatures (as a rule you will not see a lot of inheritance in Ruby projects). Changing a method signature in an interface will require a witchhunt of all the usages in derived classes.
c) its easy to keep tests up to date
Also TDD in Ruby is stunningly easy by comparison with JUnit. The verbosity of testing java projects often leads to poor test quality or poor test coverage. You can reach a point where tests in java cease to be effective documentation. In Ruby there are situations where teams use Cucumber (an acceptance testing framework) exclusively for all automated tests (including unit tests) and finding it a workable solution.
Leave a Comment