4 ms·
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 ge
by milofeynman 2y ago
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.
- Syntaf 2y agoHow 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
- gls2ro 2y agoNot 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
- Syntaf 2y agoThanks 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.