Re:Reasons to avoid static type checking
by zokier on Sunday January 28, 2024 @05:25AM
(#39164259)
While there are countless cultural and technical reasons why TS ended up more successful than Python here, I think the single most significant aspect was that TS decided to go with structural system while Python went with nominal. While nominal systems in general are fairly popular and well-received, the chief thing here is that structural types match how the language was being already used. Especially for Python they had before embraced "duck typing" as their idiom and nominal types are in conflict with that.
[ Parent
| on HN ]
Re:Reasons to avoid static type checking
by trashburger on Sunday January 28, 2024 @06:06AM
(#39164487)
This is my single greatest complaint about Python's type system. Protocol should have always been the primary building block rather than just being relegated to something you use for "duck typing". Subtyping fits much better with things like the dynamic approach of the Django ORM, for example.
Re:Reasons to avoid static type checking
by alanwreath on Monday January 29, 2024 @08:51AM
(#39176217)
Not sure what you mean, while it’s true that it would have been nice that Protocols were always the primary building block, as of python 3.8 they _can_ be depending on your use of Structural Typing https://peps.python.org/pep-0544/