Is Go Object-Oriented? A Case of Public Opinion
This is a modal window.
The media could not be loaded, either because the server or network failed or because the format is not supported.
Formal Metadata
Title |
| |
Title of Series | ||
Number of Parts | 542 | |
Author | ||
Contributors | ||
License | CC Attribution 2.0 Belgium: You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor. | |
Identifiers | 10.5446/62055 (DOI) | |
Publisher | ||
Release Date | ||
Language |
Content Metadata
Subject Area | ||
Genre | ||
Abstract |
|
00:00
InformationPearson product-moment correlation coefficientObject-oriented programmingSoftwareFlow separationEntire functionIntegrated development environmentRule of inferenceInheritance (object-oriented programming)Constructor (object-oriented programming)Social class2 (number)SoftwareArmstrong, JoeFunctional (mathematics)Social classExpert systemGoodness of fitSoftware developerInstance (computer science)Parameter (computer programming)Message passingObject-oriented programmingBusiness modelMaxima and minimaInheritance (object-oriented programming)QuicksortConstructor (object-oriented programming)Spring (hydrology)Programming paradigmRule of inferenceInternet forumTwitterIntegrated development environmentScheduling (computing)
06:08
ExplosionLink (knot theory)RobotPrice indexBookmark (World Wide Web)View (database)Computer fileRevision controlVulnerability (computing)Uncertainty principleSheaf (mathematics)Logical constantVariable (mathematics)Function (mathematics)Error messageLevel (video gaming)Functional (mathematics)Object-oriented programmingRoboticsConstructor (object-oriented programming)Programming languageType theoryPoint (geometry)Computer animation
06:53
StrutFile formatCodeWindowBookmark (World Wide Web)View (database)Interior (topology)Programming languageInheritance (object-oriented programming)Social classString (computer science)Game theoryComputer programJava appletObject-oriented programmingPearson product-moment correlation coefficientGoogolEqualiser (mathematics)Object-oriented programmingSingle-precision floating-point formatType theoryAxiom of choiceParameter (computer programming)Internet service providerMessage passingVariable (mathematics)Different (Kate Ryan album)Programming languageInheritance (object-oriented programming)Point (geometry)Source codePolymorphism (materials science)InformationFunctional (mathematics)Video gameLimit (category theory)Roundness (object)Goodness of fitSocial classHand fanCausalityCodeSinc functionInterior (topology)
13:46
CodeView (database)Computer fileWindowBookmark (World Wide Web)Pointer (computer programming)Computer wormFunction (mathematics)Pearson product-moment correlation coefficientString (computer science)File formatComputer programRobotRevision controlObject-oriented programmingMessage passingData conversionInterface (computing)Multiplication signObject-oriented programmingSocial classInterface (computing)Game theoryType theoryMessage passingImplementationPointer (computer programming)Data conversionInternetworkingParameter (computer programming)TouchscreenRun time (program lifecycle phase)Functional (mathematics)CodeProgramming languageAddress spaceRevision controlComputer animation
20:40
Interface (computing)String (computer science)Bookmark (World Wide Web)Computer fileView (database)File formatData conversionMessage passingPearson product-moment correlation coefficientMaxima and minimaProgramming languageBoom (sailing)Type theoryPhysical systemInheritance (object-oriented programming)Event horizonRobotType theoryData conversionInterface (computing)Web pageProxy serverRun time (program lifecycle phase)Computer programmingObject-oriented programmingPhysical systemIntegerString (computer science)Programming languageRight angleMultiplication sign2 (number)Cache (computing)Expert systemVotingExpression
27:33
Computer animation
27:55
Program flowchart
Transcript: English(auto-generated)
00:08
Okay, thank you, we have to stay on our schedule. So our next speaker, Rona, she stood here three years ago, but before the pandemic was a thing, and she gave us a challenge
00:20
to solve the Go diversity problem within a year. Rona, is it solved? As far as I can tell, yes. Well done, well done. So actually, Marti has stole this from me, because yeah, three years ago, I did challenge this forum to solve the problem
00:41
of lack of diversity within the Go community, within a year, and then the pandemic hit, and it seems that these issues kind of took a side, were pushed aside, unfortunately, but we can start again.
01:01
So I'm here to talk to you today about a lighter topic, is Go object-oriented? Now, it appears to be something that people have many opinions about, and I hope that you do too, because that will be fun. So I am Rona, I am a Google developer expert for Go.
01:22
I create workshops, so that's kind of like my thing, when I want to teach something, I make a workshop about it and in 2022, I kind of realized that after a few years of seeing developers struggling with different paradigms
01:41
around the Go typing system, specifically with interfaces, I figured why not create a workshop about it, and I submitted it to Go for Con Europe. It was, the name of the Go workshop was Object-Oriented Design with Go. And then the comments started coming.
02:04
So something between object-oriented is dead, please let it RIP. To why? Somebody posted a comment on my tweet and then blocked me. Because apparently that's how the internet works.
02:24
So yeah, and somebody blamed me for introducing Spring into Go. Now, I have been a developer for 20 years, but I have not done any Spring in my life, and that is such a specific accusation. I was fairly surprised.
02:41
So I'm not here to promote my workshop, even though I'm giving it again this year in Berlin, and you know, in June, because that would be bad. So what is object-oriented programming?
03:02
So it's the idea of separating software into things or objects or concerns or instances and adding some functionality to them usually called messages or methods or member functions, so that we can work with software in a more intuitive way,
03:23
the way that we understand how we interact with the real world. That's it. Now, where there are things, it can get incredibly messy. That's the business model behind Marie Kondo. Yeah, I felt the sigh.
03:41
You don't have 14 items maximum in your house? You're not alone. And we have this lovely quote from Joe Armstrong. The problem with object-oriented languages is that they've got all of this implicit environment that they carry with them.
04:00
You wanted a banana, but what you got was a gorilla holding a banana and the entire jungle. And that feels like it, it does, it really does. So Go really went a different way. It tried to sort of stay away from this.
04:20
But we will see what remains and what actually remained from this and what actually we were able to let go of in a second. So we're gonna hold a trial where we're going to check, you are going to be the jury. You're going to decide if Go is object-oriented. I'm going to try and convince you. I'm going to show you the arguments for both sides, and I'm going to have to convince you
04:42
that it is object-oriented or I am responsible for defamation. I am taking the Go's good name and dragging it through the mud, tarnishing it, hurting its reputation. You're the jury, you will decide.
05:02
So disclaimer, this is not a real trial. But, and I'm the judge and the rules are what I say they are, which is to say that these proceedings are going to be ridiculous. But yeah, we're just going to have to do it. So what have we come to expect
05:21
from an object-oriented language? Most of you know this by heart, really. We have classes because classes, and only classes can have methods. Classes can also have constructors. Constructors are created, allowed to create objects safely.
05:42
And we also expect inheritance objection. So in Go, we don't have classes,
06:03
and therefore we don't have constructors, but we pretend to have them. So here's where we pretend to have something. Now this one is quite fun. So this is a package that I created. And you can see here that inside type robot, the Go doc aggregated nicely a function called new.
06:23
Now you can see that it doesn't actually have a receiver. It's not a method, it's not anything. And it's just the package level function that the Go doc understood to be a constructor, and then it added it where it should be nicely nested inside the robot type.
06:40
Which is really interesting, because what that means was that the Go team essentially decided at some point that safe construction of objects is a tooling problem, not a language problem. It's interesting. We were constructors, okay.
07:00
All types can have methods, so you've probably seen this, or code similar to this at some point in your life. So I created a new type my thing out of an integer, so we have a new type with an underlying type int. I added a method foo to it using the receiver.
07:22
There is, remember that we said earlier that we have objects interacting through messages. It's called a receiver because it receives. It's that easy, yeah, come on. All together.
07:41
Nobody agrees? What, what's going on? Meh? Yeah, okay. Pathetic, but yeah. I said I was going to judge. All right, so, and then we have, so now we created a variable t of type my thing.
08:01
We assigned it one, and then we're able to call a method on t, foo, voila. We have a primitive type and it has a method, because in Go, all types are created equal. Thank you.
08:22
I finally realized, okay. So, let's move on to inheritance. So we get in Go, we get composition. We don't get inheritance. That's not something that's available to us.
08:41
So this little snippet here is supposed to show the difference. I created a type a, it's an empty struct. I added a method foo to it. It has a method bar, foo calls bar. That's nice. Returns bar. We have type b that embeds a. It can embed as many, as many, as many, as many types
09:04
as it wants. It embeds a. That means that now it has foo and bar, and then it decided to override bar. Fine. Variable b of b, lowercase b of type uppercase b.
09:21
To be confusing, not to be confused, yeah, okay, get it. And we can call b.bar, and we expect b.bar to be invoked directly, and then we call b.foo. Now, with inheritance, we would expect b.foo,
09:44
which returns a.bar, which is overridden, to be called. So we would expect to get b in both cases, but that's not what's going to happen because we do not have this type of polymorphism.
10:01
That is true. Who was it who said it earlier? Raise your hand. Round of applause to the gentleman. Okay, moving on. So let's talk about single and multiple inheritance because this really bugs me.
10:20
So I started my career with seven years of C++, and yes, it sounds biblical because it is. Thank you. Yeah, so I started with seven years of C++. C++ actually has a really nifty feature. You can inherit a lot.
10:42
You have multiple inheritance. It's not limited. Java, Ruby, they allow you to inherit exactly once. That, to me, does not feel like a feature. That feels like a limitation. I don't understand it. Let's say that you have a truck, and you want to describe a container of goods and a vehicle.
11:01
You cannot inherit from both. What do you do? Well, in Go we have composition, but in many, many languages that offer inheritance, you only get single inheritance. Now, I will say this. If you feel, and I know that a lot of people do, if you feel that inheritance is that important,
11:22
it just doesn't make sense that it will be so limited a feature that you will not be able to use properly or fully. And I do believe also that that is the cause of all the messy code that we see because the classes that I used to define were very small, were one function, two functions.
11:41
I didn't have to make odd choices of what is going to go into a class and what wouldn't. So it was really easy to be very expressive. So that's what I personally, my personal opinion is about single and multiple inheritance. I don't feel in most common languages,
12:01
since it's usually single inheritance, I don't feel that it makes it a, it makes it something that is going to determine whether a language is or isn't object-oriented because if it is, then as far as I'm concerned, any language that has single inheritance cannot be object-oriented.
12:23
So, Go is not object-oriented. The usual argument summary, and I'm going to, you have to understand that I'm aggregating here everything that was said to me over the internet, which is a great source of information and also a great source of information. So Go is simple, object-oriented programming isn't,
12:44
therefore Go is not object-oriented. Go doesn't have classes, so Go cannot be object-oriented. It doesn't have inheritance, so it's not object-oriented. And lastly, and this one is a great argument, we're going to dive into that one, methods are not really messages,
13:02
so Go is not object-oriented. Now this one is fun. So this comes from the Alan Kay school. So all the fans of Alan Kay have jumped in to let me know everything about the history of object-oriented. So here's what I've got. One person said, technically they aren't methods,
13:20
so he's referring to receiver, to method receivers, they aren't methods on type T, they are functions where the first argument is type, is the type. The promotion to them as methods is syntactic sugar. It's why you can call, now look at this, this is amazing, v.foo with bar,
13:40
or T, call the type, invoke a method on the type, and provide v as a parameter. And it's true, I'll show you what it looks like. So same code as before, we have a empty struct, we have method foo that we added to a,
14:06
quiet in the court. We have method foo that we added to type A, which is nice, and we can invoke it using two ways.
14:21
One is clearly less common than the other, so this is the common way, or we can invoke it on the type, and pass in lowercase a as a parameter. You have the screen?
14:45
That's why, by the way, a pointer receiver can be nil. So I have this game, I play this game all the time with people who are new to Go and I ask them what's going to happen. So I create, we are able to create methods
15:02
with pointer receivers, so I add foo and make the receiver a pointer. I create variable a, which is a pointer to uppercase A, its zero value is nil, and I invoke a.foo.
15:22
And then I ask people what will happen. Now, we're not going to be able to do this quiz here, because we are late on time and we have to make up some time, but, so I'm just going to run this. So hi from foo is actually return b,
15:47
by foo, which means that we were able to invoke a method on a nil pointer. It's possible, because there is no receiver, there is no actual receiver. Most of the time when we call a method
16:01
in other languages, what happens is that we are, we have to go and go through some reference that's somewhere in the address space of the variable itself. That this tells us that it's not where the method is at all,
16:21
it's not where it's defined, it's not where the runtime looks for it, it's just not. So my co-organizer, my Women Who Go co-organizer, Jessica Green, saw this and said, ah, so there is no spoon, which I thought was amazing,
16:41
because this is kind of a design thing, right? So everything is in our minds, really everything is in our minds. We sort of, you know, we have these philosophical ideas and then we put them into code. If there is anybody who actually thinks that the gophers that you saw, the gopher that you saw on the screen in the maze, there is an actual gopher out there doing this,
17:01
let me know, I wanna hang out. So where do receivers come from? So listen to this, because this is very interesting. According to the Go team, the inspiration to method receivers came from Obern2, which is the object-oriented version of Obern.
17:34
Okay?
17:42
And they're called receivers because they receive messages, except there is no receiver, so everybody's right. Another thing that the same person brought up, which is really cool, he said, well, I forgot to say who Alan Kay was, what's wrong with me?
18:01
Alan Kay is the creator of Smalltalk and also is considered to be the person who coined the term object-oriented. So he's supposedly supposed to know stuff about it, you know. So that's why people quote him and that's fine, it's totally fine. And he has a lot of opinions, which is also great, we encourage opinions.
18:22
So what a person said to me, so in Smalltalk you don't need to explicitly declare that an object can have a specific message. You send it a message and then it decides whether to handle it. So duck typing. Now, this is really interesting.
18:40
Can we do this in Go? Can we check if a certain value, if it can handle a certain message or has, in lamest terms, has certain methods? Well, the answer is yes through the magic of interface conversion. So, again, we type A.
19:04
We added function foo, it doesn't do much, we don't actually care what it does. And we created interface I, uppercase I, and this interface has one function, defines one function, foo, that returns a string.
19:23
And A coincidentally, or pointer to A coincidentally, also has foo, which is a string. Now, this is where Go, completely differently than other languages. In Go, interfaces are implicit. In most languages, if you have, let's say,
19:42
a class, class A, and you wanted to implement interface I, you have to, at the time of creating that class, you have to say something like class A implements I. That means that you have to be, that you cannot have a type that is not aware, has no idea, that, and implements,
20:06
that a certain interface exists and will implement it. Not unless, not unless, and that's why a lot of people move to scripting languages, because that allows them to pick some code from the internet and use it.
20:22
You know, just use it, regardless of what's going on. And Go allows you to actually download some random code from the internet and plug it in using your own interfaces. It's very strange. It's very unique.
20:41
So, with that in mind, if you have implicit interfaces, it makes sense to be able to try and be able to ask whether a type implements an interface, because maybe it does. In other languages, it just doesn't make sense because the answer will be no, right?
21:03
Right. So, therefore, we use interface conversion. Now, this is the syntax. What you need to understand from this expression is that if everything was fine, then Val will have a type, will have a B, which is, which points to A,
21:25
and with the interface of I, inside the interface of I, Val will have all of that and will be able to invoke full, which is this one. Which is exactly what's going to happen. And this is how stringers work.
21:43
Now, we said that small talk, we said that, we said that small talk was created by Alan Kay, and he coined object-oriented. Well, actually, he created small talk with the explicit, explicitly with his ideas of what object-oriented is supposed to be.
22:04
And it's important because, according to Robert Grisimer, who is one of the creators of the Go programming language, this is what small talk was actually the inspiration for this kind of interface conversion so that at runtime we can actually check
22:21
if a type has certain methods. And Russ Cox compared it to duck typing. And by the way, this is a really, really nice read. So if you just Google Russ Cox duck typing, you will find it. It is a really nice read. He explains how the runtime does it
22:40
and also how the caching works because obviously you cannot compute, well, at compile time, you cannot compute every type against all the interfaces in the world. It's really, really nice. And finally, we have a surprise witness. Marcia is going to be the proxy of said surprise witness.
23:01
Do you have your? I am here. So before I introduce our witness, I am going to ask the witness, do you remember giving an interview in 2010 to Danny Kalev?
23:23
I don't recall. Well, it's on the internet, so it must be true. It's true. I submit into evidence a webpage, exhibit 90210. So please read a portion of the text from the book
23:43
or the webpage in your own voice. Okay, Go is an object oriented, even though it doesn't have the notion of a class, the type system is more general. Any type, even basic types such as integers and strings can have methods. Thank you very much.
24:01
So what makes you such an expert to be able to say such, to make such claims? I co-created the language. You created the language. What is your name? Rob Pike. Thank you, Rob. New glasses? Yeah, new dress, when they made it. Thank you very much.
24:20
Thank you, Martia. So yes, Rob Pike actually said that in 2010. I don't know if he actually changed his mind since, but the truth is that I feel that at this point, it is clearly a matter of opinion.
24:42
So I would like to know yours since you are the jury. Voting is now open. So the verdict, it's verdict time. I hope it's now open. Yeah, it is.
25:04
The Go team is not permitted to answer. I believe one of my members asked the Go team last year if Go is object oriented. That's dare.
25:33
I am going to give you 35 more seconds because we have to wrap it up.
25:52
Am I correct? You already see 105 judgments, 108, oh no.
26:02
I created a bunch of bots. All right, so I have to close this. Unfortunately, let's find out what you said.
26:22
That's interesting. Why can't I see the results? Oh, there it is. The results. Yeah, I don't know what happened.
26:49
Let's do this. That's what I did. Wow. Okay, so I am going to cancel these proceedings
27:01
because clearly you're out of your minds as the judge. I condemn myself to providing you with stickers. Lots and lots and lots of stickers.
27:21
Iris, Rona, thank you very much. I have to get off. Thank you. If you have a sticker, you also have to give her one if she convinced you.
27:42
Again, a housekeeping announcement. If you submitted a lightning talk, check your mail, matrix, Discord, WhatsApp, whatever you send to me. I'll try to contact you if you got accepted. If you aren't sure, our Mastodon account has.