DEV Community

Discussion on: Is Go an Object Oriented language?

Collapse
 
thomasjunkos profile image
Thomas Junkツ • Edited

I would agree, that go is not object oriented as Java is. Java is the hardcore example, since classes are its pivot point. But if you compare it to python, which is considered object oriented, you find similar goals.
Python has no data hiding too - it was built for adults ;)

Go sacrifices not only encapsulation but on top even inheritance. Go designers have their lesson learned. Go favors composition over inheritance by design, there is only composition.

What go retains is polymorphism and its own flavor of duck typing.
If it walks like a duck and serveHTTP it must be a Handler of a server. But it could be anything.

I would call Go a pragmatic object oriented programminglanguage, if that wouldn't make a bad acronym.

Collapse
 
web3coach profile image
Lukas Lukac

Hey Thomas, I see your point but personally I can't agree Go is object oriented. Inheritance is not that useful, we all learned that therefore is not included in Go design. I would say Go is behaviour driven and has interfaces/typed functions to allow abstraction/extendibility/all kind of useful patterns for maintainable software. That's it. People are forcing the Object Oriented nature on it for no good reason imo.

Collapse
 
thomasjunkos profile image
Thomas Junkツ

Coming from the other side, I agree that go is as far from classical object orientation as e.g. Javascript is. And if you bring your OOP luggage with you, you are perhaps having a hard time.

Not to forget to mention, in Go are functions first class citizens and Go has (of course) closures.

It is hard to clearly categorize Go.

But "kind of" is good enough for me as a category.

Thread Thread
 
web3coach profile image
Lukas Lukac

Fair enough. I mean, the official Go resource I quoted in the article also categorized it only as "kind of" so you are not far away from official Go maintainers! :)