Re:Guido van Rossum: The Theory of Type Hinting for Python 3.5
by neckro23 on Saturday December 20, 2014 @08:04AM
(#8776536)
It reminds me of TypeScript, where everything defaults to type `any`, so it can interoperate with normal JS. This essentially makes static type checking an "opt-in" feature of the language.
Re:Guido van Rossum: The Theory of Type Hinting for Python 3.5
by mcintyre1994 on Saturday December 20, 2014 @09:34AM
(#8776708)
Thanks - this is exactly what I was missing. I was trying to figure out the benefit of allowing it in the language, when of course the answer is supporting existing programs.
The key is that we're talking about _Gradual_ Typing: it's not that "you never want to type things as Any" (if you always used a dynamically typed language like Python you probably never cared too much), or "subclassing is too limiting" (if anything, imho is not limiting enough).
The point is offering a tool to people who might benefit from some static checks, to avoid stumbling into problems at runtime. Those people have a HUGE codebase with dynamic types (basically, everything is already Any) and you need to _Gradual_ly specify and move over parts of the code to be correctly typed.
as keosak writes, if you want a proper explanation of theory behind it, just read Jsiek's blog posts