Go in 2023 === Paul: ~Test, test, test.~ Johnny: ~Test, test, test.~ Paul: ~Okay. there and welcome to Pod Rocket, a podcast brought to you by Log Rocket. Log Rocket helps software teams improve user experience with session replay, error tracking, and product analytics. Try it for free@logrocket.com today. My name is Paul and joined with us is Johnny Bocek. Johnny is currently the CTO O of a talent acquisition company, as well as being a speaker educator and regular panelist on the Go Time podcast. Yeah. Oh, I did say bok.~ Johnny: ~And it, and~ Paul: ~Apologies, Joni.~ Johnny: ~and it's also a, a talent management company, uh, not acquisition company.~ Paul: ~Okay. Do you want to also, I realized when we said the talent management it, do you want to include the library tagline in there?~ Johnny: ~No, it's fine. Yeah, just you can keep it broad. Yeah.~ Paul: ~Yeah, cuz I, I was like, damn, that kind of sounds like Upwork when I write it like that. So we'll do talent management. All right.~ Johnny: ~right.~ Paul: ~What's it called?~ Johnny: ~C o. Yeah. I have to tell people like Thet is silent, so treat us the cue. You as a c.~ Paul: ~I gotcha. Okay.~ [00:00:00] Hi there and welcome to Pod Rocket, a podcast brought to you by Log Rocket. Log Rocket helps software teams improve user experience with session replay, ever tracking and product analytics. Try it for free@logrocket.com today. My name is Paul and joined with us is Johnny Boko. ~Johnny is currently the CTO of a talent management company, as well as being a speaker educator and a regular panelist on the Go Time podcast.~ Johnny joined us on Pod Rack back in 2022 and he's coming on again today to give us an update on what has been happening with Go in the past year, and we're gonna delve into his thoughts on the world of development today. Welcome to the podcast, Johnny. Johnny: Thank you. It's gotta be back. Paul: ~So, like I mentioned, we're gonna get into some details about like the updates in particular about what happened with Go. Cuz you're the Go guy. Last time we talked about like, why would you choose Go, like we talked about Go skeptics and I mean like this has turned into like go time with Johnny. That's ki so you, you align yourself very heavily with Go.~ If we could just like circle back to. The last podcast, maybe we could get into a little bit about why you love go so much ~and really quickly about, you know, why you align. So,~ Johnny: Yeah, absolutely. ~Um, yeah, it's, it's,~ it's funny because when I think back of ~sort of~ all the technologies that I've used over the years, and ~I've been,~ I've been in the tech industry for close to 25 years now, if not more. ~Um,~ whene, whenever I think back of all technologies that I've, that I've. ~That I've~ touched, that I've come into my world, my ecosystem ~and, and,~ and the tooling I [00:01:00] use to, to solve problems ~and,~ and the solutions I've built over the years. ~It's like I,~ whenever I think back I'm like, okay, maybe it's recency bias. I don't know. But whenever I think about~ it, I'm like, okay, my, the,~ the pleasure I've had, right. Building these systems and programming that, that, that pleasure ~I've,~ I've experienced with go, I don't think I've experienced the same thing with. With, ~you know,~ other technologies, other programming languages. ~Right. And,~ and the, the closest thing to that has been Ruby, which I did a ton of prior to adopting Go. ~Um, and, and,~ and that's because Ruby set out to be ~sort of~ that language ~that~ that sort of, ~um,~ makes it. Fun ~and, and,~ and, ~you know,~ is designed for the programmers sort of enjoyment, right? ~It,~ it, ruby go out goes out of its way to make things like a pleasure to use, ~right?~ Whereby that was not, goes ~sort of a,~ a, ~um, sort of ~a, ~um,~ primary concern, so to speak, ~right? So,~ but interestingly enough, I believe they accomplished that, ~right?~ Even though that wasn't a goal of the language. I think ~they,~ they, by trying to make the language as simple as possible, I think they achieved that anyway, ~right?~ ~Without,~ without going outta their way to, ~you know,~ provide some shortcuts and different ways to express the same thing. ~Right.~ So when I think about the, what do I, why do I love Go so much? ~And,~ and [00:02:00] I think back, I'm, ~you know,~ I've worked ~on,~ on at this point, I've worked on systems large and small within the world of Go. ~And,~ and I, ~you know, you know, in some, in some,~ in some projects that are so big and massive, you dread going into them. Cause you're like, oh man, I can't hold all of these things in my head. There's just so much going on. ~Uh,~ but even in the world in with go, even with such sort of projects ~and,~ and lots of things going on because I'm able to ~sort of ~easily navigate the code base, the patterns ~are,~ are ~sort of~ familiar. And their, and the idioms, right? That, that go developers ~sort of~ adopt early on ~in their,~ in their learning journey. Like I see that repeated over and over again, so it becomes easier. So I, I can ~sort of~ use go as ~sort of~ a, the fact that I'm using go sort of false to the background and allows me to just focus on the problem, focus on the business logic, right? ~I'm not, I'm not,~ I'm not trying to fight the language itself, ~right?~ I think, which is really why to this day I still. ~Really,~ really like working with Go ~and, and,~ and if I, ~if,~ if I can help it, I'll probably retire on it. Paul: ~I, I mean like~ that is quite the vouch for the developer experience. And even beyond that, how it sounds like it enables you and your career ~and,~ [00:03:00] and ~what have you seen,~ how you said it has enabled others in their careers. ~Um, and,~ and one thing you pointed out, you were like, ~um,~ There, the people who helped create go maybe did not intend to have, ~you know,~ such a great usability be its outcome. But that happened anyway. Do you think that was, ~you know, uh,~ forefront of design because of the initial creators of the language, or was that because of the community that came in and sort of~ like~ branched it out and it was ~the,~ the vibe, ~you know,~ how people wanted to contribute. Johnny: The, I think ~as,~ as twofold ~the,~ the creatives of the language. I, ~and,~ and having heard, ~you know,~ at least one of them, two of them talk, ~and,~ and those that, that now maintain the language, right? That the creators of the language have ~sort of~ moved on to other things. But the people who maintain the language, ~you know,~ you know the GO team, ~um, and,~ and some of these folks are very prominent and, ~you know,~ they show up ~at,~ at go conferences and speak ~and,~ and things like that. So when I think back on, on some of the creator's talks, which are still available on YouTube and easily accessible ~and, and.~ And thinking about some of the more recent talks from [00:04:00] the people who actually actively maintain go and from other prominent members that are not necessarily on the go team, but also contribute to ghost's community ~and,~ and its library ecosystem and everything else. And really, it's like twofold. One, ~the,~ the creator set out to create like simple language that could scale to ~many,~ many developers ~on a, on a,~ on a team, right? They wanted something. You didn't have to do a lot of mental gymnastics. ~Right.~ To wrap your head around, ~like~ allow, once you're familiar with the language, allow it to fall to the background so that you can actually focus on the problem at hand. ~Right. That, that was,~ that was, ~that, that at least was, was~ something ~they, they, they, ~they strove for the other half of that was, it came in the form of the community. ~Right. Um, sort of~ surfacing. ~Right.~ Idioms and patterns at work. ~Uh,~ some dos and don'ts, right? Some things, obviously, ~you know, the,~ the language ~kind of, kind of~ guides you a particular way like that, a particular way that it wants to be used, right? Which is why I always tell folks, ~like,~ look, when you're coming in to go le leave preconceptions ~and,~ and things that you're familiar with from other programming leaders leave these things at the door. ~Right,~ because you're gonna come in, into go, you ~kind of~ have to unlearn some things and some things that you've, you're used to in other languages, you ~kind of~ have to ~sort of, uh, um,~ leave those expectations behind because go is gonna ~kind of~ lead you down a particular path, [00:05:00] right? ~And,~ and the moment I stopped fighting, go the moment I stopped. Trying to write gooby, which is what I, which is what I call you basically when you're going from Ruby or some other language, ~like, you know,~ gafa, Gooby, Guyon. This is just why when you're trying to bring some idioms from other programming languages into the world of go, you quickly realize, okay, I'm doing something wrong, right? Maybe I should follow idioms, so I should read some blog posts, watch some YouTube videos, ~um, you know, from,~ from folks that are reputable ~within the,~ within the community. And you start seeing, oh, okay, now I understand why. Right. Things are seemingly are easier to grow and understand when I use the language in that particular way. So ~it's,~ it's like twofold, ~right?~ It was the goal of the language, ~uh, uh, uh,~ creator is to make it simple. And it was the community and the idioms and the patterns that have emerged since then and continue to emerge to this day, right? That, that those two facets, ~right,~ make it, ~you know, that,~ that a combination leads to, to, to what I'm talking about. ~That,~ that, that love for go, because it gives me both sides ~of, of, of,~ of those benefits. Paul: ~It,~ it must be amazing to see that symbiotic relationship ~sort of~ emerge. ~I mean, you know,~ the creators ~kind of~ did something, right? If it allows that Johnny: Mm-hmm.[00:06:00] Paul: relationship to emerge. They really built a platform that lets that happen. ~So, uh, I,~ I guess it ~kind of~ can make me excited about what idioms are gonna emerge in the future as the language continues to get built out. ~Uh,~ right before we kind of wrap, ~uh,~ or step into some new. Things that are coming up with go, what do you have to say to the people who are wanting to get into a lower level language? Maybe they've only been tooling with like type scripts, for example, and they wanna write some concurrent processes and they go into the internet and they search up. I want to, ~you know,~ look at some languages that are backed by Google and they see carbon and go, Johnny: Mm-hmm. Paul: what do you have to say to the folks who maybe are ING carbon? Johnny: ~Well,~ so let me take a, let me take a, Sort of 10,000 foot view, right? So the recommendation I can give regardless of the language people are evaluating today, ~um,~ if you are looking for, if you are looking for a low level sort of systems programming language, right? ~Um, um,~ right now~ I can't,~ I can't recommend Rust, ~uh, uh, um,~ enough for that, ~right?~ ~Because I think.~ I think ~the,~ the design of the language, ~the, the,~ the things that were a priority for the designers of the language [00:07:00] and what the community is doing with that language, ~right. Uh,~ the kinds of problems they're solving, like ~the, the,~ the whole new way of thinking about programs like with the, with a strong sort of a memory management. ~And,~ and ~sort of~ borrower checker and all these things, like these capabilities are ~sort of~ doing away with a whole class of problems that it pre, ~you know,~ existed. ~You know, with the,~ with the c ~plus~ plus days ~and, and,~ and even someone see stuff, ~it,~ it's ~like~ if you're looking for that low level, ~you know, raw,~ raw performance, dealing with low level system stuff, ~you know, and,~ and you have a choice between something like c o c ~plus~ plus, ~um, and,~ and, ~you know,~ and versus rust, I would encourage people to ~sort of~ go the rust route. Now, why would I recommend Russ over go ~or,~ or anything else? ~Well,~ that's because ~of,~ of ~sort of the,~ the suitability for that particular language and the kinds of problems the community is so coalescing, ~uh,~ around right now. Could you use Russ to write, ~you know,~ network services, ~you know, uh, uh, um,~ kinda like the way, ~you know,~ those things are the bread and butter for the gold world. Absolutely. Right. There are, there are projects, there are frameworks within our community that have, that are emerging, that are tailored for that kind of, ~uh,~ use case, but, That, that world of building networked applications and services ~and, and,~ and, ~um,~ message queues and distributed systems ~in,~ in [00:08:00] one and cloud native applications. I think that world, that realm still is very much dominated by go, right? ~Um, you,~ you're talking in systems like, ~you know,~ Kubernetes ~and, and,~ and Nats ~and,~ and all these kinds of, ~you know,~ highly distributed, highly concurrent systems like ~that is,~ that is by far dominated by go. ~Right. Um,~ it could be that, ~you know,~ it is just timing go, came at the right time. It was there at the right place ~and,~ and some of the tech early technology decisions, ~you know,~ technologies that pretty people ~sort of~ take over. Granted for rented now operating cloud, ~you know,~ infrastructure, ~um, you know,~ could be the timing. ~You know, had,~ had that done, been done a different time or who knows, maybe all of that would stuff would've been supported by Rustin said, who knows? ~Um,~ but I think go ~sort of~ supremely dominates in that space still. ~Right?~ But it's not one or the other. ~Right.~ You have a choice, right? ~And, and,~ and if you are ever ~in a,~ in a sort of enviable position of making like such a low level dis ~uh,~ decision, such as ~language,~ language choice, ~you know,~ for a particular, a venture, ~uh,~ a new project, new company, whatever it is, ~um,~ that doesn't happen often ~for,~ for most of us, ~right?~ A lot of time we come into a, ~you know,~ a company or a team, these decisions have already been made for us, ~right? You know,~ we just have to. Fall in line and follow the process, follow the patterns, ~right?~ But if you're ever in a position where you get to [00:09:00] pick or if you're, ~you know,~ trying to do ~a,~ a sort of a side project, ~right?~ ~You get,~ you get to try different languages. Maybe you're coming from the transcript world, ~well,~ again, whatever language you're coming from, ~right? The,~ the kind of leave your expectations at the door, ~right?~ And then ~sort of~ a, ~uh, try to~ try to embrace whichever ecosystem you ~sort of, you know,~ whichever language is ecosystem you ~sort of ~dive into, try to embrace their patterns, their way to do things ~right.~ Leave your, they all want own way of thinking, ~you know,~ out the door at least until you develop enough of an understanding, enough of commonality, ~uh, um,~ with, ~you know, sort of the,~ the ways people ~sort of ~build systems, right? And regardless of what the language syntax does, people are gonna use the technology in a particular way. ~Right.~ Learn what the ways are ~right.~ And then start to make ~your,~ your informed decisions that, mm, I like that spa, that pattern. I don't like that pattern. Or, heck, I like this language. I don't like this language for these particular use cases. Paul: ~Right on.~ And what's one example of I, I don't, I want to pick on like type script in particular cuz it's one of the most used languages out there. But please ~like,~ choose anything. If you have a good. Example, but I want to like double click on one example of one of these idioms. You see people bringing in Togo that [00:10:00] really hasn't worked that well, that they then left behind and accepted like the new way to do it and went over that bridge. Johnny: One, the one that immediately comes to mind is, ~you know,~ a lot of people coming to grow, expecting to have exception handling. ~Um,~ and they're like, ~you know, where,~ where's my try-catch, where's my family? ~You know, where,~ where are all these things that I'm familiar with from other languages? ~Right? Um,~ and ~you know,~ like I, I don't do type script day to day, but I, ~you know,~ but I would imagine that it has, ~you know,~ some sort of exception handling capability. You can bubble up errors ~and,~ and let something else handle it, ~you know,~ up the stack, whatnot. ~Um,~ for the world of Ruby, I know it has, ~you know,~ a a trying capabilities and exception handling~ in,~ in these things. ~You know,~ certainly, ~you know,~ the Java, ~uh,~ ecosystem has that ~and,~ and pretty much virtually all recent modern programming languages. ~Right.~ Have some sort of, ~you know,~ Exception handling capability, right? ~You,~ you bubble up an error, you let something else up the stack handle it, or you try to handle it locally. What, whatnot. So these things, people are coming into the world of go expecting to, to have these kinds of capabilities and they realize, okay, go's error handling,~ right?~ Which I, ~when I,~ when I say error handling, exception handling, I'm being very nuanced here ~and I,~ and I wanna call out the attention [00:11:00] to the nuance, right? God does have error handling, it just doesn't have exception handling, ~right?~ So ~when,~ when I say exceptions, I mean you throw an error. Something else catches it and does something with it. ~Right?~ Go forces you to treat your errors as values right then and there, ~right?~ So which is why you see ~the,~ the pattern ~people,~ people tend to ~sort of~ hate when they first see it. ~Like~ if error not nail everywhere in, in your code base, ~right?~ Like they, they see that like, ~why, why is,~ why is this, why, what is all this noise, ~right?~ Why is every interaction to some subsystem, ~you know,~ capturing an error return and there's this error, not nil, ~you know,~ check all over the place. ~Like~ what is that? ~Right? And,~ and that's the first thing that sort of strikes people in it. It, because it struck me and I thought it was weird. I'm like, why is there no exemption handling? ~Right?~ And then I realized, okay, Goree Airs has values, ~right?~ Like any other value of a given type right. In your program. ~Right.~ It just forces you to deal with the consequences ~of,~ of the possibility of an error right then and there. And I, I think I've even seen papers, right? ~Uh,~ written sort of a university research papers written on, not go specifically, but on, on the value of handling your errors at the time.[00:12:00] ~You know,~ at the call site, ~right?~ Basically, when you make a call to something, ~you,~ you, maybe it's r p c, maybe it's whatever it is, some other part of your system, ~you,~ you make a call and you handle, you are forced to think about the possibility that something might have gone wrong, right? ~At the, at the,~ at the call site,~ right?~ ~And, and,~ And when you do more of that, ~right, the, the,~ the chances that some error is gonna get bubbled up. ~You know,~ hopefully something catches it, ~you know,~ up the stack ~or,~ or that ~you know,~ there some mixes somebody else's problem. ~Somebody,~ somebody could be you, it could be some other, develop, whatever the case, right? Maybe you have some exception. Global exception handler when, where all the things get logged out, whatever it is, ~right? The, the,~ the. You have, you had fewer errors right ~now. Now, I wish I could think of the title of, of that research paper, but maybe we can put that in show notes or something. Um, you had fewer errors, right?~ In the programs where the errors were handled ~right. At the,~ at the call site than they were if it, they were just left to bubble up you to some other process for handle ~Right.~ That you programs were more correct. ~Right.~ Or at least more resilient ~Right. To,~ to, to failure. ~Right.~ To some certain failure modes. ~Right.~ Then programs where you just let things bubble up. ~Right? So the,~ the, that whole understanding, that whole concept. It took, it takes, usually takes people, ~you know,~ it took me a while to wrap my head around and to stop fighting their language.~ Right?~ And yes, can you have typed errors? Absolutely. You can say, Hey, I can have different kinds of errors. I can have,~ you know,~ if I wanna capture, [00:13:00] if I'm being throttled by a remote system, yeah. I can capture an error, create some sort of custom type and bubble that up, right? ~If I, if I,~ if I don't wanna leverage, ~you know,~ part of the standard libraries mechanisms already, you know what? Whatever I can create custom. Error handling behavior. I can have custom types for certain things, right? I can have all that richness, ~right, of the,~ of the type system, ~right?~ But I just, I have to handle my errors where it happens, ~right?~ Paul: And I, from my perspective is, ~you know,~ I've seen code that it's like, ~uh,~ the choice of do I return to value or an error like that tuple sort of structure is, ~um,~ really left up to the developer. And then when you have exceptions combined with that, The lines become incredibly blurred and ~you know,~ stepping from that sandbox into a more concrete set of rails. ~Well,~ like I can imagine for sure how that ~like~ reduces your overall surface area at the end of the day. It may not be fun all the time, ~but uh, yeah, I guess that~ Johnny: ~I mean, it, it, it,~ you think about it, it simplifies it, ~right?~ There's few, ~there's fewer,~ there's fewer things to think about if you know that, okay, anytime I make a call and I'm gonna get that tool, re return,~ you know,~ the error, something that satisfies [00:14:00] the error interface ~right? Is,~ is usually the last. Thing that gets returned. ~Um, and,~ and then go, ~you know,~ there's usually, ~there's a,~ there's a two value return, especially for when things could go wrong, ~right? Um,~ sometimes you see three, but it's more common to see two. ~Well,~ whatever the value I'm looking for and the possibility of an error, ~right? Um,~ this, ~and, and,~ and, ~you know,~ you see that pattern. ~Right. There's,~ there's no question that, oh, this thing returns an error. I need to handle it. ~Right? It's, it's, it's almost,~ it's like automatic, right? ~And, and the,~ and the biggest grip people have with that is they'll be like, oh, ~well now,~ now I have all this noise in my code that~ I have to, you know, it~ makes it harder to see what's actually going on in, in a given code block. I'm like, uh, trust. Trust me. You are gonna learn to literally read. Past those things, right? If I'm looking at, ~you know, a few,~ a few files, I'm navigating a program, ~you know,~ with multiple goal files in there. Literally my eyes have learned to. Sort of skip over the, if error, not nil checks. Like ~I'm,~ I'm looking for, ~you know,~ the statements where calls are being made. I'm like, because ~I'm,~ I'm following a happy path, ~right?~ So I'm like, okay, the system does this. I I could have a, a function within a function. There are four calls made and there are four, ~you know,~ Error handling,~ um, sort of~ a, you know, condition was in there. My eyes will literally see the [00:15:00] four statements, ~right?~ And I'm, because I'm looking for that happy path. What is, what does this code block do, ~right?~ And then I see what, what gets returned. Only then do I go back and say, okay, ~well,~ when things don't go wrong for this particular role, what are the possible. States, ~right?~ What could go wrong if I make this call? Oh, you're, if this call is go, goes wrong, you call some other subsystem or you log it out, or you send, ~you know,~ you, you mark your distributed tracing, whatever you want to use. You're open telemetry call, whatever it is. ~You, you, you,~ you indicate some error of some kind, right? Then I'm like, okay, now I can start seeing how you choose to handle. When things don't go right. ~Right.~ And things don't always go right. So ~that's,~ that's the value, that's the beauty ~of,~ of that way of doing things. ~Right.~ Could you write your, go and ignore all errors? Yeah, you could, but you'd be shooting yourself in the foot and you'd be basically not taking advantage of one of the biggest values of the language, which is really~ like,~ handle the possibility of your errors. Cause errors will happen. Paul: They will have they, it's not if, it's when and it's [00:16:00] when. And I mean you can type your errors and we're gonna get into some of the new updates that ha have come into go in the past year. Before we do that, I just wanna remind our listeners that this podcast is brought to you by Log Rocket. Log Rocket offers session replay, issue tracking, and product analytics to help you quickly surface and solve impactful issues affecting your user experience. With Log Rocket, you can find and solve issues faster, improve conversion in Adoptin, and spend more time just building a better product. So go ahead and try it for free@logrocket.com today. So Johnny, if we're talking about typing. Errors. ~Uh,~ one thing that is very useful in typing our generics, and I know that's ~kind of~ a new thing that's come out and go, do you think we could delve into that? Johnny: Yeah, absolutely. Absolutely. So ~the, the,~ the, ~whenever, whenever folks,~ whenever folks talk about generics and go, because of the history ~of,~ of go and go's, lack of generics, ~uh, uh, um, the,~ the. You get ~sort of, um,~ you got a couple different [00:17:00] camps. ~Uh, um, when, when,~ when it comes to generics, when we talk about go,~ right?~ ~You have,~ you have the people that prior to the introduction of generics. Alright. And I, I don't think generics was in the language the last time I was on the show, but, ~um,~ since then, it certainly ~has,~ has had that added, but, and you get those people that basically, that used to criticize, go for the lack of generics, right? As a primary sort of modern quote unquote modern language feature that okay, I can't use go because primarily it doesn't have generics ~and,~ and other things. Paul: Right. Johnny: And then you have people that say, ~well,~ I would only use generics, or I would rather I would use go if it had generics because there's some things I wanna do. I have very specific use cases that generics would lend itself well to. ~And,~ and once the language has those things, I will start using it. ~Right.~ Which I think is the more ~sensible,~ sensible approach, ~right,~ because you actually have a use case. That you want to address with the language, and once the feature is added, you're like, okay, great. Now I can actually, ~you know,~ the idea that I wanna bring forward, ~that,~ that I envision, I can bring that, ~you know,~ to, to the fore because now the language allows me to do that. ~Right.~ Very sensible and I respect that. What I find interesting is that you had a lot of folks that[00:18:00] ~didn't, didn't.~ Had never used the language really ~for,~ for anything other than a hello world, ~um, sort of~ criticizing the language for the lack of generics. ~Um,~ and again, like ~I don't,~ I don't wanna sound, uh, um, like I'm, like, I'm blaming those folks. ~Um, I'm,~ I'm not, ~I mean, if, if,~ if folks were in one of those camps, ~like, well, I'm not,~ I'm not uniting ATRA language because it doesn't have a feature. ~I really,~ really love ~what,~ what? And I've heard ~those,~ those, ~uh, um,~ comments before in the past. And what I usually would ~tell,~ tell them is ~like,~ okay, ~um,~ could you at least try the language right? Using the mechanisms that, that it does have in lieu of generics. And there were basically three ways of doing that, right? There is basically was writing a lot of border pay code to handle different types, right? So imagine you have a sum function and ~uh,~ prior to generics, ~you, you know,~ if you wanted to sum anti jers and you wanted to sum also, Floats. You would've had to create two separate functions, like a, maybe a sum ants and a sum floats, right? To basically handle the different types ~of, of,~ of, ~um, you know, uh,~ lists of numbers that you wanted to sum to. Basically, you could only do it, okay, for inte integers, I'm gonna have one function, and for floats, I'm gonna have another function. But the body of the function would've been virtually the same, right? You're iterating through the list and you are accumulating a sum, and then you [00:19:00] return that value, right? But that value. ~Right~ had to be of the type right of the numbers, ~you know,~ that you're sending in. So if I'm sending in integers, I have to reach return integer back, so I couldn't support. Both floats and integers were on the same sum function, so I had to create two separate Paul: it through. Johnny: right, exactly. Either it's two separate versions of that, ~you know,~ function. So~ that's,~ that's a boiler plate approach. ~Right.~ And keep that in mind cuz we're gonna come back to it cuz generics doesn't. Something very interesting with that boiler plate. ~Right.~ So the second approach was to use the mt interface. The mt t interface and go basically means that there's no type information, right? ~Uh,~ you can't get to the underlying type, ~but you know,~ when I pass this particular, when I call, when I invoke a function and I pass in that, ~that,~ that, ~um,~ argument, ~you,~ you basically, you can say, Hey, ~like,~ I want, you know, in the parameter,~ in ~a, in a signature of the function, I want this parameter to basically, ~um,~ to be of type empty interface, which means no type information. So I can't tell whether it's an integer or flow, whatever it is, based on the function. Signature alone. ~Right~ now when I invoke my, ~my, my,~ my, ~uh, uh, uh, um,~ function, ~you know,~ I could pass in a list of integers. I could pass in a list of floats, right? But inside of my sum function, then, right? Even though I have one function, right? But because I'm receiving[00:20:00] ~a, a,~ a list of empty interface, basically, meaning a list of things that have no type information on a, on their face, right? ~Uh,~ in the signature inside of the function. Now I had to do a type switch to figure out, okay, let me get to the underlying, ~you know,~ type of whatever it is I'm currently iterating on. Sorry. So ~if, if, now,~ now I'm like, okay, if this is an integer, right? ~I have a, I have a,~ I have a value that they should notice to be an integer, right? Um, then I'm gonna accumulate that in inside of a, ~um, um,~ inside of my integer. If it's a float, then I'm gonna accumulate that ~inside of a,~ inside of a flow. And now my return, ~right,~ is also now of the, of an empty interface type, right? And then ~on the call,~ on the call side, now I have to cast that down. I have to convert that value back down to, ~you know,~ either an integer or a float, right? So I'm doing all this gymnastics. To get around the fact that I couldn't specify the different types that I wanted to in the function signature right in, in, in the parameters of the function. So keep that in mind. ~We're gonna,~ that's the other aspect of that generic solves, ~right? ~The third approach was to use reflection, which means that run time, not a compile time. At run time, you're gonna be like inferring and ~sort of, uh,~ using the ~reflection,~ reflection library, ~you know, um,~ package in the standard library to [00:21:00] fit to, to get at to some underlying details. But it's, it's a very. Like in the Go committee, we tend not to rely ~on,~ on sort of reflection too much, ~right?~ Unless you're building a framework where you ~kind of~ have to rely on that. ~But you know,~ it's that runtime sort of type, ~um,~ digging investigation. It's not great for writing your sort of regular day-to-day sort of business logic. So we usually tell people like, look, ~avoid generic, you know,~ avoid a, ~um,~ reflection ~whenever,~ whenever possible, right? But those are order the three arrays prior to generics when within the Russian generics basically go, says, Hey, you now can have what's called parametric polymorphism. ~Right.~ So what that means is that I can basically say, okay, I'm gonna have one sum function ~right~ now. I'm gonna specify some type parameters. I'm basically gonna say, Hey, I wanna have one sum function. But the types that this sum function can actually work with, right? The types that it supports,~ right,~ can be either an in integer or a float. ~Right.~ So now you've defined what the supported types are ~within,~ within your sum function. Now, when you invoke your sum function, whether you pass in a list of integers or a list of floats, right? The compiler does your solid. Back to that boil piece stuff we were talking about before [00:22:00] it, the compiler will literally create different versions of your function for you. So other than you having to create some ants and some floats, that atal time. The compiler is actually gonna create those versions of the functions for you. You, as a developer, ~your, your,~ your programming experience remains, ~you know,~ nice. Because the only thing you've done is you define ~a,~ a generic sum function specifying the types that it supports, right? When you invoke the function. Right. Due to some inference that happens, ~you know, uh, uh, in,~ in the, ~you know,~ at compal time as well, you don't have to say, oh, I'm invoking this function with a list of ends. You don't have to specify the type of the things you're passing in, ~you know,~ go can infer those things for you, making your experience of using that some function no different from, ~than,~ than you used to. ~Right. Um, so the, the,~ the, that value, ~right.~ The compiler gives me a solid by basically ~by, by,~ by, by. Creating those versions for me and keeping my developer experience, ~you know,~ like a, a very nice one without having to worry. So ~I've,~ I've used generic library code~ without having,~ without having to know that the code is generic. ~Right.~ And that's the beauty, that is one of the major reasons why it took some time to get [00:23:00] generics into the language because the, the, ~you know,~ basically the community and the language designers wanted to make sure that using ~like.~ Your usage of go didn't change because generics was introduced and that's exactly what happened. Generics was introduced, right? And nobody had to change the way they write. Go. Now you just had another tool in the tool belt to say, Hey, I'm writing a lot of boil bait here. Right? And the only thing that's different is the type. That I'm sending in the type of value that I'm sending in perfect opportunity ~for, for,~ for creating a generic version of this particular, ~you know, uh, uh,~ behavior over this particular piece of code. Right? And then now you have this tool to do it right. The basic biggest, ~uh, uh, um,~ so to takeaway from the introduction generics rate really is that parametric ~poly~ poly polymorphism capability. Paul: It almost speaks volumes to the language. If the, ~if,~ if the creators are making this decision about ~like,~ do we, we can, but should we? Because is it gonna change the ethos of the language? ~And the,~ and the way that you model things in your head, because of course you can, I guess everybody's known you could do this. I'm sure people had [00:24:00] their own little generic wrappers out there, but Johnny: Mm-hmm. Paul: if you're coming in to go, you have to make sure you understand that you're not changing the way you write it. So ~you went,~ you went over three. ~Uh,~ general ways. I was ~kind of like~ joing them down as, as you were listening 'em off. ~Um,~ the first one sounded like almost like you're writing separate versions of your functions, almost like you're overloading them. Uh, the second one was, did you say it was an empty return type? Almost like a void, so you Johnny: ~It's, it's,~ it's, yeah, exactly. So it was ~the,~ the type information, right? For the list you are sending in, ~you,~ you use, ~uh, uh, the, uh, so another, um,~ think of the alias for the empty interface. ~Right? Uh, so for,~ for people ~who, who,~ who have some passing familiarity with the go is the, literally is the keyword word interface with an empty braces next to it, right? Basically the alias for that is any. ~So,~ and I'm sure you've come across and ~the,~ the term any or the keyword, any and other programming languages, it literally says any type will do. ~Right.~ So that's exactly what it is. ~You know,~ the problem is ~you,~ you then have to do some work to figure out, okay, this any type, I really know it's an integer under the hood, so now I have to do ~some,~ some conversion ~on,~ on when I'm working with it. ~Right?~ Paul: It's almost like an escape hatch from the compiler. ~Uh, and,~ and you're ~kind of~ [00:25:00] accepting responsibility there, Johnny: Exactly. Yeah. You just saying, telling compiler, hey, like I'm gonna take responsibility for the type, the underlying top of this value. Don't do tap checking for me. Don't do compile time track check. Don't yell at me, please. ~You know,~ I'm taking responsibility. Paul: ~I think one of the strongest parallels to that in another language would be in type script. If you want to force its hand, you would convert it to unknown and then you could cast it to, to anything. It's kind of, you're like, listen, just this, this is what it is.~ And the third one you mentioned was using reflection, ~uh,~ which is ~kind of~ like an internal thing, which gets the metadata from the runtime, but not advised for the majority of Johnny: Not, no, not for your day-to-day. ~Like, I,~ I can definitely see the use for it and have seen the use for it. And when you're building like frameworks or ORMs or anything of that nature where you need to elaborate as really general purpose kind of thing. ~Um, you know, ~the things that I'm sure, ~you know,~ with the advent of generics, ~um, um,~ that's gonna be, ~you know,~ generics is probably gonna be more suited for a lot of those use cases. But there's still ~some,~ some places where, ~you know,~ reflection is the right approach, right? It's just not something that, ~you know, I,~ I, if I see that, ~you know,~ doing ~sort of ~a day-to-day, ~You know,~ line of business, ~you know,~ a developer opens a pr, ~you know,~ to do something very simple. And I see, ~uh,~ reflection in there. I'm probably gonna say, ~uh, can,~ can we not? Paul: Gotcha. Johnny: know, I know. It's cool. I know it's cool. I know it's clever, but, ~uh,~ yeah. Can we not, ~right? ~Like they just [00:26:00] do it the quote unquote long way. ~Right? ~Because listen, I'm an s ~it's, it's,~ it's, at the end of the day, if I get paged at three o'clock in the morning and I have to wake up and go on a computer and see what's going on, ~like,~ I don't want it to be because somebody was being clever, ~you know,~ with ~uh, uh, um, you know,~ reflection ~or,~ or even with that matter, right? ~I don't,~ I don't want it be because somebody was being, ~you know,~ clever and they didn't test for a particular edge case, right? ~Like,~ things like that. I'm like, ah, I'd rather it be the long, verbose way as opposed to the, ~you know, the,~ the clever way. Paul: So it seems like when the compiler takes a, what we're calling a generic and this new version of go, this new flavor that's coming out, ~um,~ it ~kind of~ does the first method that we talked about. Ultimately, it just ~kind of~ does it for us. Johnny: Yeah, exactly. Yeah. It just creates those world based for you, ~you know,~ go calls at the ~uh, um,~ instantiation, ~right?~ So it'll instantiate different versions of your function for you. And then under the hood, the right version is gonna get called BA based on type inference. Paul: ~Uh,~ so Johnny, being somebody who has worked with Go for so long, you've done things your way for so long, and the ways the Go [00:27:00] community has done for so long, what is your personal take on generics and. How people are gonna interact with it. That's a big smile. So I know there's more than just, this is a hundred percent good. Johnny: Yeah. ~Um.~ I guess my dirty little secret is that even though the generics has been the language for two major versions now, ~um,~ it's not a go-to for me. I'm not reaching for it. ~Um, It,~ it could be because the surface area, ~uh, where,~ where, see the kinds of things that I'm working on, ~um,~ hasn't, ~doesn't,~ doesn't create a surface area for that kind of stuff. ~Um, maybe,~ maybe not, ~but you know, I,~ I think it's just not, I'm not going outta my way to look for opportunities to use generics. ~Right? ~So it's one of those things ~where,~ where ~I don't,~ I don't design my systems around types. ~Right? I don't,~ I don't do type first development. ~Right?~ Like I'll introduce a new type or a new domain object. ~Right.~ I'll introduce something new. When I need it, right? Like I've done, I've been doing this long enough to know that, okay, any sort of, ~uh, uh, um,~ design system you try to have ahead of time to, to anticipate, ~right?~ A particular business need or something like that, ~right?~ You end up having to change those refactor those you end up, ~you know,~ like all that sort of a reusability or reusable code that [00:28:00] you're trying to write without an actual use case for where it is actually reused. ~Like~ all that stuff ends up getting thrown away ~or,~ or at war becomes technical debt ~in your,~ in your system. ~You know, like,~ because you don't know what you don't know yet, ~right?~ So to, to me, ~the un, unless,~ unless like I have a real use case ~for,~ for generics, I'm not gonna try and anticipate, ~right?~ And design types around, oh, let, ~if I,~ if I only use this, then I could make a, I could have a generic function where, you know, ~uh, uh,~ I could pass in different things like to process transaction. If I don't want transaction, could be. An ACH transfer versus a credit card, ~you know,~ debit or whatever. I can try and create some abstractions around these things. ~Like, like,~ I'm like, no, like me, ~I will, I will,~ I need to see something repeated, ~you know,~ at least twice, maybe even three times, ~right?~ I don't mind copying. A little bit of copying is better. Then a ~little bit,~ little bit of dependency, ~right?~ So rather than ~sort of~ creating some obstruction, cuz what usually end up a sense of having, or what do you do? Like you create some sort of library ~right?~ Or package that you intend to reuse in other places, you're gonna ~kind of~ sprinkle everywhere, ~right?~ So if you're doing that ahead of time, ~right,~ and the way you know, ~you,~ you're [00:29:00] facilitating that through the use of generics, ~you know,~ or some other mechanism, ~right? Just,~ just to anticipate ~right.~ The need ~for,~ for reusable code. Unless you've actually, unless you actually have a use case that ~where, ~where you get to actually reuse this code, ~right?~ Two or three times, ~right?~ Unless you actually have that use case. I call that premature optimization. So to me, generics falls in that category. If you're trying to create things ahead of time using generics because you think you're gonna need them. That's called premature optimization. ~Right,~ and in this case, you're trying to prema like prematurely optimize understanding of a, of your business or your problem domain and trying to think, okay, ~well~ this thing could probably do this thing. If I twist its arm this particular way, like all of that. If I see that in a new project, I'm gonna, I'm gonna raise eyebrows and if I see generics in that, I'm gonna raise eyebrows. Paul: you have to design for the right now Johnny: Yeah, exactly. And ~I mean,~ not to say you can't design a system, you don't, you shouldn't think, ~you know,~ in terms of, ~you know,~ architecture and all these things, it just means that ~you, you,~ you don't design yourself into a box. ~Be~ be before you know what that box shape is, ~you know,~ or how big the box is gonna be. ~Right.~ And more appropriately, right? ~Like, you don't,~ you don't say, ~well,~ I know we could. And eventually [00:30:00] we'll need to ~fit,~ fit a fridge in there, in this box, right? So I'm gonna build today, start starting. I'm gonna build the box with those dimensions in hand, when really the only thing you need is to put a toaster in there, right? Right now. So ~it,~ it is ~like, don't,~ don't design ahead of time, right? ~Or,~ or rather think about the system, how it will evolve. ~Right?~ Don't, but don't solve problems you don't have yet. Paul: Now, Johnny, I know you have a course it's called Go in three weeks, is that correct? ~Uh, is~ is generic something that you have roped into that course and what of. Of the teachings and speakings that we rambled on today, maybe about ~kind of like the,~ the bigger 10,000 foot view about generics and how we're using it. ~Um, do you have in your course, if so,~ Johnny: ~Yeah, so the, the, I,~ I do teach a course regularly now on, it's ~kind of,~ kind of part of O'Reilly, sort of a, ~um, um, Sort of~ always on, if you will.~ Uh, um,~ sort of trainings, ~you know,~ I teach it at least three or four times ~a~ a year. So ~if,~ if you are interested in learning, go, and I'm not saying that because I'm trying to entice your audience to, ~to,~ to sign up, although if they do, that's fine too. ~The,~ the in, in that training, ~I try to be ver,~ I try to give a fair. ~Sort of, um,~ evaluation [00:31:00] beyond teaching you, ~you know,~ that hey, this is an important part ~of,~ of the language recently added, ~you know,~ teaching people, okay, this is what it used to be. This is what preliminary studies look like. This is what post studies looks like, and these are the do's and don'ts. ~This,~ this is the, ~you know,~ this is when you should use it, kind of thing, ~right?~ I try to provide a grain of salt with that basically saying, ~Hey,~ hey. It's cool, ~right? It's a,~ it's a nice feature and there are some use cases where it allows you to write. Very elegant, ~very,~ very nice. ~You know,~ pieces of code,~ right?~ ~It's,~ it's great. But I've seen some, I've seen some pretty gnarly things done, ~uh, um, um,~ with generics, ~right?~ Because you can, because ~you know,~ types can be inferred, ~and,~ and you can have, ~you know, you can,~ you can definitely. Program your way into a corner, ~right? Um,~ so don't, again, same advice. ~Don't, don't program your code.~ Don't, desi don't solve solutions around types. Don't define the world before you start solving problems, solve problems. And then if you start noticing repetition, if you start noticing a lot of boil bait, right? The telltale sign that you could use generics is, I have the same function. That accepts different types of things, but the bodies [00:32:00] of those functions is virtually the exact same. That's a telltale sign that you can use generics, ~right?~ Because the only thing that's really different is the type, hence the whole, ~you know,~ polymorphic para, ~uh, um, um,~ parametric rather parametric polymorphism, ~right?~ You want to be able to support multiple types within this given function. And the only thing that's different, really everything works the same. The only thing that's different is a type then yes, perfect use case ~for,~ for generics, for that language feature. And honestly, Regardless of the new features, ~like~ added to a language, ~you know, gen,~ we've been talking about generics cuz ~it's a, it's a,~ it's a target rich environment, so to speak. ~Um,~ but ~any,~ any feature add to a language really, uh, I'd say ~don't,~ don't go a new factory, your entire world to use a new FE language feature. ~Like, you know,~ it's, ~that's,~ that's ~kind of~ foolish, ~right? If,~ if something solves a problem for you, great. ~Um,~ maybe we're, ~you know,~ if you're gonna sit down and refractor things while solving a business problem that comes up in the future, ~uh,~ if you wanna go back and, Hey, while I'm in here, why don't I also clean this up? Kind of thing. Great. ~Right?~ But ~don't,~ don't go refractor entire world. ~And, and,~ and you might introduce mo bugs ~than you,~ than you bargain for. Paul: And in general, if people, ~uh,~ were to look at the go [00:33:00] three weeks course, I mean go can be a daunting language when you're looking at it, ~uh, uh~ do you usually find that, ~you know,~ if you're getting all the way down to the point where you know how to break the rules, you know the rules, so you can break the rules, ~sort of~ like how they say in music to the point where you can use generics. ~Um,~ do you find people ~kind of~ get to that point at the end of the three weeks? Johnny: At the end of the three weeks, ~um,~ I usually get ~a couple, couple,~ two kinds of students ~I have and, and the, and~ over the years I've experienced ~that,~ that I can ~sort of~ distill it down to ~those,~ those are basically two kinds of students. You have the students that really we don't want to use go, ~um,~ they've done some tutorials on their own, they've watched some YouTube videos, write some articles, ~um, um, and,~ and they really want to use it. Maybe they use it on some type project and they're like, okay. I need to know what I don't know. I need to know what to look out for. I need to know what ~some, some,~ some gotchas are. Like, ~I,~ I need to ~sort of~ level up right in, in, in my goal journey, right? And they stumble ~on my,~ on my training. They're like, oh, great. I can do this over the course of three weeks. ~Um, um, you know,~ one, one once a week for three weeks, ~you know,~ three hours a pop, ~right?~ It's a nice, ~you know,~ sizable, digestible, not too short that you forget. ~You know,~ the moment you walk outta class, but not too long [00:34:00] that it, ~you know,~ it takes up your entire day. ~Right?~ So you do, ~you know,~ for three weeks ~and,~ and you walk out of there thinking, okay, great. Now I have, even though I, I didn't know I could use certain language features. Yay. Thanks Johnny, for showing me I can do these things even though I didn't know how to use concurrency. Yay.~ Like,~ you've showed me examples, practical examples of how to use things like you've showed me some gotcha. Some do's and don'ts. ~Right? ~Great. Like they feel comfortable, ~right. You know,~ knowing where sort of the glaring things are gonna come out at them, and day one, but also how to spot, ~right.~ And to me that's more important than the actual, ~you know,~ thing that I'm teaching. I'm teaching 'em how to identify problems, ~right?~ ~How to,~ how to ~sort of~ look for, and then ~sort of~ smell weirdness, ~right? Uh, um,~ again, the whole idioms, ~um,~ thing, especially the idioms are very strong. They carry weight within the Go community. Alright, there, there's a certain way you could write Go code that other Go Toves. Were gonna look at you say, ah, maybe ~don't,~ don't write it that way. Try to follow this pattern instead. ~Right? ~So those idioms I try to teach in a class. That way when those folks start doing, go for real. ~Right. Um,~ they start writing go like after the Go developers, ~right? And,~ and that [00:35:00] allows you to ~sort of~ get assimilated and start writing Go code. Like honestly, sometimes I look at Go Code that was written by a Go newbie and I couldn't tell the difference, ~you know,~ with the go that was written ~from a,~ from a veteran because they follow the idioms, ~right?~ And that's exactly what you want, ~right? You, you want,~ you want that sort of a, ~that~ that consistency across projects. You want that consistency across sort of ways of writing Go code, ~right?~ The other kind of students are those that. Are looking for reasons ~why,~ why ~they,~ they wanna stick to what they're already doing or ~they wanna,~ they wanna not choose go, ~right?~ So I've literally had people, ~you know, who,~ who follow up with me afterwards says, Hey, great class. The training was superb, but I still don't like go.~ Right. Like,~ because it, it doesn't offer me X, Y, and Z. ~Right.~ And it's usually because of some feature that they have in a language that ~they, they, they, they,~ they won't be able to ~sort of~ do the same thing and go. Or maybe sometimes it's the, ~you know,~ like the saddest ones, ~uh,~ are the ones who come and says, Hey, you know what? ~The,~ the I love Go, but I can't use it at work because my VP or ~you know,~ their engineering director doesn't wanna like it because of X, Y, and Z. I'm like, you should have 'em attend the training. Paul: Yeah, Johnny: can help. ~You know, like~ persuade them that this is a good thing. ~Right.~ So yeah, you have [00:36:00] those different kinds of students, ~but you know,~ by far the ones I enjoy the most are the ones that basically, ~you know,~ they need to level up. They just don't know what they don't know yet. And there's just so much content out there ~it's,~ it's hard to, ~you know,~ you just need something like that Is thought. Thought through enough that gives you all the bits and pieces that what to worry about, what not to worry about. ~Right.~ Like I think a lot of times people attend ~my ~my classes because they wanna know what to ignore. ~Right.~ More so than anything else. ~Right. And, and,~ and I approach it that way. I say, Hey, You need to go. There's a lot of stuff out there you don't know where to start, ~right?~ These are the things to where you worry about, listen, I've been doing go for ~many,~ many years now, and consistently these are the things that matter the most, ~right?~ So they just look for that advice, right? So ~if that's,~ if that's you and you want, ~you know,~ attend the class ~and,~ and ~sort of~ really unearth what matters most when in a world of go, definitely ~check out the,~ check out the class. Paul: Johnny, thanks for, ~uh,~ your time today coming on ~for, you know, we should definitely brand it like go time with Johnny. Uh, we'll keep having these every so often. Um, I know you're active on the interwebs and you post, so if people wanted to follow what you're doing, what you're thinking,~ where can people find you? Do you have a Twitter? Johnny: Yeah. ~Um,~ it's, ~uh,~ first national last name, so J A B O U R S I Q U O T, ~um, on,~ on Twitter. ~Um,~ and ~these days,~ these days, ~uh,~ Twitter's a little, ~kind of~ an odd place, ~um, you know,~ with everything going [00:37:00] on, but, ~um,~ I, I think I. There's ~like, uh,~ the master Dawns of the world ~and then,~ and then the blue skies of the world, you saying coming into the fore. ~Um,~ but yeah, Twitter's probably gonna be~ sort of~ a jump off point. ~Uh, uh,~ if you wanna follow me, ~you know,~ if you wanna check on my LinkedIn, all these other things, ~you know,~ Twitter's probably a good jump, jump off point. Paul: Awesome. ~Well,~ thanks again, Johnny. It was a pleasure. Johnny: Thank you.