Life Beyond Rails: A Brief Look at Alternate Web Frameworks for Ruby
Before we get started, let’s address the elephant in the room. Rails is great. It really is what you need for large scale production applications most of the time. It has history. And if you got started in Ruby working on the web, chances are Rails is what you are most familiar with. All these things are a fair argument for Rails as the framework of choice for many projects.
The point of this article is not to… derail (sorry, could not resist!) our beloved Rails. The main goal is to shed some light on alternatives that you may or may not have been aware of. Some will focus on small scale projects, others fast prototyping, but all of them will work with Ruby and hopefully you will have fun exploring the frameworks and micro-frameworks that help bring this great language to the web.
Cuba Microframework
Cuba is one of the most easy to start with micro-frameworks currently available to Rubyists. Written by Michel Martens, the key to Cuba is simplicity. With the avoidance of large scale overhead, this micro-framework is designed to build and deploy simple apps while avoiding bloat and unnecessary functionality.
Like many micro-frameworks, Cuba is Rack based. Rack minimizes the interaction between the webserver supporting Ruby and the framework itself. This helps improve app response times and makes using the framework, in this case Cuba, fairly simple.
One of the best parts of Cuba is the documentation. A walkthrough guide is available online and allows anyone to look into and take advantage of Cuba’s functionality. After working for a short time with the walkthrough guide you will have a simple Twitter clone called Frogger. At this point, you should be familiar enough with Cuba to start using it in your own projects.
In addition to the walkthrough guide, there is a small app to test getting Cuba setup on a server.
Trailblazer
Technically not a framework, Trailblazer is the latest gift from long time Ruby punk rocker, Nick Sutterer. The idea behind it is to help Rails to work more efficiently as a framework by enforcing encapsulation and adopting a more intuitive code structure. The idea is to offer more layers of abstraction to make Rails easier to work with.
Since it’s not an actual framework, we won’t go into too many details about Trailblazer, but we will say it makes projects easier to use when Rails is the framework of choice. It’s easy to implement and there is a book in the works that can be used in its partial state.
Volt
Volt is another framework that has been fresh in the mind of many Rubyists recently. With a focus on building a fast application and eschewing the yak shaving, Volt offers the opportunity to get things moving quickly. Instead of focusing on syncing data via HTTP, Volt works using a persistent connection. Part of the reason for Volt’s quickness is that it lives on top of Opal, a really amazing gem that translates Ruby to JavaScript conveniently.
One inconvenience for Volt at the moment is that it only supports MongoDB. While MongoDB is a great database solution, it’s not always what you want to use.
Cramp
Looking for something of the asynchronous variety? Perhaps Cramp is what you’re looking for. Built on top of Event Machine, Cramp is designed to function with tons of open connections and provides full-duplex bi-directional communication.
Also supported by Rack, Cramp uses Ruby 1.9.2 or higher and a simple gem installation is all that’s necessary to get started. If you are familiar with building simple applications using Ruby, the style used in Cramp will not be strange or unusual to you. The examples they use clearly set the stage for ease of use.
Another beautiful feature of Cramp is the inclusion of an application generator. Type cramp new realapp in your console to get started with a new Cramp application.
Ramaze
Built on the ancient coding ideal of KISS (Keep It Simple, Stupid), Ramaze is a framework that is looking to do just that: remove complexity in favor of making things easier. Ramaze is built to work with various ORMs, adapters like Unicorn or Passenger, as well as various implementations of Ruby such as JRuby and Rubinius. If MRI is not your favorite flavor of Ruby, perhaps Ramaze will be your framework of choice.
Ramaze is fast and flexible, which puts it at an advantage over some of the other frameworks mentioned here. The other benefit is how it functions similar to other frameworks. For example, if you are familiar with Sinatra, chances are Ramaze will not be that hard to get into.
Sinatra
I’ve gone over my feeling on Sinatra vs. Rails before, perhaps more than once. It’s easy to say Sinatra is my framework of choice for most small projects. Since the many uses of Sintra have been covered there we can focus on other things like something smaller. And for that there is Konstantin Hasse’s Almost Sinatra. (Do not actually ever use Almost Sinatra ever for anything ever.) Sinatra is easy to setup and there are more than a few Sinatra apps running in production on Engine Yard.
Lotus
After seeing all these options you may still be looking for something Rails-like and familiar, but not Rails. Enter Lotus, a complete erb framework for Ruby built by Luca Guidi. The key difference between Rails and Lotus is Lotus’ lightweight speed, which should attract those frustrated with the bulkiness of Rails.
Lotus is a full MVC framework and acts as such, so switching isn’t a big jump. The one drawback of Lotus is its maturity: it’s not quite ready for production apps. But it is nearly there.
Conclusion
We’ve taken a look at just a handful of the frameworks rubyists can use outside of Rails. Again, this isn’t a call to abandon Rails. I do think, however, it’s good to expand your horizons and try out new things. And when you’re ready to get one of these things running in production, our support team is happy to help.
P.S. Have you tried one of these frameworks before? Have we missed your favorite framework? Throw us a comment below.
Share your thoughts with @engineyard on Twitter
OR
Talk about it on reddit