Is Golang Object Oriented!? (OOP)
Vložit
- čas přidán 25. 11. 2021
- Is Golang Object Oriented!? (OOP)
In today's Golang video, we will talk about the reasons why and how Go is not an object oriented programming language. We will go through why OOP is invented, its 4 main features, problems with OOP, and how Go programming language's solve its OOP problem. Enjoy!
--
Golang Dojo is all about becoming Golang Ninjas together. You can expect all kinds of Golang tutorials, news, tips & tricks, and my daily struggles as a Golang developer. Make sure to subscribe if you look forward to such content!
Get Your Golang Cheat Sheet! - golangdojo.com/cheatsheet
Git repos & notes - golangdojo.com/resources
Golang Informative - • How much do Golang dev...
--
#golang #goprogramming #golangdojo - Věda a technologie
📝Get your *FREE Golang Cheat Sheet* -
golangdojo.com/cheatsheet
I'm converting my project from Python to GoLang. It was great experience. Thanks for such a great video!
To make it faster?
Glad you liked it!
imagine, me from nodejs... delicious
So, I get into the discussions a lot. The problem with inheritance isn't inheritance itself, but the fact that is so often misused (and indeed misunderstood). Full disclosure, I am primarily an OOP developer, I just think in objects. I really like your point about duck typing, and I think if more people understood that idea, inheritance wouldn't get such a bad wrap.
Example... take the super class A. It has a set of functions that are useful for other things. But it IS a thing. If you decide to inherit from A (class B extends A), the very first question you should ask is "is B an A?"... the problem is that a lot of people (anecdotally speaking for myself and 20+ years of experience) might look at the methods within A and say "yeah, that is what I want to do". This is NOT a good reason to inherit from that class. I have seen it so many times. And where you run into problems is when something DOES change with class A!, It will generally not (assuming the overall architecture is good in the first place) affect subclasses that ARE an A! What it WILL affect (and usually adversely) is a random class that just wanted to use the functions that already existed within A (but that are not As themselves).
So, I do love the duck method you refer to. I think that should be the rule in OOP (not just with inheritance, but with interfaces and polymorphism in general as well).
Thanks for the video. I am getting deeper into Go and find your content very useful.
In 6:26 you don't need to include the "super struct" as a variable just remove "human" from line 13 and the struct is "inherited"
As I learned it at uni, inheritance is not a necessary part of OOP, subtyping is. It is often conflated in many programming languages, but doesn't have to be. Inheritance is basically about code reuse, subtyping is about a more formal relationship between types, see the Liskov substitution principle.
i've always presume that OOP is a must in any programming languages. Go is like a whole new world to me
Same with me at first!
whole new world because you are a self learner programmer. Golang is just like c which is the basic of all programming language.
Encapsulation is not about making some data private , this is called data hiding.
Encapsulation as defined in the object oriented through process book is about making data and behaviors ( methods ) into a single unit
8:10 it is a state of mind. GO does lack subtyping via class inheritance but composition over inheritance is a thing in Java, C# etc. and is actually prefered. Class inheritance is still useful when you want to hide some library/framework glue inside base class, but it can be achieved in other ways.
I like GO, but languages like C#, Scala, Python, etc. happily mix OOP, procedural, functional and work just fine.
What you said at 8:05 simply cannot be overstated!
Nice video dude. really well produced and answered the questions I had
Really enjoying the vids. Many thanks!
Glad you like them!
Could you please make a video about Golang modules, thank you.
In the pipeline!
@@GolangDojo Interfaces also please...
This is my favorite channel of golang content.
Awesome!
Thank you soo much for this!
You mentioned in oop one danger with inheritance is changing a super class method causing breaking changes. How does go solve this issue? Based on composition the same problem exists?
if chnage means renaming identifiers to you, then good luck to you...
@@ZamaaN I was hoping someone with experience would answer but thanks for your comment anyway.
I will make a more example focused video soon!
Can u make video about Go packages? Best go packages or most useful
Will do soon!
So I still don’t understand, if you don’t use OOP in Go what do you use?
I’m still a noob so don’t know everything.
Tbh not everything need to be put in a case. Now some languages are build with a specific goal and take the functionalities of paradigms (like OOP, FP, concurent, parallelism, procedural, ...) without taking everything to achieve the said goal. There are for instance, Go, Rust, Nim that do so
That is something I'm interested in 🤗
Great to hear!
Yes surely need a deeper understanding of Interfaces please..!!
On the way!
programming or hooogramming?
👍
I'm learning Go for a college assignment and I've been liking most of it but the OOP-like stuff is so damn verbose and overly complex
Also I don't understand the problem you mentioned with inheritance in OOP languages, seems like a non-issue, just don't put errors in the base class??
Let’s get rusty guys
LOL
I stopped using GO for this reason. Its fine for little projects but designing anything substantial it quickly becomes a mess. I am actually in the process of converting everything to C++
I think that's a mistake by yours. You think OOP ist class oriented. But that's not true. Alan Kay's definition here: “1. Everything is an object, 2. Objects communicate by sending and receiving messages (in terms of objects), 3. Objects have their own memory (in terms of objects), 4. Every object is an instance of a class (which must be an object), 5. The class holds the shared behavior for its instances (in the form of objects in a program list), 6. To eval a program list, control is passed to the first object and the remainder is treated as its message”
What do you mean by class oriented? Thank you for the comment!
@@GolangDojo I think that OOP is equated with the c++ family. There are some people who say Java is not OOP, as it only allows single inheritance.
@@rumpeldrump lol, who says that? Java supports all types of inheritance. study well before talk...
@@ZamaaN He meant Java does not support multiple inheritance between regular classes , but that can be compensated with multiple inheritance between interfaces...
@@ZamaaNthat would look good on you too. Java has no multi inheritance and use primitive types. And don't tell me about interfaces. Implementing is not the same as extending.
Is golang OOP?
OOP can't be but funcional its a joke hahahaa without having map, filter and reduce ^^
It true FP > OOP
No Go is crap-oriented. I can't believe no other GC-based language have attempted to do what Go did before, which is compile to native code directly. There are efforts in this direction in .NET but honestly, it's late with modest results
Why ? Go learned from his predecessors and have modern features without keeping the heavy old features. It will be a winner in the long run