| ▲ | sirsinsalot 2 days ago | ||||||||||||||||||||||||||||
Follow the trail of the blog post and you end up with Python and duck typing, and all the foot guns there too. | |||||||||||||||||||||||||||||
| ▲ | zbentley 2 days ago | parent [-] | ||||||||||||||||||||||||||||
How so? Genuine question. Duck typing is “try it and see if it supports an action”, where interface declaration is the opposite: declare what methods must be supported by what you interact with. In Python, that would be a Protocol (https://typing.python.org/en/latest/spec/protocol.html), which is a newer and leas commonly used feature than full, un-annotated duck typing. Sure, type checking in Python (Protocols or not) is done very differently and less strongly than in Go, but the semantic pattern of interface segregation seems to be equivalently possible in both languages—and very different from duck typing. | |||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||