Hacker News new | past | comments | ask | show | jobs | submit login

I started a small service recently in rails. I'm forcing sorbet with typechecking (you can still set things to false like tests which sometimes are a pain to get to pass). It feels almost like a typed language with LSP jump to etc. It's getting there.



How do you like using sorbet? Does it feel natural? I’m also running service on rails and considering trying to integrate sorbet but worry about the syntax


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: