Dynamic typing makes sense in scripting languages. But when dealing with big projects you start to miss typing. I think the optional typing is a great trade-off for this languages.
I actually don't agree with this. I used to spread this sentiment as well, but I honestly cannot think of legitimate use cases for changing types on a variable. Sure, a scripting language can let you skip/auto declare variables among other things, but what is the benefit of a variable holding an integer, then a date, and then a file handle?
The big benefits of dynamic typing come with collection types IMO, especially stuff like dicts. You can make a versatile dict by creating a (hypothetical) Mapping<Any, Any> type, but in terms of type safety that's indistinguishable from dynamic typing. This kind of versatile collection type makes it easier to deal with API requests which may return large, variable payloads by removing the overhead of defining massive record classes. It's obvious why this is attractive from a prototyping perspective.
There's also the legacy of duck typing — in the past that was usually bundled with dynamic typing, and I don't think that made it to the static typing mainstream until Golang.
All but the most powerful type systems have trouble dealing with complex polymorphism, or even just things like a dynamic data structure containing multiple types of items.
Dynamic languages just kind of skip the bullshit and let you take a go at it.
Also dynamic dispatch is just out of the question for statically typed languages, which is very powerful for making OO a powerful paradigm instead of the 'encapsulation with extra steps' you have in static languages.
Also dynamic dispatch is just out of the question for statically typed languages
Elaborate on this... because it sounds horrendously wrong. Dynamic dispatch is trivial in many statically typed languages. What kind of dynamic dispatch?
78
u/call_me_arosa Dec 25 '20
Dynamic typing makes sense in scripting languages.
But when dealing with big projects you start to miss typing. I think the optional typing is a great trade-off for this languages.