Ruby, RBS vs. Sorbet #6531
Replies: 2 comments 1 reply
-
BackgroundSorbet
RBS
SyntaxSorbet
RBS
AdvantagesSorbet
RBS
DisadvantagesSorbet
RBS
What about YARD/RDoc?
Nothing about RBS or Sorbet precludes you from using YARD (or RDoc, for that matter). In fact, it’s probably beneficial to use YARD in addition to Sorbet or RBS because of its documentation generation capabilities. Is it possible to use both?You can, generally, use both Sorbet and RBS — with a bit of a catch. Because of the aforementioned flexibility limitations within Sorbet, there is certain code (especially around duck typing) that cannot be typed with Sorbet. There is an escape hatch in this scenario (using a return type of The way that this interoperability would work is that you would supply both Recommendation
Open questions
Next steps
Resources |
Beta Was this translation helpful? Give feedback.
-
What about Sorbet runtime checking?Sorbet supports runtime checks where the type signatures will be validated when the code is run in production. There are a few advantages to this:
There are also a few disadvantages:
Given that we have (nearly) complete control over the codebase and it can be typed from the get-go, there is not much advantage to using runtime checks here. This is a similar approach to the one that Stripe took with the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
To be continued by Ethan...
Beta Was this translation helpful? Give feedback.
All reactions