Static typing is still important.
Despite the fact that it has been argued over and over again that proponents of the dynamic approach say that problems arising from dynamic input can be reduced (or even eliminated) with sufficient unit tests.
I do not want to argue whether this argument is correct, so I assume that it is for this answer.
In this case, there is another problem: many stores do not have procedures / know-how / rules / controls to obtain a sufficient number of high-quality unit tests.
And if I need to choose between dynamically typed code without unit tests and statically typed code without unit tests, I choose statically typed code every day.
A similar problem exists with double dispatch :
In Groovy, method calls are sent based on the actual types of the arguments at run time (which is almost necessary because the static type is unknown and / or Object most of the time). This means that there is no reliable way to find out which method is called at any given point in the code when faced with extensible class hierarchies.
Any code that calls a method with signature foo(String) most of the time can unexpectedly call foo(Integer) or foo(SomethingElseEntirely) , depending only on the actual type of the argument at runtime. In Java, which can never happen, since the exact signature of the method that will be called is determined at compile time.
Like other "dynamic" language functions, dual dispatching is sometimes a very useful tool, and its absence can lead to some ugly constructions in Java, but it has its own cost, because it is even more difficult to read, understand, and the reason for the code.
source share