News for hackers. Stuff that matters.
Re:Diminishing returns of static typing by rbobrowicz on Monday October 02, 2017 @02:11PM (#15386300)
Personal anecdote:

I worked on a small Python project some years ago and we had a type error in production despite having tests.

We traced it back to a call to a third party library. It was supposed to return a list of results, and all of the test cases around it worked and always got a list back. In production however we encountered an error because if there was only one value to return, the library would not return a list of one element, as we expected, but a scalar value. So the rest of the code was expecting a list and when it encountered a scalar it blew up.

You can blame it on us for having insufficient test cases, or not coding defensively enough, or not reading the source code of the library we used, or the author of the library for bad design, but ultimately, this bug would not have been possible in a statically typed language.

So just saying "have test cases" is not good enough. Your test cases can be not exhaustive, but a good static type system and type checker is.

Re:Diminishing returns of static typing by berdario on Monday October 02, 2017 @05:11PM (#15387999)
I cannot reply to cdoconnor (probably some downvotes), so I'll write here:

That's the whole point: as it's often said "type checking keeps you honest"

I stumbled time and time again upon badly designed libraries... With a static type system, the painfulness will be obvious and felt the first time you'll try to build your code

with dynamic types, the pain might not be felt at all, until a crazy bit of code will be invoked, sometimes at the most unfortunate of times

Re:Diminishing returns of static typing by crdoconnor on Monday October 02, 2017 @04:11PM (#15387494)
>or the author of the library for bad design

That's the one. That's a damned stupid decision.

Re:Diminishing returns of static typing by UncleMeat on Monday October 02, 2017 @05:43PM (#15388216)
Yeah and a static type system refuses to let you make such a stupid decision. When interoperating with code I didn't write, knowing that the code is guaranteed to conform to some specification is valuable.