Static type inference, are you in?

I consider myself a pretty disciplined Ruby developer. I have an app, used every day, that hasn’t thrown an “undefined method for nil” in production in years. That said, Crystal still catches me constantly.

Sometimes this is frustrating, but it also makes for more confident refactoring. In many ways, it’s like refactoring Elm or Haskell. Change a thing, fix all the compiler errors, and Bob’s your uncle.

For me, this is a welcome addition to a ruby-like language, where refactoring often involves a lot of "OMG! I hope I have the good tests for this… "

What say you all?

3 Likes

I can confirm all of your statements. I’m working on a 2 year old Crystal app that interacts with Google Spreadsheets, Quickbooks, Slack, postgresql and other third parties. Around 5k LOC.

So it’s not huge but there’s already a lot of “legacy” in there. The compiler is your best friend. You just move something around, and let the compiler guide you. A lot like Elm and Haskell, indeed. Could it be a Hindley-Milner feature?

Another side-effect: I find I tend to write much higher level tests than in Ruby. There’s a lot of testing that goes away because the compiler makes them redundant.

3 Likes

THIS!!! \o/

1 Like