Either way you need to fulfill the contract, but I'd much prefer to find out I failed to do that at compile time.
Either way you need to fulfill the contract, but I'd much prefer to find out I failed to do that at compile time.
Think about the web, which is full of dynamicism: install this polyfill if needed, call this function if it exists, all sorts of progressive enhancement. Dynamic types are what make those possible.
You want to know how often I find dynamic typing the correct tool for the job? It's literally never.
Dynamic typing does allow you to do things faster as long as you can keep the whole type system in your head, which is why JavaScript was designed the way it was. That doesn't mean it is necessary to do any of those things, or is even the best way to do it.
gcc has nested functions that can act like a closure.
And Clang has blocks.