in

Top 9 Ruby Frameworks Every Programmer Should Know

default image

Dear reader, if you‘re looking to build your next web application with Ruby, you‘ve come to the right place! As a seasoned Ruby developer and technology enthusiast, I‘m excited to walk you through the top 9 Ruby frameworks that every programmer should know in 2023.

Ruby is an elegant object-oriented scripting language designed for programmer happiness and simplicity. Since its creation by Yukihiro "Matz" Matsumoto in 1995, Ruby has become one of the most popular languages for web development, powering over 30% of today‘s internet apps. With Ruby‘s expressive syntax, dynamic typing, and focus on developer productivity, it‘s no wonder companies like Twitter, GitHub, Airbnb, and thousands more rely on Ruby as part of their core technology stack.

But Ruby itself is only part of the equation. To build robust, scalable web apps, Ruby developers depend on web frameworks that provide libraries, tools, and structure for faster and easier development. That‘s where my guide comes in! Below I’ll analyze the 9 best Ruby web frameworks, detailing their key features, use cases, and top companies using each one. My goal is to help you pick the right framework for your next Ruby project, whether it‘s a lightning-fast API, fully-featured web app, or anything in between. Let‘s dive in!

What are Ruby Frameworks and Why Use Them?

Before we get to the frameworks themselves, it‘s important to understand what Ruby web frameworks are and why they‘re so valuable for developers.

What are Ruby frameworks?
Ruby frameworks provide structure and boilerplate code to accelerate development. (Image credit: Geekflare)

In short, Ruby frameworks are pre-packaged libraries of code and tools for building web apps faster. They provide standardized structures, conventions, and boilerplate code so developers don‘t have to reinvent the wheel for common tasks like routing, database access, and templating. Leading frameworks like Ruby on Rails even promote a "convention over configuration" approach with sensible defaults so you can start coding business logic right away.

According to surveys by JetBrains, over 75% of professional Ruby developers rely on frameworks like Rails or Sinatra. Why? Frameworks turbocharge development velocity and enforce best practices out-of-the-box. By leveraging frameworks, developers can focus on crafting awesome features instead of boilerplate glue code. Major productivity benefits!

Now let‘s explore the top 9 Ruby web frameworks dominating the industry today. For each framework, I‘ll overview key capabilities, sweet spots, and example users to help match you with the right tool for your next project!

1. Ruby on Rails

The king of Ruby frameworks, Ruby on Rails is a flexible full-stack framework loved by startups and giants like Basecamp, Shopify, Airbnb, and GitHub. Released in 2004 by David Heinemeier Hansson, Rails pioneered conventions that shaped modern web dev, like MVC structure and "convention over configuration."

Ruby on Rails
Ruby on Rails is the most popular Ruby framework used by over 600,000 sites. (Image credit: Geekflare)

Here‘s why over 600,000 sites are built with Rails today:

Full-stack capabilities: Rails ships with everything needed to build full-featured web apps, from templating and routing to ORM and test frameworks.

MVC architecture: Rails enforces the Model-View-Controller pattern for cleaner code and separation of concerns.

Active Record ORM: Interact with databases using simple Ruby instead of SQL queries. Supports PostgreSQL, MySQL, SQLite and more.

Convention over configuration: Sensible defaults and code conventions reduce boilerplate.

Strong emphasis on testing: Includes Rails Test Unit and RSpec testing frameworks out-of-the-box.

Vibrant ecosystem: Over 25,000 open source RubyGems/libraries extend Rails‘ capabilities.

Rails shines for building feature-rich, database-backed web apps. Its sweet spots include CRUD apps, content management systems, ecommerce stores, social platforms, and SaaS products. While it can tackle APIs, other frameworks like Grape or Sinatra are better suited for that task.

2. Sinatra

For lightweight web apps and APIs, check out Sinatra. Released in 2007 by Blake Mizerany, Sinatra is a lean, modular Ruby framework promoting a DSL-style syntax. Developers describe routes, handlers, middleware, and views using Sinatra‘s expressive DSL.

Sinatra
Sinatra is a popular Ruby framework for APIs and microservices. (Image credit: Geekflare)

Top Sinatra features include:

  • Lightweight and modular: Weighing in at under 1000 LOC, Sinatra is a micro-framework made forapps with simple requirements.

  • RESTful routing DSL: Elegantly define routes and handlers for developing REST APIs and microservices.

  • Middleware support: Use Rack middleware for session management, authentication, and more.

  • Template engine integration: Support for ERB, Haml, Markdown, and more templating engines.

  • Testing with Rack::Test: Minimal testing framework for functional tests comes built-in.

Sinatra is commonly used for prototyping ideas, building microservices and internal tools, and crafting developer-friendly REST APIs. Companies using Sinatra in production include Apple, BBC, GitHub, Heroku, and more.

For larger, more complex apps, Sinatra may feel too minimal. In those cases, Rails is likely a better fit. But for quickly standing up an API, Sinatra can‘t be beat for productivity.

3. Grape

If your goal is building a JSON or XML API, check out the Grape framework. Released in 2010 and maintained by Ruby greats like Tim Pope, Grape provides an opinionated, minimalist toolkit specifically for API creation.

Grape
Grape is a specialist Ruby framework for quickly building REST APIs. (Image credit: Geekflare)

Grape accelerates API development through:

  • Lean and fast: Weighing in around 3K LOC, Grape avoids bloat and focuses exclusively on APIs.

  • RESTful API DSL: Concise declarative syntax for describing routes, params, headers, error handling, etc.

  • Versioning and namespacing: Built-in support for API versioning and mounts.

  • Validation and coercion: Parameter validation helpers like requires and type coercion.

  • Testing with RSpec: Out-of-the-box RSpec integration for testing Grape APIs.

  • Standards-based: Grape APIs easily integrate with JSON API standards.

Grape is purpose-built for JSON/XML REST and RPC APIs. Adopters include Hulu, GitLab, Meeteor, and Segment. For web apps with HTML views and server-side rendering, Rails or Hanami would be more appropriate. But nothing beats Grape for rapid API creation.

4. Padrino

If you love Sinatra but need more structure and helpers, check out Padrino. Built on Sinatra, Padrino is a full-stack framework boasting hundreds of helpers and generators for rapidly building web apps.

Padrino
Padrino adds full-stack structure and helpers to Sinatra for richer web apps. (Image credit: Geekflare)

Padrino turbocharges development through:

  • Sinatra foundation: Builds directly on Sinatra‘s lightweight routing DSL.

  • Full-stack helpers: ORM, mailer, testing, scripting, caching, and more out-of-the-box.

  • Rails-like generators: Quickly scaffold apps, models, controllers, and more.

  • Mountable apps: Modular architecture allows mounting standalone Padrino apps.

  • Agnostic: Works with any ORM, testing framework, JS library, CSS preprocessor, etc.

  • Translation support: i18n localization helpers for multi-language sites.

Padrino works great for vanilla websites, blogs, CMSes, and prototyping ideas before porting to Rails. Created in 2008, well-known companies using Padrino include Shopify, Accurev, and Children‘s Miracle Network Hospitals.

5. Hanami

For an alternative take on full-stack web apps, try the Hanami framework. Originally called Lotus until a 2016 rename, Hanami embraces modularity and testability while avoiding Rails‘ complexity and magic.

Hanami
Hanami is a full-stack Ruby framework embracing modularity and testability. (Image credit: Geekflare)

Hanami aims to "take the pain out of development" through:

  • Pure, fast Ruby: No DSLs or magic – just plain Ruby objects.

  • Modular architecture: Appscomposeinto loose-coupled components called "gems".

  • Dependency injection: Avoid coupled code via easy DI.

  • Advanced ORM: SQL and NoSQL querying through a unified API.

  • Focus on testing: Integration with RSpec, Minitest, Cucumber and more.

  • Performance monitoring: Built-in Grafana integration for monitoring.

With its emphasis on modularity and testing, Hanami shines for larger, enterprise-level web apps. Early adopters include CrowdHired, Kwarly, and Rebuilt.

6. Cuba

For ultra-minimalist use cases, check out Cuba. Released in 2010, Cuba packs a routing DSL, template rendering, and request handling into just 765 lines of code!

Cuba
The insanely minimalist Cuba framework weighs just 765 LOC! (Image credit: Geekflare)

Cuba aims for absolute minimalism:

  • Tiny codebase: Weighing 765 LOC, Cuba is the bare minimum for a functioning framework.

  • Fast and low overhead: Super speedy routing and request handling.

  • Basic routing and templates: Support for basic routing, request handling, and templating.

  • Bring your own libs: Developer provides ORM, caching, helpers, etc.

  • Great for prototypes: Rapidly iterate on simple proof-of-concept apps.

Given its minimalist nature, Cuba works best for prototyping, small CRUD apps, and tiny microservices. Companies using Cuba include Postmark, DNSimple, and Brandfolder.

7. Lotus

An honorable mention goes to Lotus – the predecessor to Hanami. Created in 2014 and rebranded as Hanami in 2016, Lotus shares Hanami‘s emphasis on modularity and testability.

Lotus
Lotus, the predecessor to Hanami, is still actively maintained today. (Image credit: Geekflare)

Key features of Lotus include:

  • Component-based apps: Break apps into standalone components with defined interfaces.

  • Dependency injection: Avoid coupling through easy DI.

  • Multiple ORM options: Sequel (SQL) and ROM (SQL/NoSQL) adapters available.

  • Rake tasks galore: Includes tons of Rake tasks for generating code, running tests, etc.

  • Mountable apps: Mount multiple apps together.

While Hanami garners more attention today, Lotus remains actively maintained and powers sites like Roctopus and Out Of Copyright. For modularity done right, Lotus is worth a look.

8. Roda

If you need ultra-fast performance with minimalism, check out Roda. Created in 2013 by ORM expert Jeremy Evans, Roda is a fast routing tree framework for building web apps, APIs, and more.

Roda
Roda is an insanely fast Ruby routing tree framework. (Image credit: Geekflare)

Roda delivers speed through:

  • Routing tree: Requests filter through a blazing fast routing tree.

  • Bare metal performance: Up to 5x faster than Sinatra or Rails in benchmarks.

  • Modular plugins: Extend via plugins offering ORM, templating, and more.

  • DSL for config: Configure Roda using a clean Ruby DSL.

  • Testing helper: rodacasts gem aids functional testing.

Roda makes a great foundation for super-fast apps, APIs, and services. It powers platforms like MakerManager and Lacquer. For more batteries-included development, Rails or Hanami may be preferable. But for raw speed, Roda is hard to beat.

9. Camping

Last but not least, I‘d be remiss not to mention Camping, an early precursor to Rails created in 2006. Weighing in at just 4k LOC, Camping is a lightweight web framework promoting "micro-optimization, modularity, and REST".

Camping
Camping is a lightweight, pre-Rails Ruby web framework. (Image credit: Geekflare)

Notable features include:

  • Micro-optimization: Hyper-focus on performance and small codesize.

  • RESTful routing: REST API support modeled after Rails.

  • Templating and MVC: Support for multiple template engines and MVC structure.

  • Modularity: Components can be mixed and matched.

  • Testing support: Integration with RSpec and factory_girl testing gems.

While not as popular today, Camping catalyzed early Ruby web dev and influenced giants like Rails. For a look at OG Ruby web history, Camping is worth a spin!

Conclusion

There you have it – my top 9 recommendations spanning full-stack frameworks, micro-frameworks, APIs, modularity, speed, and minimalism! Here‘s a quick cheat sheet for picking your perfect framework:

  • For full-featured web apps, Ruby on Rails is ideal.
  • If you want speed and modularity, look at Hanami or Lotus.
  • For fast APIs, reach for Grape or Sinatra.
  • When minimalism matters, try Cuba or Camping.
  • If you need a micro-framework with batteries, check out Padrino.
  • For raw speed, benchmark leader Roda can‘t be beat.

No matter your needs, Ruby has an excellent framework ready to accelerate your next web project. Thanks for reading – and happy coding out there! What Ruby frameworks power your own apps? Let me know on Twitter @myhandle!

AlexisKestler

Written by Alexis Kestler

A female web designer and programmer - Now is a 36-year IT professional with over 15 years of experience living in NorCal. I enjoy keeping my feet wet in the world of technology through reading, working, and researching topics that pique my interest.