---
title: "Static Typing in Ruby with a Side of Sorbet"
description: "An experiment introduced Sorbet into a greenfield Ruby codebase with four developers to test whether static typing could catch bugs earlier, ease refactoring, and improve code design. Sorbet combines static linting with runtime checks that verify method parameters and return values against signatures, while RBI files describe methods from gems and Rails models. Setup required sorbet init, running sorbet tc, and adding that command to CI; however, Rails metaprogramming required model signatures, and sorbet-rails could miss or mistype fields. Sorbet immediately exposed issues including repeated method calls, unintended nullable database columns, and unnecessary explicit returns or guard clauses. The team reports a very positive short-term experience, while noting that the project’s young age caused most of the bugs encountered and that long-term value remains uncertain."
---

# Static Typing in Ruby with a Side of Sorbet

[Heroku](https://yomu.fyi/company/heroku) · Jason Draper · Oct 31, 2019

**Type:** Explainer

## Summary

An experiment introduced Sorbet into a greenfield Ruby codebase with four developers to test whether static typing could catch bugs earlier, ease refactoring, and improve code design. Sorbet combines static linting with runtime checks that verify method parameters and return values against signatures, while RBI files describe methods from gems and Rails models. Setup required sorbet init, running sorbet tc, and adding that command to CI; however, Rails metaprogramming required model signatures, and sorbet-rails could miss or mistype fields. Sorbet immediately exposed issues including repeated method calls, unintended nullable database columns, and unnecessary explicit returns or guard clauses. The team reports a very positive short-term experience, while noting that the project’s young age caused most of the bugs encountered and that long-term value remains uncertain.

## Context

The experiment evaluated whether adding Sorbet’s static type checking to a Ruby codebase could catch bugs before production, make refactoring easier, and improve code design for a four-developer team.

## Approach / What changed

The team added Sorbet to a greenfield Ruby codebase, initialized its configuration with sorbet init, ran sorbet tc locally and in CI, and used method signatures and RBI files for application, gem, and Rails model code. They also used sorbet-rails to generate model RBI files.

## Takeaways

- Sorbet uses runtime checks to verify method parameters and return values against declared signatures, in addition to static linting.
- Sorbet exposed nullable database columns that conflicted with the team’s preference to avoid nils, prompting a database migration.
- Rails metaprogramming complicates static typing; sorbet-rails helped generate RBI files but still missed or mistyped some fields.

**Tags:** [Ruby](https://yomu.fyi/topic/ruby), [Sorbet](https://yomu.fyi/topic/sorbet), [Static Typing](https://yomu.fyi/topic/static-typing)

- Source: [Heroku](https://www.heroku.com/blog/static-typing-ruby-with-sorbet)
- Source URL: https://www.heroku.com/blog/static-typing-ruby-with-sorbet
- Ingested by Yomu: 2026-09-09T16:02:15.361Z

[Read original post](https://www.heroku.com/blog/static-typing-ruby-with-sorbet)
