Cuba, the micro framework for web development

While most of the web development in Ruby is done with Rails and Sinatra, there's an unknown tiny framework that provides a significant advantage. It was inspired by Rum, a mapper by Rack's creator Christian Neukirchen.

Have you ever heard of Cuba? I bet you haven't, it's kind of a secret weapon. We use it for the Redis website and for OpenRedis.

The slides of the Cuba presentation are available here.

As I always say when I'm introducing Cuba to someone, it's a verbose, DSL-ish way to define web applications and it doesn't match Sinatra's maturity. But it provides the right abstraction and it's freaking fast.

What sets Cuba apart? The answer is two fold: for one, using closures lets you build the application incrementally. Check the slides 3 and 4 of the presentation: the article assigment appears twice in the Sinatra example and only once in Cuba's. Describing a web framework as a finite state machine allows you to match each part only once. If you already matched articles and :id, there's no point in going through those checks again. Sadly, that's what happens with most web frameworks.

The second aspect that sets Cuba apart is the fact that not only you aren't limited to inspecting the PATH_INFO when defining your workflow, but every detail of the request is at your fingertips and at the same level. It doesn't matter if you check some part of the path, or a parameter, or the host: every aspect of the request is a first class citizen.

What started as an easy way to try Rum evolved into our preferred tool for web development at Citrusbyte.

How to install it and further information

Run gem install cuba to try it now. If you want to know more, take a look at the documentation, check the source code for the Redis website, and meet us on IRC at #cuba.rb on freenode.net.