3 ms·
> Statically type checked code has all of its code paths effectively tested by the compiler The type checker just ensures that a program is well-typed (i.e. fr
by rkrzr 10y ago
> Statically type checked code has all of its code paths effectively tested by the compiler
The type checker just ensures that a program is well-typed (i.e. free of type errors).
The better the type system the more program properties can be encoded in it and the more errors it can catch (up to the point of proving correctness of your program).
But you are right that type checking alone is no substitute for testing. They are orthogonal concepts and both should be employed to ensure that your programs behave correctly.
One nice thing of statically typed languages is that they can automatically generate some tests for you, like e.g. the QuickCheck library for Erlang and Haskell.
- deleted 10y ago[deleted]
- jeremiep 10y agoClojure has quickcheck as well: https://github.com/clojure/test.check https://github.com/clojure/test.check
- marcosdumay 10y agoThey are not orthogonal at all. Both verify your code against invariants. While the typing system tries to prove an invariant holds, a test tried to prove that it does not hold. That means that false positives are the problem for typing systems, while false negatives are the problem for tests. But that's the biggest difference you will find. One does even replace the other.