Static typing lets you build very large rigid structures where types ensure constraints. However, these constraints get in the way of moving quickly. If you change a signature of a function, you have to first change every piece of code that calls the function. You then have to compile, restart your program, rebuild the whole rigid structure, and confirm the change works as expected. This whole process can take many minutes. The claim is that catching these errors at compile time results in more reliable code.
Dynamic typing has no such constraints to help you catch errors at compile time. Dynamic typing allows you to build organic structures that more fluidly change. If you change a function signature, you don't have to change every piece of code that calls the function. You can change the function and test it in a running application without restarting the application. Doing this takes seconds. Dynamic typing allows you to iterate 100x faster. Being able to rapidly iterate often means better tested code and more reliable code.
Both are valuable. Dynamic typing is valuable during development when you need to iterate rapidly and build a prototype when requirements are often changing. Static typing is valuable when code need is more mature, changing less frequently, and code needs to be put in production.
Ideally you have both. More mature parts of the program are statically typed and more fluid parts of the program are dynamically typed.
> Static typing lets you build very large rigid structures where types ensure constraints. However, these constraints get in the way of moving quickly. If you change a signature of a function, you have to first change every piece of code that calls the function.
I strongly disagree that this sort of refactoring is "quicker" with dynamically typed languages, particularly with non-trivial (i.e. large) code bases.
You have zero feedback and no indication of how disruptive such a change is when working with a dynamically typed language. In fact, you have no feedback on whether you've actually finished the change at all.
While with static type checking, you have immediate and valuable feedback guiding you through such a change. Each line of code which requires updating is identified for you and communicated to you.
Spending my time doing work the compiler should have done for me (including tracking down heisenbugs) has wasted far more of my time than I’ve ever gained from the lax enforcement of dynamic typing.
> You then have to compile, restart your program, rebuild the whole rigid structure, and confirm the change works as expected. This whole process can take many minutes.
This is not my experience at all. Virgil is a fully statically-typed language and compiles fast. When working on the Virgil compiler (approximately 50KLOC), my typical workflow is to run the compiler in the interpreter in my debug, edit, run loop. The interpreter can load the entire compiler, typecheck it, and run it with my changes in 90 milliseconds. If we throw a complete optimized compile in the loop, it's 400 milliseconds.
It takes me longer to switch between my two terminal tabs.
It's not static typing versus dynamic typing. It's ridiculously inefficient languages/build systems versus efficient ones.
Inefficient languages/build systems can make the problem worse.
There are many statically typed languages that can compile in under a second. But when you change any function signature, you still have to ensure every caller is fixed. You then have to recompile, restart the application and rebuild all the data structures. Some static languages allow for hot reloading in interpretive mode, but the types of changes allowed are limited.
In dynamic languages like Common Lisp and Smalltalk you can update the program while it is running. The speed of iteration is 100x faster, because you don't have to restart the application and rebuild all the data structures to get to the point where you can test your change.
Dynamic typing has no such constraints to help you catch errors at compile time. Dynamic typing allows you to build organic structures that more fluidly change. If you change a function signature, you don't have to change every piece of code that calls the function. You can change the function and test it in a running application without restarting the application. Doing this takes seconds. Dynamic typing allows you to iterate 100x faster. Being able to rapidly iterate often means better tested code and more reliable code.
Both are valuable. Dynamic typing is valuable during development when you need to iterate rapidly and build a prototype when requirements are often changing. Static typing is valuable when code need is more mature, changing less frequently, and code needs to be put in production.
Ideally you have both. More mature parts of the program are statically typed and more fluid parts of the program are dynamically typed.