News for hackers. Stuff that matters.
Re:Why Crystal Is My Next Language by vidarh on Monday June 11, 2018 @03:12AM (#17282405)
Those measures you want are tests. You need them just as much with statically typed systems, but it's often easier to tell yourself you don't. If you compare static code with poor test coverage with dynamic code with poor test coverage, the dynamic code is probably more likely to fail with a runtime error of some sort, but in my experience they're about as likely to fail to produce the intended result. Once you add proper tests, most type errors in the dynamic code tends to get caught without specifically testing for it.

I used to make this argument too, until I actually spent some time writing Ruby, and none of my fears came to pass.

Re:Why Crystal Is My Next Language by tigershark on Monday June 11, 2018 @07:33AM (#17283410)
You don’t really need tests for everything. If you make the invalid state unrepresentable in the type system then, guess what? You don’t need to test for its validity and more importantly you are guaranteed that if it compiles it can’t ever reach an invalid state. This renders a whole class of tests unnecessary.
Re:Why Crystal Is My Next Language by vidarh on Monday June 11, 2018 @11:31AM (#17285101)
While that is true, you still need to test to ensure that your representation matches reality, and in practice when you do that in systems written in dynamic languages you tend to cover most type issues implicitly.

For that matter it's not that hard to write code to statically validate that arguments to a given method are checked against a set of types and that this set does not include a representation of invalid values. (E.g. I can "forcibly" wrap any method with checks). The reason the various libraries to do that haven't gained much traction is that they've rarely paid for themselves in reduced effort compared to higher level tests.

I'm all for more static validation, but I just don't think we have suitable tooling yet to do it at a level that provides sufficient benefit.