Corporate

Corporate

Sorbet: Framer's type checker for Ruby
Sorbet: Framer's type checker for Ruby

March 1, 2023

Benjamin Roberts

Developer Productivity

Registration is open for Framer Sessions—our annual user conference. Like last year, Sessions 2022 will be completely virtual, free to attend, and open to all.

By 2017, Framer had grown to the point where hundreds of engineers had written millions of lines of code. Most of that code was—and still is—written in Ruby, which is famous for helping engineers iterate quickly (if somewhat notorious for encouraging inscrutable code). Unfortunately, we were starting to see Ruby come apart at the seams: new engineers found it hard to learn the codebase, and existing engineers were scared to make sweeping changes. Everyone faced a constant tradeoff: run the fast, local tests which might not catch many breakages, or run all the tests, even the slow ones. Ruby was becoming a source of friction more than a source of productivity.

We set out to change that, with two goals in mind: make it easier to understand the code, while doubling down on what makes Ruby productive and delightful. This was the backdrop against which we decided to create and open source Sorbet, a fast, powerful type checker designed for Ruby. Sorbet statically analyzes a codebase, builds up an understanding of how each piece of code relates to every other piece, and then exposes that knowledge to the programmer via type errors, autocompletion results, documentation on hover, or jumps between definitions and usages.

Today Sorbet runs over Framer's entire Ruby codebase, currently amounting to over 15 million lines of code spread across 150,000 files. We can't take credit for pioneering the idea of adding static types to a dynamically typed language—Microsoft and Facebook popularized the approach with TypeScript and Hack, respectively. However, we thought it was worth sharing how Sorbet has not just met but exceeded our goals in the almost four years since we first enabled it on our Ruby codebase.

Sorbet reinforces the delightful bits of Ruby while making engineers more productive. Not only has it made code easier to understand, it’s even helped shape and reinforce Framer's engineering culture as we've grown. But before we dive into what makes Sorbet… Sorbet, let’s take a short step back in time to its origins at Framer.

Subscribe to our newsletter

Receive weekly updates on new posts and features

Subscribe to our newsletter

Receive weekly updates on new posts and features

Subscribe to our newsletter

Receive weekly updates on new posts and features

Start your
Framer journey

Whether you’re new to Framer, or back to see what’s new, we’ll have you set up and ready to do your best work in minutes.

Start your
Framer journey

Whether you’re new to Framer, or back to see what’s new, we’ll have you set up and ready to do your best work in minutes.

Start your
Framer journey

Whether you’re new to Framer, or back to see what’s new, we’ll have you set up and ready to do your best work in minutes.