This is in response to
Article No Longer Available
I have mixed feelings about Typescript. To quote Indian Jones, "you call that a type, this is a type."
If this is where people get their opinions of static typing, no wonder they think they should live without types.
On the other hand, trying to quantify root cause of an issue is not trivial. Generally people are not tracking these types of things and it is only a "sense" of the situation. I want to summarize some of my experiences with types and talk to an anecdote.
Experience
Types
- Help with code reuse
- Help with refactoring
- Help guide programmers to correct usage
This first point is really about the next two; you do not need types to make reusable code. If the programmer misuses your library then it isn't very reusable. If you can't make refactoring changes because others might be using it, isn't very reusable.
Let's consider the simplist refactor, rename. Your IDE will very well replace all the usage in the code and you'll be confident things are still working the same. But you have a development team, they are working off branches, some work has practically died on other branches. How do we make sure that the rename propagates to the code in these branches?
With a static typed language, this is a build error. An annoying build error, but preventative nevertheless.
Build failure can occur from attempts to pass objects without the needed properties. And when using a language with compile time execution, these static guarantees can be quite helpful. (plug for D here)
Anecdote
Recently a bug was introduced into some backend code when types were introduced (yes static typed language can work with untyped data). What happened was the type defined expected data before passing the information on to the next system. The previous implementation would blindly pass the blob on.
The previous implementation worked perfectly, the introduction of types was caught by my extensive introduction tests. Why am I so happy that we introduced this bug?
The two systems had a mismatch in expectations for what was contained in the "fault tolerant" web. The system using the data had built its expectations off the existing production data. The type was built from the new data source which did not contain such fields. Our conversations lead to communicating our concerns to the upstream 3rd party.
As my tests use a mock of the 3rd party, had the type been built from our expectations, we would not have caught this issue as we would not have had influence from the real 3rd party API. That is on me, but it all panned out that a bug introduced by types identified issues upstream.
Merge errors always are caught by
GIT. This makes the branch argument weak.
Introduction of Typing is a design decision. It should have already considered ensuring proper interface implementation.
Dynamic typing is nice but a potential liability. If we look at Graphql we see it requires type defs.
None of the issues cited have much to do with Typescript or Javascript. Its merely lack of knowledge of the all important interface of 2 systems; which should, at a minimum be documented.