Sorbet first came on the scene almost a year ago, so this post isn't really news.
But having not really gone into depth about how it actually works, I really enjoyed this podcast episode about how it works.
Basically it is a gradual typing system designed for uneven adoption because that is what was needed at Stripe, and this makes it really appealing to adopt on an as-needed basis in a codebase based on individual team preferences and problems.
Sorbet
This repository contains Sorbet, a fast, powerful type checker designed for Ruby It aims to be easy to add to existing codebases with gradual types, and fast to respond with errors and suggestions.
This README contains documentation specifically for contributing to Sorbet. You might also want to:
- Read the public Sorbet docs
- Or even edit the docs
- Watch the talks we've given about Sorbet
- Try the Sorbet playground online
If you are at Stripe, you might also want to see http://go/types/internals for docs about Stripe-specific development workflows and historical Stripe context.
Table of Contents
The whole thing seems quite well thought out and useful, and the pattern of starting with type-free Ruby for prototyping and then moving to typing once business logic starts to congeal seems great.
Top comments (3)
I like the idea of bringing a Typechecker to Ruby in the way Sorbet does it because it doesn't feel intrusive (like TypeScript in JS, i.e). However, last year I gave it a try in a Rails project and couldn't make it work :sweat-smile:
Maybe in a couple of months would try again and see what happens :)
I've been using it on production for some time and I've both loved and hated it at some points.
The benefits it brings if your domain can benefit from types are good, but it still has some cons that are a bit problematic and that make using it more boilerplatey than other type systems like TypeScript for example.
The type system it provides is still not 100% ready and things like generics are there but they are not even documented. Support for rails exists but it isn't simple or comfortable to use. You need to regenerate the typings when you do things like add new models, controllers, routes, relations... That has an obvious cost, not only on the extra work it requires but also because onboarding someone new to the team is more complex.
The code in sorbet moves super fast and you need to upgrade it quite constantly if you don't want to be left behind. Sometimes upgrades are smooth, but some others you'll just suffer bugs and instabilities of different types (non-compatible gems, issues depending on the Ruby version...) they are fixed quite fast though, which is something to be grateful for.
In general, my impression over it is that it is not as ready as I would have liked to.
Been working with Sorbet for the past couple months, and overall it's been a good learning experience for me, and contributed to helping us produce more explicit code. I wrote some thoughts about the experience a little while ago: dev.to/nexmo/insights-from-incorpo...