Errors at compile time instead of run time
Strong typing allows the compiler and IDE to catch errors early. In a small code base this doesn’t matter a lot but in a large code base errors become easier to make and tests take longer to run. There is a large productivity difference between finding out about errors while you are coding and finding out when your tests run several hours later.
Refactoring support and better code navigation also make a huge difference to developer productivity. Many of us have worked on large code bases written in strongly typed languages and believe that safe, easy refactoring resulted in a higher quality code base. In our current code base there are many changes that we want to make but we are scared of what we will break when we make the change.
So far, TypeScript seems to excel at all of this. Its type system is surprisingly capable and IntellIj’s support for the language is good enough that many of our mistakes are caught before compilation.
All that said, static typing can cause more pain that it is worth at times, including when people are learning a language. We are happy that TypeScript allows static types when we want them but keeps them optional.
The Surprising Benefits of Static Typing
The arguments above in favor of static typing are pretty common. There are also some more surprising benefits.
First, static typing helps us to ensure that the client and server agree on a protocol. Without static typing it can be hard to know whether a field in a RESTful response is being used by the client, especially if it has a common name. With static typing you get a compilation error if you remove a field that is still being used.
Second, static typing allows us to skip checks that would otherwise be required at runtime. For example, React.js will see significant performance improvements because of this and we hope to be able to take advantage of this in future React releases.
Moving to TypeScript for our browser code is just one of several large changes we are making to improve the stability and performance of Asana. We will have more blog posts coming soon about the other changes.