Hacker News new | ask | show | jobs
by AstroBen 413 days ago
I just wish Ruby had something with the widespread adoption of TypeScript. Once a project gets large enough it's really painful not having types

Sorbet and RBS are okay but they don't really compare

4 comments

The way I describe language types to non-coders inquiring about language selection for a given project is simply “scale matters”… dynamic types provide flexibility at small scale, but can very easily result in chaos at a large scale. Conversely, the structure of static types can feel onerous and restrictive at small scale, but provide robustness and structure at large scale.
If you mean codebase complexity and team size... then yes... types is more helpful with that. But in a small team with a small codebase you don't need types to do really well. I find types helped a lot when multiple teams were responsible for different domain spaces inside different components of a Rails app. I never saw the same advantage in codebases that are much smaller with fewer people.
If you can keep everything in your head, types can feel superfluous. Large projects make that nigh impossible.
In my experience it's exactly the opposite.
I see what you mean but I have never found it to be an issue even in large codebases. Sorbet and RBS have been problematic. Lots of development slows down with these solutions. I wished it had something baked into the language as well but I'm happy without... just following conventions alone has worked really well for me.
Yeah I just can't go back. How fast you can confidently refactor and the improved tooling is the biggest thing for me

You can do fine without them - Basecamp proved that. There's a good reason basically every other Rails company eventually moved to static typing though

Jake Zimmerman wrote this excellent blog post[1] on the current state of Sorbet.

I was impressed at recent changes in the Sorbet syntax but also with the proposal that we make code comments available to the ruby VM.

That would allow Sorbet to adopt the rbs-inline comment syntax for both runtime checks and static analysis.

So there does appear to be a way forward on this, which is pretty exciting.

1. https://blog.jez.io/history-of-sorbet-syntax/

This is a great presentation/article, thank you for posting it since I haven't seen it go by elsewhere.

What holds me, personally, from Sorbet is the fact that it tries (unwillingly) to dictate which features of Ruby are "bad" by not supporting them - specifically, "prepend" and Refinements. Now, Refinements I havent' seen used in the wild, but "prepend" I use the living hell of - both when designing modules and when overriding other libraries (with moderation, and when I do it is gawddam' well necessary).

While I can appreciate opinions, I am not really motivated to adopt a tool which snaps me on the fingers because I use the tools I know the utility of. I am not working at Stripe nor at Shop :-) Another thing I could really appreciate would be ad-hoc interfaces a-la Go - and more support for duck-typing in general. Maybe I missed this in Sorbet, but it seemed the idea was to "inherit like you are told to and shut up" - which is not how truly great things can get done in Ruby, at least in my experience.

Interesting to see where Sorbet goes in the coming years - and stoked for more RBS/Sorbet interplay!

Why? No one's stopping you from, say, using a Rails API and React front end.
Because I would prefer the Rails side to have good support for static typing
Just curious, why?

I like static typing when it gives me a 100x speedup (Java, C++, Haskell, whatever), but not solely for the sake of it...

I get the most value from it when it comes to refactoring