8 Ruby Frameworks That Are Not Rails
It’s common for a Ruby developer to only have experience with Rails and describe themselves as a Ruby on Rails developer. Since David Heinemeier Hansson created Rails in 2003 it has been one of the most popular web frameworks out there. After many painful years spent creating spaghetti code in PHP, you could simply build a blog in under 15 minutes. On top of that the code looked beautiful. That being said, there are many other options out there for Ruby developers, that aren’t Rails. The majority of us have heard of Sinatra or Padrino, but there’s a ton of other (usually micro) frameworks like Cuba or Hanami out there. Check out the examples below:
Now I know, many of you will be outraged, saying that Sinatra is technically not a framework but rather a DSL (domain-specific language) for building websites, web services and web applications in Ruby. On the other hand, there are also some of you, that will keep insisting that it is widely considered as a framework, and therefore we’ve included it in this list. Sinatra, written in 2000 lines of Ruby, is the biggest of the frameworks on the list, but still it emphasizes the minimalistic approach to development, offering only what is necessary to handle HTTP requests and deliver responses to clients. Sinatra’s syntax is easy to understand and quite straightforward, and it allows for rapid API development, site building or creating a Ruby-based web service.
Padrino is a full-stack Ruby framework built upon the Sinatra web library. It might be based on Sinatra, but it adds many additional tools, such as having generators, tag helpers, caching, localization, mailers, etc. It is best suited for those who have an existing Sinatra app that is becoming more complex and warranting things that come in a full-stack framework. You can start with Sinatra and graduate to Padrino if needed.
Hanami is a full-stack Ruby web framework built by Luca Guidi, made up of small, single-purpose Ruby libraries. As the Hanami Team writes on their page, Hanami’s goal is to build lightweight apps which consume less memory than other Ruby web frameworks. Due to its size, Hanami is optimized for speed. Hanami is great for those developers that find themselves disagreeing with “The Rails Way,” or for those that really enjoy the Domain Driven Design approach.
Grape, or Generalized Rapid API Erector, is a REST-like API micro-framework built to complement existing frameworks. It does that, by providing a simple DSL, and was built to replace the API’s functionality of bigger frameworks like Rails, and Sinatra.
Cuba is a microframework for web development, a small but powerful mapper for Rack applications. It is very close to Rack with very low overhead. Its best use is for small endpoints, where speed is important, or for those who want full control over their entire stack, adding additional gems and complexity as needed.
Roda is a web framework built on top of Rack, created by Jeremy Evans, that started as a fork of Cuba and was inspired by Sinatra. Roda (and Cuba) have a very unique approach to routing compared to Rails, Sinatra and other Ruby web frameworks. In Roda you route incoming requests dynamically as they come. Roda ships with lots of plugins for everyday needs, it comes with over 60 built in it.
Ramaze is a very simple and straightforward web-framework. The philosophy of it could be expressed in a mix of KISS(Keep It Simple Stupid) and POLA(Principle Of Least Astonishment). It’s built to follow the MVC pattern, though it’s possible to ‘deploy’ everything from within a single script. It supports all major templating systems, and its heavily focused on modular design.
NYNY, or New York, New York, created by Andrei Lisnic, is a microframework for Ruby. In his own words:
If Sinatra is very minimalist, then I’d say that NYNY is very, VERY minimalist. Sinatra’s source code has 2000 lines. In contrast, NYNY has only 300. At the same time, there’s not a lot of stuff that NYNY lacks and Sinatra provides. NYNY is also 25% faster and has a more powerful router (it uses Rails’ router), but lacks a lot of convenience helpers that Sinatra has.
Hopefully this round-up of some alternative Ruby frameworks will help expand your horizon. Chances are, you don’t always need a massive framework like Rails, and could sometimes use a micro one, like some of the aforementioned frameworks. That being said we’re still huge fans of Ruby on Rails.