><i>Why I prefer dynamic-typing over static-typing: the speed of adapting to change</i><p>Funny, that's the same reason I prefer static typing.<p>><i>In How ignorant am I, and how do I formally specify that in my code? I said that I liked to add run-time contracts to a function as I better understand it. When I first write a function, I may not know for sure how I will use it.</i><p>Which is irrelevant. You still know that the "customer_name" argument to it will be a string and the "age" will be an integer, no?<p>><i>For the programming that I do, I am often creating new architectures. Therefore I need dynamic typing.</i><p>Non seguitur.<p>><i>Consider dealing with JSON in Java. Every element, however deeply nested, needs to be cast, and miscasting leads to errors.</i><p>Another bad argument. First, if you don't cast, and expect an integer like 55 but get a string like John, your program has an error. The difference is that in a dynamic language your program will continue to run doing stupid things instead of crashing in the miscast.<p>><i>Given JSON whose structure changes (because you draw from an API which leaves out fields if they don’t have data for that field) your only option is to cast to Object, and then you have to guess your way forward, figuring out what the Object might be.</i><p>You can trivially have a JSON parser that returns a list of map of the 6-7 valid JSON types (maps ("objects"), floats/"integers", strings, booleans, null, arrays).<p>You don't need to deserialize to specific object structure/schema as is the default mode in some parsers, if that's what you want to avoid.<p>If you dislike the verbosity of getting nested elements in Java, that's a Java thing, not a static typing thing. Heck, it's very easy in Haskell (what with lenses and stuff).<p>With a language that supports Optionals and try or has a map index operator and list/map literals, it's more like JS or Python than Java.<p>If you just want to extract a deeply nested element, and not care what it is, but still use it, I'm not sure how that works.<p>Do you expect the object at e.g. resp["x"]["y"]["z"] to change types randomnly?<p>><i>Static typing does not live up to its promises. If it did live up to its promises, we would all use it, and the fact that we don’t all use it suggests how often it fails.</i><p>"Proper weight does not live up to its promises. If it did live up to its promises, we would all be on it it, and the fact that many are obese suggests how often it fails"<p>How about some uses of dynamic typing are for specific, constrained, use cases (e.g. glueing, quick scripts) and it increasingly breaks down with larger codebases and multi-developer projects?<p>Larger codebases and multi-developer projects either don't use dynamic typing (most huge projects the world relies on, from compilers to browsers, and from OSes, to all kinds of embedded hardware, games, desktop apps, etc, are done in one of C/C++/Java), and others (e.g. large websites) are moving towards some kind of types (e.g. Typescript and Flow).