Code Count: Ruby on Rails vs. C#/ASP.NET
May 28, 2009 11:24

I'm going to start with this table so it's all up front.

(Widen your window if the CSS float sidebar is overlapping the content)

  C#/ASP.NETRuby on RailsRatioC#/ASP.NETRuby on RailsRatio

When I started working in Ruby and Rails back in 2005, I was mostly a Java and Struts developer. I had spent years messing with XML and type-casting and fighting logic:equal tags and building Iterators - not to mention hand-crafting my own pre-Hibernate object-relational database layers. Using Ruby on Rails felt like someone had opened a window and let in sunlight and fresh air. Things that would take dozens of lines of Java were reduced to a single line of Ruby, and entire application layers just disappeared.

I had always wondered exactly how much more efficient Ruby on Rails could be over Java and Struts, but I never had a direct translation of an application to work with.

Last fall I worked on just such a project, converting ClearFit's application from a crufty old .NET/C# application to Ruby on Rails. We kept the same screens and the same functionality - just cleaned things up and translated everything into Rails. This was a perfect opportunity to get some real numbers on how much more efficient Ruby on Rails can be compared to a Java / C# application.

I gave a presentation in early May and this was one of the more popular slides:

So, in general, a big Rails application will get the same thing done as a big C# app in roughly one fifth of the amount of code.

Since there are lies, damned lies, and statistics, here are some mitigating factors (in both directions):

  • 'Display' only counted the contents of .aspx or .html.erb pages
  • The 'display' amounts for Rails would have been less if we had used Haml, but we decided not to use it, since it would be easier to just copy-and-paste the HTML for the pages
  • The C#/ASP.NET application was fairly old and didn't use an object-relational library like NHibernate
  • Likewise, we didn't do very much 'leading edge' Rails for this project either - most of it could have been written in 2006
  • The 'Non-Display' code includes all .cs and .rb files in the projects, but doesn't include libraries, such as .dlls or items in the vendor/plugin directories, or migrations
  • Some of the C# code was very badly written, and some functions were much larger than they probably needed to be.
  • On the other hand, we didn't spend a lot of time making the Ruby code cleaner or more efficient than it was already
  • There were very few tests in the C# code, and limited automatic tests in the Ruby code (mea culpa mea maxima culpa), however, the Ruby total includes admin tools and an interactive 'testing' interface.
  • The Ruby version of the application has 56 tables in the database, while the C# version had 250 tables - but most of these 250 tables weren't referenced in the code.
If anyone is curious, the complete translation project took roughly 350 hours of development time and took from mid-October 2008 to early January 2009. It was mostly done by me, with some key help from Paul Doerwald. For more details, see the detailed presentation notes, including slides and some video clips.

A Brief Note on Twitter
May 26, 2009 08:53
Other Blog Posts
My Expanded Twitter Thread about BurgerWeek 2021 This Is Nowhere: The Server Side Building a React Native App Without Tears - Part 3 Building a React Native App Without Tears - Part 2 Building a React Native App Without Tears (Mostly) This Is Nowhere: The Memento Edition This Is Nowhere: Aspects of Accessibility Presentations About NowHere This Is Nowhere: Head-First Into React Native This Is Nowhere: Bloomsday Halifax This Is Nowhere: Why an HTML/JavaScript Single-Page App With GPS Is A Bad Idea This Is Nowhere: GPS and Wayfinding and More UX This Is Nowhere: The Single-Button UX This Is Nowhere: Don’t Just Stand There! This Is Nowhere: Finding My Duck Finding Burgers Fast: My DIY Halifax Burger Week Site "This is Nowhere" at PodCamp Halifax 2018 The Diary Diaries: Fixing Remembary's Facebook Connection Special Leap Day Edition of "Some Weird Things About Time" What's Up With Remembary Can't get pg_dump To Work Now That Heroku Has Upgraded Postgresql to 9.4? The Best Thing I Ever Did To Promote My App If You Build It, They WON'T Come #deployaday, My Big Hairy Plan for 2015 Extracting Plain Text from an NSAttributedString My Year of "Hits" Part 2: Remembary Rolling My Year of "Hits" Part 1: Remembary Rises (and Stumbles) Handy Little Test Method to Check for Translations in Rails Apps My Suddenly Slow-Waking MacBook Air Indie App PR: Keeping Control of Your Tone A Quick Note on 'clone' in Rails 3.2 My eBook Apps 2: iOS, JavaScript, and Ruby My eBook Apps 1: Introduction Quick Tip: No Sound on Mountain Lion My Upcoming Talk at PodcampHFX 2012: My Year of "Hits" Building at the Speed of Funny Screencast Tips Remembary's Cool New Picture Support Indie App PR 2: Keeping On Top Of User Feedback Indie App PR 1: How to Handle an App Disaster Giles Bowkett Diary Project 2 Remembary Video Congratulations! Welcome to Your Nightmare! How My iPad App Remembary Took Off Why You Should Have an App in the App Store (Even If You Probably Won't Make Any Money) PodCampHFX Remembary Presentation - Part 3 How I Used MailChimp Autoresponders to Promote Remembary PodCampHFX Remembary Presentation Part 2 PodCampHFX Remembary Presentation Part 1 Why AdWords Ads Don't Work for iPad Apps Remembary is Sponsoring PodcampHFX Why Can't I Resize my Views in Interface Builder? Momento and Remembary Concerning Remembary iPad-Friendly eBooks of Gracian's Art of Worldly Wisdom Project Report: PTOS2 A Quick Note on Encryption We're all LUsers Thoughts on HAML Friday Afternoon Hack - Getting Beyond the Basics Halifax Friday Hack and Back to Basics Quote from Wil Shipley FutureRuby Make Web Not War Busy Week I: Toronto Ruby Job Fair Employment.nil - the Toronto Ruby Job Fair Code Count: Ruby on Rails vs. C#/ASP.NET A Brief Note on Twitter The Hub Halifax and Mobile Tech for Social Change Deep Thoughts on Microsoft From The Accordion Guy The Two Kinds of Defensive Programming Presentation - Fixing Careerious: From C#/.NET to Ruby on Rails Enterprise! Presenting at Ruby on Rails Project Night - May 7th New Name and New Look for Careerious/Clearfit FutureRuby and More From Unspace Health Tips for Programmers This tables meme won't die Careerious - Ruby and Rails vs. C#/.NET Yeah I Use Tables For Layout, So Sue Me The Different Kinds of Done Giles Bowkett's RubyFringe presentation OfficeTime: Great Time-Tracking App for OS X Back With A New Look Non-DRY Feed torontorb Keeping Your Sanity With The Command Design Pattern shindigital Is All Grown Up! (according to the spambots) Startup Stars? I'm so bored! The Magic Words for RMagick Jennifer from Operations You see? Naming is HARD Business Software as Process Documentation Deployment note: 'execve failed' Steve Jobs on Market Research Why Canada Is Better for Entrepreneurs "Program first and blog second" Toronto Tech Collage The MacBook Air Is A Roadster RubyFringe! Quote of the Week: Steve Yegge Starting Up: Cards Great design tool: Starting Up: The Logo Quotes Of The Day: Hedge Fund Interview TSOT Ruby / Rails Presentation Night - Part 1 Moneyworks: Accounting Software for Canadians on OS X Starting Up: The Name Nice logo, but why is your site so bland? Welcome to