Do Unit Tests Obviate Static Typing for Error Detection?

Evan Farrer to test the frequently cited claim by proponents of dynamically typed programming languages that static typing was not needed for detecting bugs in programs. In his blog post, he explains why unit testing isn’t enough and you need static typing too.

He did an experiment that consist in finding examples of open source, unit tested programs written in Python, a dynamically typed programming language, and manually translating them into Haskell, a statically typed programming language. I would then quantify how many (if any) defects were detected by the type checker, and how many dynamic constructs couldn’t be directly expressed due to being rejected by the static type checker.

The results of this experiment indicate that unit testing is not an adequate replacement for static typing for defect detection. While unit testing does catch many errors it is difficult to construct unit tests that will detect the kinds of defects that would be programatically detected by static typing.

Read the full research document