Susan Potter
software: Created / Updated

To Type or not to Static Type

Originally published as a Gist here:

Minor modifications in formatting and an extra line of no-judgement was added to this text from the original Gist.

Purpose, Disclaimer and Confessions

This is the (mostly) no nonesense guide to studies and research that measures and/or compares a variety of facets, characteristics, or manifestations of software development in dynamically vs statically typed programming languages.

Disclaimer: For larger, more complex codebases, I do advocate for statically typed languages that also support algebraic data types (ADTs), generic types, type classes, and preferrably a form of typelevel expressiveness (e.g. dependent types, refinement types) for larger, more complex codebases.

This alone is not enough for me though. Other practices I advocate for include imposing referential transparency wherever possible, modeling with algebraic abstractions such that laws of the system can be encoded as property-based tests either in a runnable test suite or in the type system itself (as with, for example, Idris), using some form of example-based tests to capture edge conditions. However, I have been known to write a lot of Bash for simpler glue logic, so much so that I wrote a Bash styleguide here: I also write much Nix for the infrastructures I deploy.

Previously in my career as a developer I wrote Ruby (relgiously TDD-style) to build Rails web applications and Ruby libraries and advocated in favor of code-level practices that I read in disgust now.

Forgive me father, for I have sinned.

I am not here to judge you on the bet you are making w.r.t. static versus dynamic types. Make your bet on your own terms. :)

Observations of results

  • Measuring things like proness to creating bugs, developer productivity, or otherwise effectiveness of type systems is a hairy task (to say the least) to design valid experiments for.
  • The scope of the experiment is inversely proportional to how precise the result can be (i.e. the larger the scope, the smaller probability the result holds in all operating environments).
  • The results I am presently aware of in this space are not conclusive towards one side or another. In fact, there are some results that offer mixed findings.
  • Many experiments or research studies in the area that compare dynamically and statically typed languages tend to target the lowest common denominator kind of statically typed languages which are mainstream such as Java and C#.

Related (Statically Typed Background)

This is where my current bias will likely show up the most since I am more likely to be exposed to pro static types or at least pro static analysis papers:

These are just pointers. If you have a relevant paper, experiment, or study please link to it in the comments and I will add to this list.

So what?

"To Type or not to Type, that is the question."

Make your own mind up. My suggestion is above in the disclaimer.

If you enjoyed this content, please consider sharing this link with a friend, following my GitHub or LinkedIn accounts, or subscribing to my RSS feed.