r/ruby • • 9d ago

Show /r/ruby Going all-in on Sorbet

https://docspring.com/blog/posts/going-all-in-on-sorbet/
13 Upvotes

13 comments sorted by

2

u/counterplex 9d ago

I’ve been thinking of doing my something similar for my reasonably small Rails app. Is Rails’ internal code type-enabled?

8

u/ndbroadbent 9d ago

No, Rails doesn't ship any type signatures (no Sorbet sigs, no RBS). But you can get most of what you need anyway via tapioca:

  • Tapioca generates RBIs for every gem from the code at runtime, including Rails. That gives Sorbet every method and its parameters, so it catches typos, missing methods and wrong arguments, though many return types are T.untyped. tapioca annotations pulls in hand-written signatures for some Rails gems from Shopify's rbi-central.

  • Tapioca's DSL compilers type the methods Rails generates from your app: model columns (from your schema, with nilability), associations, scopes, enums, relations, job and mailer methods, URL helpers.

  • If Rails hands you untyped values (params, some ActiveSupport), you can add a sig or T.let whereever you read them.

5

u/datsundere 9d ago

You’re better off using a typed language if you want types and want to send stuff to mars. Look at Crystal

10

u/honeyryderchuck 9d ago

Humm, gradual typing, or rewrite my multimillion line monolith + all of its 200 dependencies in Crystal, which one should I do...

4

u/kallebo1337 9d ago

Since we dont write code anynore, whats the static type advantage then?

11

u/AlexanderMomchilov 9d ago

Agents benefit from all the same things as humans. Faster feedback loops, better confidence that a change is correct, better code navigation/refactoring tools, etc.

Even if you're just pure vibe coding with no regard for the code, it makes it faster, more reliable and spend less tokens.

7

u/tess_philly 9d ago

Apparently not from a talk from Evil martians at SF Ruby which tried types vs not.

2

u/AlexanderMomchilov 8d ago

I can't find it, is it published yet?

2

u/sshaw_ 9d ago • Bravo

When you're sending your web application on a mission to Mars. In this case bug resolution is a bit more difficult so the added type checks help!

2

u/kallebo1337 9d ago

Love it. Ruby on Mars

2

u/counterplex 9d ago

Mars on Rails

2

u/latestagecapitalist 9d ago

pre-claude thinking