2 min read

MythBusting -- Merb Style

The Rails team has lately been out in full force trying to bust some myths that seem to have come from the Merb community. In a reddit comment, in attempting to rebut a claim that Merb was significantly smaller than Rails, bitsweat made this "myth-busting" claim:

The merb stack is about 30KLOC; merb-core is half that. Rails minus Active Record is 46KLOC.
That seemed wrong to me, since I've recently clocked in merb-core at just 7,000 lines of code, and I know that merb-more plugins are relatively small, so I decided to do some counting.

My tool of choice: find lib -name ".rb" | xargs cat |grep -v "[1]$" |grep -v "[2]*#" |wc -l

It may be relatively coarse, but it should be close enough to the actual figure to get us some real numbers. In case you need help there, I'm getting all Ruby files in the lib directory, catting them, then removing lines that are just whitespace or begin with "#" (comments).

Drumroll please.

merb-core clocks in at just 6,944. If you add in all of merb-more but auth, exceptions, and slices (features that Rails doesn't have), that "bloats" us up to 13,322. If you add in those plugins (which clock in at a "massive" 2,282 LOC) we're up to 15,604. Finally, throw in extlib (our "clone" of ActiveSupport) and we're up to 17,291.

Next stop: Rails.

As per bitsweat, we did not count ActiveRecord. We also didn't count ActiveResource or ActiveModel, which don't have analogues in Merb.

Starting with humble action-pack, it clocks in at a "tiny" 12,126 LOC. action-mailer clocks in at a "miniscule" 6,405 LOC (take that, merb-mailer, with your bloated 216 LOC). ActiveSupport clocks in at 23,217 LOC. I wonder what they had to leave out to keep it so small compared to the extlib "clone".

And finally, railties, a veritable smorgasbord of Rails extras, clocks in at 5,447 LOC.

merb-core + merb-more + extlib clocks in at 17,291. Rails clocks in at 47,195.

As you can see, it's a tie.

Oh, and I forgot to mention that Merb contains rack handlers for mongrel, thin, ebb, fcgi, cgi, webrick, etc. which clock in at over 700 LOC. In Rails-land, that code is contained in the individual gems (such as the mongrel or thin gem).

UPDATE: When you remove the LOC that's the result of bundled gems, it's still a tie, with Rails clocking in at 23,923 and Merb clocking in at 15,009. See my Nov. 15 post for a more exhaustive treatment of modularity.


  1. [:space:] ↩︎

  2. [:space:] ↩︎