talira

A fast, powerful type checker designed for Ruby

open sourceApache-2.0self-hostablefree

Sorbet is a static type checker for Ruby that you adopt gradually: each file opts in with a strictness sigil, and method signatures (sig) are written in plain Ruby, so existing tools keep working. It is multithreaded and fast enough to check large codebases in seconds, uses flow-sensitive typing so it needs fewer annotations, and reads type definitions for gems and generated code from RBI files. sorbet-runtime checks the same signatures while the program runs. Its language server gives editors autocomplete, go to definition and inline documentation, and sorbet.run is an online playground. Stripe builds it.

Problems it solves

  • catch nil errors and typos in my Ruby code before they reach production
  • add types to a large Rails codebase one file at a time
  • refactoring our Ruby monolith is scary because nothing tells me what I broke
  • I want TypeScript-style checking for Ruby
  • get reliable go to definition and autocomplete for Ruby in my editor
  • document what each Ruby method takes and returns in a way that's checked
  • fail CI when someone calls a method with the wrong argument types
  • check method argument types at runtime in Ruby too, not only statically
  • a type checker fast enough to run on every save in a million-line Ruby app
  • let my AI coding agent find type mistakes in the Ruby it writes
  • type-check Ruby code that uses gems and metaprogramming

Features

  • gradual typing with per-file strictness levels
  • method signatures in Ruby syntax
  • flow-sensitive typing
  • multithreaded checking
  • RBI type definition files
  • gem awareness
  • language server (autocomplete, go to definition, hover docs)
  • runtime type checks via sorbet-runtime
  • online playground (sorbet.run)

Capabilities

Has a command line toolplan not known

Forks

  • Sorbet for Rails A Sorbet build for Rails apps that type-checks specs, factories, and ERB views. 7 changes, 1 merged upstream.

Alternatives

The same job

These do what Sorbet does.

  1. Steep Gradual typing for Ruby
  2. TypeScript JavaScript with static types, compiled to plain JavaScript
  3. Flow A static type checker and typed dialect of JavaScript

Compare Sorbet with the top 3