Hacker News new | ask | show | jobs
by troad 302 days ago
Ruby is such an elegant language, but the strong and ongoing hostility to any sort of sensible gradual typing is a real mistake.

I know that the Ruby community loves its clever runtime metaprogramming, but even the most metaprogrammed codebase is still going to consist mostly of plain old in-out methods. And as anyone who's ever typed a dynamic codebase knows, you pick up so much low-hanging fruit, in terms of edge cases and errors, when you slap some types on those. You don't need to type everything, but there is real hostility in Ruby circles to gradual typing, even where it would make sense and wouldn't impose any major costs.

Personally, I've stopped writing Ruby. Short of any pathway to sensible gradual typing, I just can't shake the feeling that every new line of Ruby is instant tech debt. Which is such a shame, since I find real beauty in the language.

2 comments

> Ruby is such an elegant language, but the strong and ongoing hostility to any sort of sensible gradual typing

I'm not sure what you're basing that on, gradual typing has been built into Ruby since 3.0 (2020). Sorbet can around a bit earlier in 2019.

There is on going work to improve both with RBS-Inline support now in Sorbet with runtime support hopefully on the way.

IRB uses RBS for autocompletion and Solargraph and Ruby-LSP both support it.

I would say there is no hostility to gradual typing in the Ruby community. Quite the opposite, people are being paid to work on it.

Have you given RBS/Sorbet etc a go?
I gave Sorbet a red hot go on a decently-sized codebase maybe a year ago. I stopped writing Ruby not long after coming to the conclusion that Sorbet is a dead end. I never seriously considered RBS; the idea of maintaining C-style header files always struck me a kind of nuts from a DRY perspective, and very antithetical to the elegance of Ruby.

I ended up rewriting my Ruby codebase in Elixir (with thanks to some kind pointers here on HN). Elixir has perfectly satisfactory gradual typing via Erlang's dialyzer, which will happily power an LSP right now, and work is underway on a handmade gradual set-theoretic type system. It's a direction of travel I feel more confident in than Ruby's.