Sorbet · A static type checker for Ruby


Coming Summer 2019. Built with 💜at Stripe.

Sorbet is multithreaded, scaling linearly across cores on your CPU. It checks your types in seconds, giving you feedback as you code.

Get started with Sorbet →

Sorbet works with your favorite editor to provide IDE features like autocomplete and jump to definition. It's easy to add to your CI setup.

Try Sorbet online →

Sorbet works with normal Ruby, so you can keep using your existing toolchain. Add Sorbet types to your codebase one file at a time.

Learn what makes Sorbet gradual →

Coming Summer 2019. We're looking for early feedback to make Sorbet great: sign up here to get involved!

Sorbet is 100% compatible with Ruby. It type checks normal method definitions, and introduces backwards-compatible syntax for method signatures.

Explicit method signatures make Sorbet useful for anyone reading the code too (not just the author). Type annotations serve as a tool for understanding long after they're written.

Sorbet is designed to be useful, not burdensome. Explicit annotations are repaid with clear error messages, increased safety, and increased productivity.

# typed: true
extend T::Sig sig {params(name: String).returns(Integer)}
def main(name) puts "Hello, #{name}!" name.length
end main("Sorbet") # ok!
main() # error: Not enough arguments provided for method `main`
man("") # error: Method `man` does not exist

Sorbet gives your Ruby development environment IDE-like features, including autocomplete, in-editor documentation, and go to definition. The implementation leverages the Language Server Protocol to be compatible with your favorite editor.

In the time we've spent adopting Sorbet at Stripe, countless people have told us that adding types to existing code or writing new code feels interactive, like pair-programming with the type checker. People ask Sorbet questions, and it responds in seconds—or faster.

GIF of autocomplete in editor

Stripe LogoCoinbase Logo

Sorbet is currently used by the teams at Stripe and Coinbase. If you'd like to try it at your company, sign up for our mailing list and we'll reach out when we have more to share!

Link to Sorbet talk video

Much has already been said about Sorbet. Here's a talk we gave at Strange Loop 2018:

Stripe maintains an extremely large and growing Ruby code base with hundreds of developers and millions of lines of code. Continuing to scale development is one of the most critical tasks to maintaining product velocity and the productivity of Stripe engineering.

This talk shares our experience building a type checker, and adopting it in our massive codebase. We start with a discussion of core design decisions we made in early days of the project, and evaluate how they withstood reality of production use.

Sorbet is a gradual type checker, which enables incremental adoption. On the other hand, it'll be unfamiliar to those expecting a traditional statically typed language.

Learn why gradual is different →

Sorbet works with 100% of Ruby, but it does not work the same for all Ruby. Developers can opt into more static checks to get even more safety and productivity.

How to enable static static checks →

One way Sorbet works to be useful without getting in the way is with control-flow-sensitive typing. Sorbet tracks the effect of control on types, instead of asking for type annotations.

See the power of flow-sensitivity →