4 ms·
I think I'd rather just use a language with a good type system than write Ruby in that sort of style. The value of types is greatly diminished if there isn't a
by rubiquity 11y ago
I think I'd rather just use a language with a good type system than write Ruby in that sort of style. The value of types is greatly diminished if there isn't a compiler to make all sorts of wonderful optimizations and find bugs for you. At least until Ruby the language implements gradual/soft typing directly.
The library mentioned also raises exceptions for bad input. Unfortunately, exceptions cripple the runtime performance of Ruby so I wouldn't consider that a smart thing to do.
- solnic 11y agoYou'd get these runtime exceptions anyway, but they would be obscure and often hard to debug. Once you define core objects in your system that you construct from external sources (like a database) you establish a contract that the source is trusted and it's expected to provide valid data. If that doesn't happen, for some reason (and it happens), you want to see it as early as possible and a meaningful error can be very helpful. This obviously doesn't come even close to a statically typed language but I believe it's a huge improvement over the typical approach in Ruby where you...just don't care and hope for the best ;)
- rubiquity 11y ago> You'd get these runtime exceptions anyway, but they would be obscure and often hard to debug. Only if you use the bang versions of save/update/create, which I don't.