Adopting Sorbet at Scale, by Ufuk Kayserilioglu


Shopify is a platform used by 800K merchants generating 12B$ revenue per year, serving 80K requests per second. Our core monolith is a 21K file Ruby on Rails application modified by 800 PRs per day. At this scale, we’re always looking out for tools that improve our confidence in the code that we write and maintain.

In this talk, we’ll explain how we adopted Sorbet to leverage static typing in our Ruby codebase. We’ll talk about our journey, the challenges we faced and how we overcame them. Based on this experience, you’ll get a better understanding of how you can benefit from Sorbet, too.


  • Intro: Why we needed Sorbet at Shopify (why rubocop, etc is not enough)
    • Number of files (~12K non-test files)
    • Number of people working (800 PR/ day, 1500 people in RnD)
    • 12B USD GMV going through our platform. 100B USD total
  • Quick overview of Sorbet
    • Static/Dynamic checking
    • Simple example
    • Gradual typing
  • How we adopted
    • We paid the early adopter price
      • There was no runtime checker component
      • Constant resolution and RBI generation for gems were problematic
      • Built some tooling (waffle-cone, tapioca, sorbet-cops)
    • Contributed to Sorbet (e.g. the DSL plugin system)
    • How we handled metaprogramming (plugins + RBI generation)
    • How we disabled runtime component in production (we don’t want the performance overhead)
  • Outcomes
    • Metrics obtained
      • 43% of non-test files are typechecked
      • 2% of method have a type signatures
      • ~40% of method calls are typechecked
      • 75% of developers find static typing useful
      • 48% of users say Sorbet caught an error in their code
      • 57% of developers want more code to be typed
    • Benefits observed
      • Easy to learn
      • Gradual typing
      • Confidence in code changes
      • Encourages better design
      • Improves inter and intra team communication
      • Free and evergreen documentation
    • Pain points / Limitations
      • Not enough flexibility or expressiveness
      • Syntax is verbose and can be distracting
      • Sorbet is in early stages and changes very fast
  • How can you do it in your projects?
    • Start playing around on Sorbet Playground
    • Introduce Sorbet in your project (srb init, tapioca)
    • Start with new code, preferably
    • Use gradual typing to your advantage
    • Don’t overtype
    • Make use of the runtime component in tests
    • Watch out for gotchas:
      • Very limited metaprogramming support
      • Incomplete core/stdlib definitions
      • No constant resolution via inheritance
      • No dynamic superclass/mixin support
      • No Ruby 2.7 support, yet
      • Small differences between static/runtime checking
      • Runtime checking overhead
    • Bonus: Use LSP and editor integration (--lsp)


There has been increasing interest in static typing for Ruby in the last few years. Since the release of Sorbet, many developers are looking to adopt it in their projects. Having gone through this path as early adopters at Shopify and having learned some lessons at scale, we believe it will be insightful for us to share our experience.

The speaker was on the team that drove this adoption and has first-hand experience with the hardships and opportunities with Sorbet. He is also the main developer of our gem RBI generation tool, tapioca.

Edit proposal


RubyConf 2019 - Accepted [Edit]

Add submission