Merb is the new black

— October 31, 2006 at 09:04 PST

According to Ezra Zygmuntowicz, I just deployed to production the second Merb app ever written. Woo-hoo. Or today, maybe I should say Woo-hooooOOOooooOOOOOoooo!

If you don't have your ear to the ground, you may have missed hearing about Merb. It's Ezra's new mini-framework written in Ruby. It combines a Mongrel handler and a framework that can route requests and render ERb templates. (Mongrel + Erb = Merb) Ezra started Merb as a better way to handle file uploads. Rails isn't particularly nice about uploads - its single-threading can lock up listeners for long-running actions like uploads, which is no fun. But Merb can do multiple threads, so it doesn't lock up and happily processes multiple requests with only one Mongrel process.

Like most of what I do these days, my Merb app is an internal tool so I can't show it off. But just to let you know how cool Merb is becoming, let me give you the rundown. I needed a little web service that allowed me to upload RPM package files and add them to our own private repository, then run a script to rebuild the repository metadata. So I wrote an extremely simple app in Merb. It consists of one Controller with just one action. Including configuration, the whole thing is under 40 lines of code. I didn't need to make a view template since all I wanted to do was return various result strings, and I could easily do those inline. I also wrote a little client command line script in Ruby that wraps curl to upload the files to the web service. (I had to use curl because Ruby doesn't have a simple solution for doing multipart file uploads.) Most of the code in both the service and the client script is actually error handling, checking and reporting for invalid file uploads.

Working in a pre-0.1 framework can be rough-going. But I'm having fun working with Merb and finding bugs for Ezra, and making some small contributions to the development of the framework. I'm going to keep kibitzing in with Ezra on Merb and helping him with some features as I'm able. It seems like it has the potential to be a good sidekick for Rails for an app that needs uploading, and a nice, simple alternative for small apps that don't need all the power that Rails provides.

3 commentsmerb, rails

  1. AndrewO2006-11-01 08:22:41

    What made you choose Merb over something like Camping? The reason I ask is I'm also looking at thread-safe microframeworks for when Rails is overkill. Any particular place where Merb really shines?

  2. Josh Susser2006-11-01 08:34:46

    @AndrewO: Camping has a bit too much meta-magic going on under the covers for me. Merb is such a small amount of code that I can easily understand what it does, and it's very fast and lightweight. Plus, I like Mongrel.

    Merb is still a young framework, but I think it has a lot of potential for doing simple things faster and easier than Rails.

  3. Keith Fahlgren2006-11-01 10:18:03

    Thanks for the notes on using Merb. I'm considering replacing a tiny Rails app that does essentially the same thing with Merb.

    On multipart POST in Ruby:

Sorry, comments for this article are closed.