Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not the OP but I started working with Sorbet in a Rails codebase 6 months ago.

Learning it is easy and using it is also easy if you stay away from: 1. Meta programming 2. Methods that are returning different results based on some conditions.

the second case it can be handled by Sorbet but it makes the type more complex.

I find this a nice side effect of Sorbet: - the moment I start fighting the types or feeling to add many T.any it is a signal to me that I should split my methods/objects

Some things that I found useful:

- I started to like T.enum, T.struct and somehow I am feeling them missing now in a normal Rails project.

- I also like T.let as it helps with object shapes and memoization.

- It also solves the inheritance and there is no need to discuss what exception to throw when you want to define a method that should be implemented in

- I would recommend the gem sorbet-results that adds a simple typed monad

- It helps a lot refactoring

To get the full benefits always try to make your files with typed:strict and of course use tapioca with Rails



Thanks for the opinion! I work with type annotated Python day-to-day so I'm excited to have that sort of type safety with a tool like Sorbet, sounds like I should check it out sometime soon.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: