The TypeScript,[6] Elm[7] and Python[8] languages support structural typing to varying degrees.
Protocols and interfaces provide a way to explicitly declare that some methods, operators or behaviors must be defined.
In contrast, with duck typing, the object would be accepted directly without the need for an adapter.
Template (also called generic) functions or methods apply the duck test in a static typing context; this brings all of the advantages and disadvantages of static versus dynamic type checking.
Duck typing can also be more flexible in that only the methods actually called at runtime must be implemented, while templates require implementations of all methods that cannot be proven unreachable at compile time.