A Ruby developer may have exclusively worked with Rails, in which case they may call themselves a “Ruby on Rails” developer. One of the most widely used web frameworks, Rails, has been around since its creation in 2003 by David Heinemeier Hansson. After spending years agonizing over PHP spaghetti code, you can throw up a blog in minutes. Furthermore, the code was aesthetically pleasing. The good news is that Ruby developers can open themselves to Rails; plenty of alternatives exist. Most of us are familiar with Sinatra and Padrino, but there are many additional (often tiny) frameworks to choose from, such as Cuba and Hanami. Take a look at the illustrations below:
I anticipate some pushback from readers who insist that Sinatra is not a framework but rather a DSL (domain-specific language) for creating Ruby-based webpages, web services, and web apps. However, many of you would say that this is a framework and deserves to be here because of this widespread perception. Despite being the largest of the frameworks on our list at 2000 Ruby lines, Sinatra emphasizes minimalism by providing just the bare minimum required to process HTTP requests and provide replies to clients. Sinatra’s syntax is simple and concise, allowing for speedy application programming interface (API) development, website development, or Ruby-based web service creation.
Using the Sinatra web library as its foundation, the Padrino Ruby framework provides a comprehensive solution for web development. Even though it’s built on Sinatra, it has many more features. For example, it has generators, tag helpers, caching, localization, mailers, etc. Those who already have a Sinatra project that is maturing to the point where it requires the more robust features of a full-stack framework are the ones who will benefit the most from this. When Sinatra doesn’t cut it, try Padrino.
Luca Guidi’s Hanami is a full-stack Ruby web framework comprised of lightweight, purpose-built Ruby libraries. According to the Hanami Team’s website, Hanami was created so that developers could create programs that used less memory than competing Ruby web frameworks. Hanami is built for speed because of its compact nature. For those who have issues with “The Rails Way” or who prefer the Domain-Driven Design methodology, Hanami is an excellent alternative.
Grape, short for Generalized Rapid API Erector, is a micro-framework in the style of the RESTful API designed to function in tandem with larger frameworks. It did this using a simple DSL and was designed to replace the API capabilities of more robust frameworks like Rails and Sinatra.
Cuba is a web development microframework, a lightweight but robust mapper for Rack programs. It has low overhead and is located near Rack. This is the ideal option for tiny endpoints where performance is paramount or total stack control is desired, so extra gems and complexity may be added as required.
Jeremy Evans’ Roda is a Rack-based web framework that was originally a fork of Cuba and was influenced by Sinatra. Compared to other Ruby web frameworks like Rails or Sinatra, Roda’s (and Cuba’s) approach to routing differs. Roda’s request routing is completely ad hoc and in real-time. Roda has more than 60 pre-installed plugins, allowing it to meet a wide variety of common requirements right out of the box.
Ramaze is an easy-to-use and intuitive web development framework. The idea behind it may be summed up by combining the KISS principle (Keep It Simple, Stupid) with the POLA principle (Principle Of Least Astonishment). It is feasible to “deploy” the whole application with a single script, even though it was constructed using the Model-View-Controller design pattern. It’s very modular and works with all the popular templating frameworks.
Andrei Lisnic’s NYNY (short for “New York, New York”) is a Ruby microframework. If Sinatra is a minimalist, then NYNY is much more so, in his words. There are 2000 lines of code in Sinatra’s main source. On the other hand, NYNY has just 300. However, there isn’t anything that Sinatra offers that NYNY doesn’t. In addition to being 25% faster, NYNY leverages Rails’ router, which is far more powerful than its own but misses many of the convenience features that Sinatra provides.
This collection of Ruby frameworks is meant to provide you with more options. It’s likely that you will only sometimes need a huge framework like Rails and might instead benefit from a tiny framework like the ones listed above. Even so, Ruby on Rails has won over our hearts and minds.