This is a significant number and is a strong argument for type checking. However, there’s never a free lunch and static typing comes at a cost during development time. Indeed, the developer has to reason about the types while coding and type the type annotations. To measure this, the authors of the paper counted the number of tokens they had to type to fix a particular bug. I didn’t find the results of this part very solid because this method doesn’t take into account the “reasoning” time. However, they did come to the valid conclusion that Flow has an advantage over TypeScript here as its stronger inference system requires less type annotations to detect typing bugs.1
I have no practical experience with either type checker yet. However, I have worked in statically typed compiled languages before and I always felt a certain comfort in having the compiler detect some errors early on. Therefore, on the “static typing vs dynamic typing” debate I am more on the side of static typing. This is also why I am somewhat happy with the main result of the paper as it provdes scientific evidence for my gut feeling. It is definitely an incentive to start introducing Flow or TypeScript in the Sutori codebase (an Ember.js single-page application).
The website has more information about the research. What I would have found interesting is the list of bugs that were preventable with a static type checker. Unfortunately, I couldn’t find any such list. I would have liked to go through and see what classes of bugs are typically caught, mainly to gain more intuition and apply this knowledge on the codebase that I work on.
There was an interesting discussion comparing Flow and TypeScript on Hacker News the day after I wrote this article. ↩︎