I'm not actually making a claim one way or the other, I'm rather questioning one argument in favor of static typing.
There are other arguments for static typing which I agree with, but which are too domain-specific.
13 karma · joined July 24, 2016
I'm not actually making a claim one way or the other, I'm rather questioning one argument in favor of static typing.
There are other arguments for static typing which I agree with, but which are too domain-specific.
I disagree with the idea that you need to write more tests because of dynamic typing, my claim is that the tests you have to write anyway also cover type errors. Just running your code yourself covers most type errors.
Chances are however, your type error will already occur the first time you run your code.
http://games.greggman.com/game/dynamic-typing-static-typing/
When a language imposes static types, it also imposes a development cost, possibly negating all the value it brings.
Typescript is a little in the middle in that static typing is optional, but then you also don't reap the supposed benefits wherever you don't use it. Any "tool-based" refactoring is now less reliable than a simple text search.
As for catching type errors, those are usually caught very early. If they aren't, that points to a lack of test coverage.
As for the "documenting" aspect: The article claims that by static typing, the documentation need not be consulted, which is rather irresponsible. If you use a function, you had better read the documentation. I know that's a bit much to ask from actual developers, but it's true.