←back to thread

140 points ksec | 4 comments | | HN request time: 0.804s | source
1. milofeynman ◴[] No.41084253[source]
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.
replies(1): >>41087043 #
2. Syntaf ◴[] No.41087043[source]
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
replies(1): >>41087725 #
3. gls2ro ◴[] No.41087725[source]
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

replies(1): >>41093441 #
4. Syntaf ◴[] No.41093441{3}[source]
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.