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

5 ksec 2 4/27/2025, 3:35:38 PM blog.jez.io ↗

Comments (2)

Lio · 4d 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 · 4d 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/