When is static typing worthwhile?

Static typing is a crucial tool for constructing correct programs. That does not mean you should always use a statically typed programming language. Often program correctness does not matter and “mostly works” is good enough. you might be better off with a dynamic programming language that has good libraries for solving your problem.

When is static typing worthwhile, then? I have a couple of hunches:

  1. The value of types increases over time. They make it easier to understand large codebases and they ensure that your changes are correct.

  2. The value of types increases together with problem complexity. If the problem is complex, the extra structure given by static typing allows you to concentrate on the problem itself instead of worrying whether you’ve constructed a correct program.

  3. Types boost you in the core of the program, but hinder on the edges. Often you need to interface with the untyped world, e.g. via JSON-speaking APIs. Marshalling the data back and forth takes extra effort in the statically typed world.


Comments or questions? Tweet to me or send me an e-mail.