February 28, 2008
The Pragmatic Programmer has long advocated that it's good practice to learn at least one new programming language every year. If you're a web developer, it's at least as important to pick up a new framework from time to time.
Most Ruby developers tasked with building web applications are clearly working in Rails at this point. However, there are some great alternative frameworks out there that also deserve a look. Do yourself a favor and dig in; learning a different framework can change the way you think about the box you're working in.
Some of these frameworks borrow heavily from Ruby's premier web framework. Many offer significant improvements in speed and flexibility. Some can be used as outright replacements for Rails. Others are perfect for running as supplemental services, when something faster and closer to the metal is needed (consider the case of handling large file uploads). And a few have entirely different goals in mind, such as providing a whole web application stack in a single file for easily deployed mini-applications. But despite all their differences each of these frameworks have at least two things in common: a great dynamically-typed human-friendly base language (Ruby!) and a smart, enthusiastic core group of contibutors.
Note that this list isn't intended to be exhaustive; if your favorite isn't included, make sure to leave a comment and a link.
CAMPING: A micro-framework weighing in at less than 4k, Camping was developed by prolific Rubyist _why back in early 2006. It uses Markaby for representing HTML in pure Ruby code and ActiveRecord for database access. Ideal for writing single-file mini applications (served with or without chunky bacon).
SINATRA: A recent entry into the Ruby web framework space, Sinatra is designed as a minimalist RESTful framework that sits on top of Mongrel. It's core is a simple domain specific language for defining RESTful actions and responses. Also ideal for single-file mini-applications. ORM agnostic and built on Rack.
WAVES: A new "next-generation" framework that leverages Rack and Mongrel (for HTTP interfacing), Sequel (for ORM), and Erubis/Markaby for view templates. One interesting feature of Waves is its use of request lambdas, which means that whole requests are mapped to a block of code rather than matching simple paths to a controller with a set of implicit actions.
HALCYON: Small and fast, but the real distinguishing characteristic here is its exclusive use of JSON for requests and responses to/from AJAX client applications. Another big win is that it's extremely well documented, in stark contrast to many of its competitors. It's also built on top of Rack.
SWIFTCORE IOWA: The grandaddy of Ruby web frameworks, IOWA was originally developed by Avi Bryant as a port of the NeXT WebObjects system. Kirk Haines has since taken over the project and revamped it, providing support for evented and clustered modes of operation as part of the Swiftiply project.
NITRO: Another long-standing option that predates Rails. The Nitro project also includes Og, an alternative ORM package.
Clearly there are a lot of options. So should you ditch the Rails kool-aid for [Merb, Waves, Sinatra]? Well, no, not necessarily. It really depends on your situation. Rails itself is a fine web framework, and there's a reason it's drawn so many people into the world of Ruby. At this point it's well established and relatively mature, and supported by a top-notch community; there's little doubt that it will continue to grow and thrive for quite some time.
With that said, monoculture is rarely a good thing, even in development circles (surprise!). Having this variety of web frameworks is healthy for the Ruby community. It not only gives developers options but also allows for exploration of innovative ideas that may not "fit" inside the Rails aesthetic.
Check one of them out if you have the opportunity; I think you'll be glad you did.
 Rack is a framework for building web frameworks, sort of a standard interface between Ruby web servers and Ruby web frameworks with a simple API (similar to Python's Web Server Gateway Interface). A large number of these web frameworks are built on top of Rack, which is a Good Thing. We'll be talking about exactly what this means and why it's important next time...
About the Author(s)
You May Also Like