News for hackers. Stuff that matters.
Re:Diminishing returns of static typing by andrewaylett on Monday October 02, 2017 @01:34PM (#15385934)
Why would I write test-cases for something the compiler can catch for me? Yes, I need to write tests for all the correctly-typed cases, but there are a whole class of bugs that I don't need to test for any more because I can't even write the failing case.
Re:Diminishing returns of static typing by crdoconnor on Monday October 02, 2017 @04:23PM (#15387585)
>there are a whole class of bugs that I don't need to test for any more because I can't even write the failing case.

By adding sanity checking asserts in a dynamically typed language you can achieve more or less the same result.

Re:Diminishing returns of static typing by wstrange on Monday October 02, 2017 @04:48PM (#15387809)
If you are going to add a bunch of asserts, why not just use types?
Re:Diminishing returns of static typing by crdoconnor on Monday October 02, 2017 @05:14PM (#15388029)
I don't particularly see the need to extend this approach to every single variable in my code base. I usually just stick it on boundary code.
Re:Diminishing returns of static typing by enraged_camel on Monday October 02, 2017 @01:42PM (#15386009)
You don't write test cases specifically to check types. Your existing cases, if they are robust and thorough, will simulate your runtime and check those for you as a side effect.
Re:Diminishing returns of static typing by andrewaylett on Monday October 02, 2017 @05:12PM (#15388005)
My existing test cases, robust and thorough though they are, only test what happens when I feed in a correctly typed object. Because I can't write a test that exercises my code on an incorrectly typed input: the type system prevents that.
Re:Diminishing returns of static typing by metaphorm on Monday October 02, 2017 @01:49PM (#15386084)
you're already writing the test cases to ensure correct behavior with typical input, and predictable exceptional input. putting in one more assert for predictable exceptional input (wrong type) doesn't really add a noticeable amount of overhead to writing the tests you were already writing.
Re:Diminishing returns of static typing by macspoofing on Monday October 02, 2017 @02:52PM (#15386739)
>putting in one more assert for predictable exceptional input (wrong type) doesn't really add a noticeable amount of overhead

Yes. We call that 'typing'.

Re:Diminishing returns of static typing by discreteevent on Monday October 02, 2017 @05:58PM (#15388315)
And it takes less typing (keyboard) than the assert, and you get free documentation inline with the code!