Tapioca makes Sorbet taste even better, by Ufuk Kayserilioglu


As part of our adoption process of Sorbet at Shopify, we needed an automated way to teach Sorbet about our ~400 gem dependencies. We tackled this problem by generating a Ruby Interface file (RBI) for each gem using runtime reflection. Thus, the gem tapioca was born. With the recent addition of RBI generation for various DSLs, including Rails, Tapioca has become the perfect complement to Sorbet and is the exclusive tool used at Shopify for gradual type adoption.

Come join us and see how Tapioca can make Sorbet taste even better, and how you can also start using it in your Sorbet recipes.


The intended audience of the talk will be people who are thinking about adopting Sorbet in their codebases or have had problems with adoption before.

The desired outcome of the talk will be to have empowered the listeners with a new tool to help them on their journey in gradual type adoption. Moreover, we aim to present some of the runtime reflection techniques that we have used to build the tool, which could be useful for a more general audience.

A rough outline of the talk will be as follows:

  • Intro: The need for RBI file generation
    • Static analysis and Sorbet's limitation.
    • What happens when you depend on types from a gem.
    • What happens when you create methods at runtime.
    • RBI format and how it can solve these problems.
  • Runtime Reflection: Ruby reflection APIs
    • How do you do runtime reflection in Ruby.
    • How can you use that to generate RBIs for gems.
    • How can you use that to generate RBIs for DSLs.
  • Tapioca: All this built into Tapioca
    • How does the gem work.
    • How can you get started with Sorbet with ease.
    • Which DSLs are supported out of the box.
    • How can you add generators for your custom DSLs
  • Conclusions and Takeaways


During our 1.5 year experience of adopting Sorbet at Shopify, we've realized that the biggest obstacles to adoption are gem definitions and dynamic methods.

Since Sorbet does not analyze the codebase's gem dependencies it needs to be told about the types coming from gems. Moreover, since Sorbet is a static type-checker, it needs to be told about all the methods that are dynamically created at runtime by various DSLs (for example, all the attribute definitions in Active Record models, that don't even have any static artefacts in the codebase).

This talk will present an overview of how we've solved these problems at Shopify and how we have shared it as an open-source project for the whole community to use and build upon. It will outline the obstacles new comers could face adopting Sorbet, and outline how they can be overcome using Tapioca.

The speaker is the primary author of the open-source tapioca gem and has been leading the effort of gradual type adoption at Shopify.

Edit proposal


RubyConf 2020 - Rejected [Edit]

Add submission