3 ms·
> This is no different from writing tests in a dynamic language. Types and tests are not equivalent. This is a prevalent myth among dynamic typing enthusiasts.
by naasking 9y ago
> This is no different from writing tests in a dynamic language.
Types and tests are not equivalent. This is a prevalent myth among dynamic typing enthusiasts. There is no unit test that can ensure, eg. race and deadlock freedom, but there are type systems that can do so. There are many such properties, and tests can't help you there.
Types verify stronger properties than tests will ever be able to, full stop. You don't always need the stronger properties of types, except when you do.
- zbobet2012 9y agoTo add some color here on the difference between a type proof and a test: consider that you can never test all possible strings for reverse. However, a type proof can show that reverse, reverses all possible strings. It is possible to test that a function on 16 bit integers returns the correct value for all inputs. Doing so would be a proof by exhaustion. Type based proofs let us prove things using other methods than exhaustion, which is the only possible way to prove things with tests. That is an important property.
- naasking 9y agoIndeed, or to summarize as a soundbite: tests can only prove existential properties but types can prove universal properties.