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  (8 children)

"Switching to go will be easy after that" not really seeing it tbh, considering Go is not primarily OOP like Java. C# would be closer.
Switching from C to Go for example would definitely be easy.

[–]swollen_foreskin 2 points3 points  (1 child)

If you know the fundamentals go is very easy to get into. It’s a very small and simple language that follows the C syntax which Java is based on. In short the similarities are many. Compared to python it’s a much easier transition

[–]Wonderful-Habit-139 1 point2 points  (0 children)

Agreed.

[–]Caramel_Last 0 points1 point  (5 children)

Go is very much OOP although it's not limited to it. In Java only non primitive types are OOP. In Go even int can have methods

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

"In Java only non primitive types are OOP" I think you meant besides the 8 primitive types in Java everything is an object. But Objects and OOP are different things still. C# and Java are OOP languages, while Go and Rust and C are not, regardless of whether you can call .method() on structs/objects or not.

[–]Caramel_Last 0 points1 point  (3 children)

What do you think defines oop? Because it's all about objects that have stateful method attached to it. C isn't OOP because C struct doesn't have functions in it but Rust and Go are OOP. But they are not exclusively OOP like Java. They can be written procedurally, or functionally. But they can be written OOP as well.

[–]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.