5 ms·
Two questions (sorry if that's too much): 1. Sorbet isn't really great to use with Rails. I tried it out about a year ago - a few things might've changed but f
by square_usual 5y ago
Two questions (sorry if that's too much):
1. Sorbet isn't really great to use with Rails. I tried it out about a year ago - a few things might've changed but from scanning the relevant gems I think this broadly still applies. I used sorbet-rails but there were still a bunch of rough edges, eg. with using a class method on a model as a scope. The general theme was that Rails was doing quite a few things that make it super hard to type. ex - look at what it takes to do a type-safe pluck with sorbet-rails, and I don't think doing a typesafe select with association columns is even supported. Is there any acknowledgement of this from the Sorbet team itself, and will there be more to make the Sorbet with Rails experience better?
2. I'm really excited for the future of the Sorbet compiler. Like above, is there any work on making the AOT compiler work better with Rails?
- zomgwat 5y agoRegarding Sorbet and Rails, I recommend Tapioca [1]. The Rails app that I worked on had a few edge cases Tapioca didn't cover so I wrote a simple script to load the Rails app and generate RBI files (e.g. generate RBI definitions for fixture methods in ApplicationTestCase). The Tapioca codebase helped provide a path for that [2]. Tapioca also continues to add to their DSL compilers. The work to integrate Sorbet paid off very quickly. Also, T::Enum and T::Struct are handy in any Ruby codebase. [1] https://github.com/Shopify/tapioca https://github.com/Shopify/tapioca [2] https://github.com/Shopify/tapioca/tree/main/lib/tapioca/compilers/dsl https://github.com/Shopify/tapioca/tree/main/lib/tapioca/com...
- jez 5y ago1. I don’t know much about using Sorbet with Rails, but I do know that almost every major user of Sorbet that isn’t Stripe is using Sorbet with Rails! You might want to reach out in the #rails channel on our Sorbet Slack[1] for more? 2. Our focus for the Sorbet Compiler has always been more inward focused than Sorbet, so we focused pretty much exclusively on features that make the compiled code run fast on Stripe’s codebase. But you might be curious to read more about YJIT, the JIT compiler that was recently merged into Ruby 3.1—it’s being primarily developed by a team at Shopify where Rails performance is the highest priority. [1] https://sorbet.org/slack https://sorbet.org/slack
- daveungerer 5y agoNot OP, but hopefully this helps with your first point: we're happily using Sorbet with Rails (leveraging sorbet-rails). It's by no means perfect, but a gradual typing experience in Ruby never will be, unless you restrict the way you use the language. The benefits of having at least some level of type-checking outweigh the cons, IMHO. Sorbet picks up many of the little typos that only become apparent when you try out the code / run a test. I've been using an unofficial VS Code extension for ages, and I really like the increase in iteration speed.