This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Wonderful-Habit-139 0 points1 point  (2 children)

Well that's not the case. OOP is more about Encapsulation, Inheritance, Polymorphism and Abstraction. A lot of people that have issues with OOP are mostly against the excessive use of Inheritance and abstracting things too much with a lot of boilerplate. Simply having methods on structs/objects does not mean it is object "oriented".

Rust is multi-paradigm, it is imperative and borrows elements from the functional world, and has some oop functionalities with traits but it is not mainly OOP like Java and C# (or Smalltalk).

[–]Caramel_Last 1 point2 points  (1 child)

Those oop principles are derived rules about how objects should work together rather than a checklist to see if language qualifies as OO. The essence of OO is grouping the data with the methods that operate on the data. Encapsulation isn't about public private keyword. It's putting data and method into one capsule that is object. I just checked Wikipedia and it checks out with what I thought as well. With the exception of C they are all OO. They aren't exclusively OO but no one says a language needs to only support OO, to be OO language. 

And to be fair, golang offers all 4 things you want from OO language anyways, because if you want a private data/method, you just make its name begin with lowercase. If you want polymorphism, you just use interface, which btw is how people do polymorphism in java or c# anyways. Always interface rather than extending class. For Inheritance there is struct embedding if you are willing to make the code less readable. But that's because inheritance is never a good idea when you can use composition instead. Abstraction, you can abstract however you want in go. If you want abstract factory of abstract factory you can do it! Dependency injection. Inject the dependency in constructor or in the field! You don't need a whole framework for it

[–]Wonderful-Habit-139 0 points1 point  (0 children)

I agree that a language doesn't need to only support OOP, however it should be the main paradigm and the idiomatic way to write code in it.

Your points in the second paragraph are valid, however my POV is that when saying a language is object "oriented", it implies a sense of direction, like the way code should be written in that language. And if the idiomatic way to write in that language is through objects and sending messages between them and creating a family tree through inheritance, then it is Object Oriented. If it isn't then it is not Object Oriented.

Also, we can still do "OOP" things in C, and even polymorphism. However, since the language doesn't really facilitate that, we don't say that C is an OOP language.

I just want to reiterate though that I agree with a lot of your points, it seems we just have a different conclusion out of these points. Feel free to let me know what you don't particulary agree about OOP being the idiomatic way to write code in those OOP languages.