Hacker News new | ask | show | jobs
by igouy 392 days ago
> Without types … Now try to find all the places that you broke.

Do failing tests show what we broke?

2 comments

Yes, if you have tests that test all aspects of the behavior for all possible inputs.

Oh, you don't have that? Then do not scorn the help you can get from types.

"Less than 35 bugs were found in the 17,100 changes."

https://news.ycombinator.com/item?id=42473314

I wonder how many were not found.

Sometimes, but maybe you haven't written any tests! Type hints and immediate feedback from mypy are a lot easier than writing unit tests.
> haven't written any

Any!

Then maybe the immediate feedback of consistent types conveys a false impression.

Hard to conceive of a case where that would occur. Can you think of one?

The implication of what you're saying seems to be that if you're concerned about some kind of correctness you should be writing unit tests anyway and not being so fussed about type checking in a language like Python. I suppose if you are strictly following TDD that might work, but in all other cases type checks give you feedback much more quickly than unit tests ever can. I guess I don't understand.

Any old math with consistent types and incorrect calculation? (If only we'd diff'd the output with some known result.)

No doubt we're at cross purposes.

I'm a little surprised that you haven't mentioned — "Program testing can be used to show the presence of bugs, but never to show their absence!" (or existential versus universal quantification).

I'm afraid you lost me.