Hacker News new | ask | show | jobs
by pxc 300 days ago
Sorbet can actually make programs crash at runtime if a variable's type doesn't match its annotation, right? It's not as busted as some other gradual typing implementations.
2 comments

I'm definitely in favour of gradual typing but runtime checking is already really easy to do if that's what you want. Just add a rightward assignment patten match to your method. e.g.

  def somemethod(foo, bar)
    foo => Integer
    bar => MyBarClass
  end
Personally I think the RBS-Inine format is the way forward. Sorbet has experimental support for it too.

https://sorbet.org/docs/rbs-support

Oh exactly what I wanted - runtime overhead, on top of its lack of ability to accomodate ducktyped external dependencies in any sane way.

It does welcome nil proliferation though! Just sprinkle some `nilable` around and you're set to continue the actual scourge of the language.