Re:Static types in Python
by catnaroek on Thursday October 13, 2016 @07:26PM
(#12705038)
OCaml-style structural typing cannot handle deciding at runtime what fields an object has. Arguably it's best to know this statically, but dynamic language users make extensive use of the ability to dynamically add fields to an object.
[ Parent
| on HN ]
...which, of course, make it easier to assume the presence of a particular field and crash.
Using an explicit map for dynamic attributes at least makes you aware what is guaranteed and what is optional.
This removes much of the neat magic that such a dynamic approach affords to languages like Ruby, JavaScript, and, to a lesser extent, Python.