3 ms·
Definitely good stuff to think about in the piece, but even as a Go fan, I found the rhetoric to be insufferable. "Go obviously doesn’t have classes—instead we
by skywhopper 10y ago
Definitely good stuff to think about in the piece, but even as a Go fan, I found the rhetoric to be insufferable. "Go obviously doesn’t have classes—instead we have the far more powerful notion of composition". Go's syntax may frame things differently than Java or Ruby or C++, and I don't discount the impact of syntax and abstractions on code design, _but_ just because you don't call them "classes" doesn't mean they are something entirely different.
Go types can have public and private fields, a set of associated functions which can also be public or private, and ways to extend other structs or pose as other types. So you've got encapsulation, inheritance, and polymorphism. Pretending you don't have "classes" is just silly.
- dilap 10y agoIt's perhaps subtle, but there is a real difference -- traditional inheritance allows the base class to call methods in the derived class; Go embedded fields don't have this property, which is a huge simplification. (You also don't have all the complexities of constructors.)