frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Past, Present, and Future of (Ruby) Sorbet Type Syntax

https://blog.jez.io/history-of-sorbet-syntax/
5•ksec•8mo ago

Comments

Lio•8mo ago
This is a great write up and I think the proposal to make rbs-inline type comments avaible at runtime is an execellent solution.

I can definitely see the value runtime type checking in addition to static analysis. For my own work I've done this either using pattern matching:

  class User
    def initialize(name:, age:)
      String => name
      Integer => age
      @name = name
      @age = age
    end
  end
but the error messages aren't great IMHO. It's pretty easy though knock up a little type checker in a very small module and prepend it. I have support for union types and typed arrays in mine.

I actually wasn't aware of the improvements they've made over the years to Sorbet. It think that's probably what I'll migrate to now.

Lio•8mo ago
I'd add, I'm surprised this this post isn't added to the "official" Sorbet blog. It really is a great post and very positive for the future of the project.

https://sorbet.org/blog/