Re:In praise of Go or "Why I moved from Python and C++ to Go"
by BarkMore on Tuesday November 16, 2010 @10:38PM
(#1912789)
From the FAQ: " Although Go has types and methods and allows an object-oriented style of programming, there is no type hierarchy. The concept of “interface” in Go provides a different approach that we believe is easy to use and in some ways more general. There are also ways to embed types in other types to provide something analogous—but not identical—to subclassing. Moreover, methods in Go are more general than in C++ or Java: they can be defined for any sort of data, not just structs."
http://golang.org/doc/go_faq.html#Is_Go_an_object-oriented_l...
The lack of type hierarchy makes code easier to understand.
Re:In praise of Go or "Why I moved from Python and C++ to Go"
by jamesaguilar on Tuesday November 16, 2010 @11:05PM
(#1912860)
Also, an "interface" is more of an enforced duck type annotation than an interface or ABC in Java or C++ terms respectively.
Re:In praise of Go or "Why I moved from Python and C++ to Go"
by aaronblohowiak on Tuesday November 16, 2010 @11:18PM
(#1912890)
IIRC, the duck-type mode uses implicit interface creation but you can force an explicit interface if you want (please correct me if i am wrong.)
Re:In praise of Go or "Why I moved from Python and C++ to Go"
by BarkMore on Tuesday November 16, 2010 @11:25PM
(#1912907)
Interfaces are explicitly defined in Go as they are in Java. The difference is that you do not declare the interfaces implemented by a type. If a type has methods that match an interface, then the type implicitly implements the interface.
Re:In praise of Go or "Why I moved from Python and C++ to Go"
by aaronblohowiak on Wednesday November 17, 2010 @12:31AM
(#1913040)
Oooooh, that makes sense. Thanks for the clarification.
Re:In praise of Go or "Why I moved from Python and C++ to Go"
by stcredzero on Tuesday November 16, 2010 @11:55PM
(#1912979)
there is no type hierarchy
A type hierarchy seems to get misused almost as often as it's well used. The net benefit of it is much less than what the inventors imagined.
Re:In praise of Go or "Why I moved from Python and C++ to Go"
by silentbicycle on Tuesday November 16, 2010 @10:42PM
(#1912802)
Having never written Go, I suspect it means that Go isn't prone to code that requires you to read eleven different files in their entirety just to determine which parts of a method will be polymorphically dispatched to from a given line - code can be reasoned about locally.
What does that even mean?