In Ruby Module#include at Odds with Duck Typing I lamented the fact that Ruby wouldn’t treat an object as an Enumerable unless that object included the Enumerable interface explicitly.
Well Google’s new Go language has no such limitation. If it quacks, it really is a duck in Go:
Rather than requiring the programmer to declare ahead of time that two types are related, in Go a type automatically satisfies any interface that specifies a subset of its methods. Besides reducing the bookkeeping, this approach has real advantages. Types can satisfy many interfaces at once, without the complexities of traditional multiple inheritance. Interfaces can be very lightweight—having one or even zero methods in an interface can express useful concepts. Interfaces can be added after the fact if a new idea comes along or for testing—without annotating the original types. Because there are no explicit relationships between types and interfaces, there is no type hierarchy to manage or discuss.
Well…there it is.