← Back to context

Comment by mehagar

12 days ago

On that topic, static type checking can effectively be seen as a "unit test" that tests as well as documents the expected types for an interface.

No, static typing proves correctness (with respect to the types), which unit testing doesn’t do.

  • Unit testing proves correctness in regard to the test written (not necessarily the correctness of the application itself). They're similar in that they are both typically fast to run, and that they check an aspect of the program for correctness.

    • They typically can only prove correctness for specific input data, and then there’s often still some runtime or environment-dependent chance involved which may cause some fraction of the invocations to fail. Is it correct or not if a single invocation succeeds? How can you be sure?

      1 reply →