WEBVTT

0:00:15.792 --> 0:00:22.829
<v A>Welcome everyone to another.

0:00:23.571 --> 0:01:40.240
<v B>Episode. Excited to have a guest here today who is going to help us revisit Python. I think Jason was saying it's been about a decade since the last time we had Python as the topic of an episode. I don't even remember what we were doing back then. It feels like a long time ago, but excited to have it. I have a love-hate relationship with Python. So I hear that there's going to be some work to sort of convince me to drop the hate part and just embrace the love part. But maybe some of that comes from years ago. But I do respect that Python has in some ways stood the test of time. It's really there. It's pervasive, and it's helped so many people get into programming. It's made so many advances. So I'm excited to talk about it. As I mentioned, we have here today Jason C. McDonald. He is the principal Python Engineering Consultant at Rural Sourcing and author of the book Dead Simple Python from No Starch Press. Welcome to the show, Jason. Hey, thank you. Thank you for having me. Well, we typically start off all these interviews. I know I want to dig into Python. I'm already ramped up. I'm excited. Even though it's a little early in the morning when we're recording this, but I'm ready to go. Let's talk a little bit about how you got into tech or programming. Do you remember your first computer or your first programming experience? What was it that kind of made it real for you?

0:01:40.679 --> 0:03:33.780
<v C>Oh, yes. Okay. Well, I have two first experiences. I would say my first first experience was when I was 14 and I wanted to do some coding to be able to build a game I was wanting to make. And so I fired up Python, tried learning it, hated it. Not just Python, programming as a whole. Hated it. Despised the whole activity. Was miserable with it. Gave up after two days and vowed to never touch it again. Fast forward several years. By this point, I am on the other side of a traumatic brain injury. Fell down a staircase my sophomore in high school. Hit my head on the banister and went from a 4.0 sophomore college level reading to failing pre-K material. Had to work my way back up. The way I explain my head injury is if you're familiar with the BBC sci-fi Doctor Who, I basically am the doctor in that it's still fundamentally me under here, but I have actually had three head injuries in my life. And each time it has fundamentally rewritten my personality, my skill set, my cognitive ability. It's still me. The core of who I am does not change, but it expresses itself very differently. And so I'm on my fourth. Basically, I'm in my fourth form. But after that 2008 head injury, I discovered, oh, I like coding. It made sense. It clicked for me. And started out with, well, at first I thought you had to have a degree to do it. So I kind of came in by the back door via VBScript. And then from there, I picked up Visual Basic .NET. And then from there, I discovered that that ecosystem was too constraining for what I wanted to do. And so I thought, huh, I remember this Python thing back from when I was 14 and I hated it then. But, you know, I like coding now. So let's try it again.

0:03:33.780 --> 0:03:36.740
<v A>So was VBScript your second head injury?

0:03:40.540 --> 0:03:59.976
<v C>No, no. The second head injury was that staircase when I was 16. But no, VBScript was... It was an interesting language. It was a good introduction to it. But I still, to this day, have no idea why you instantiate anything with Dim. I understand what it means. I understand the history. It still makes zero.

0:03:59.976 --> 0:04:05.600
<v B>Sense. For people, can you... It may be dating or something. But what is VBScript? What was it used for?

0:04:06.220 --> 0:04:46.264
<v C>So VBScript, Visual Basic Script, this was used in applications—still is, actually. In applications like Microsoft Word, Microsoft Excel, you can write macros, which are basically just actions that you can perform on top of Office. The context I was using it in was this game software that, because of the scammy nature of the business behind it, I'm not going to name, but it was this game building software and they used VBScript as a scripting language. And that was where I got my first taste of programming. So I learned VBScript, fell in love with the fact that I could call up a dialogue box that says, 'Hello World,' on the screen. I'm like, 'This is awesome.' And...

0:04:46.420 --> 0:04:47.620
<v A>Yeah, it's so true... went from there.

0:04:49.200 --> 0:04:56.120
<v A>Yeah, that's a big part of it is having that kind of REPL, where you do something and you see an action right off the bat.

0:04:56.700 --> 0:05:06.320
<v C>Right. And not even just an action, but like a full-blown dialogue box with a yes and a no button, and you click it and there's something different. I'm like, 'Oh my gosh, this is amazing. I feel so powerful.'

0:05:07.920 --> 0:05:14.749
<v C>I became deeply... I became addicted to dialogue boxes for about two years after that point. I loved them, so... Oh, wow. All.

0:05:14.749 --> 0:05:24.000
<v B>Right. So I think we foreshadowed it by the fact that you may or may not have eventually written a book, but you returned to Python after that. And how did that second experience go?

0:05:24.940 --> 0:06:34.973
<v C>The second experience was definitely a lot smoother. So, as I mentioned, I felt very constrained by the .NET ecosystem for what I wanted to do. So I picked up Python and immediately hit a wall. And I was going, 'How do you declare a data type in Python? This is weird. I'm used to declaring the type of my variable.' So I logged into the Python channel on the IRC network. That channel is still there. Just Jump Networks is now on the Libera Chat IRC network, if anyone's curious. And I'm still in there. Anyway, my first question ever in that room was, 'How do you declare a data type?' And one of the moderators/room regulars responded with, 'You're a data type.' And then proceeded to explain dynamic typing. For reasons I don't fully understand at that exact moment, it became my favorite language. Because part of it was the fact that it could figure out what it was doing. And part of it was just the kind of the snarky, somewhat irreverent Monty Python-esque attitude that it brought to coding that I just fell in love with. I mean, it's named—the language is named for Monty Python's Flying Circus. It was not named for the snake. Oh, I never

0:06:34.973 --> 0:06:36.320
<v A>knew that. Did you know that, Patrick?

0:06:36.679 --> 0:06:52.607
<v B>Yeah, I actually didn't know that. But only because I looked it up. Oh, that's awesome. There are a couple of references to Swallows as well in the documentation online and stuff. So it sort of perpetuates the Monty Python skits through some of the... I don't know how much anymore.

0:06:52.607 --> 0:07:12.460
<v C>But oh, it still does. Yeah. The Spam and Eggs are the foo and bar used for most of the examples. And then the Python Packaging Index was originally called Cheese Shop. So, you know, it runs throughout the release notes; always have a quote from Monty Python or something. So it's deeply ingrained in the language.

0:07:13.360 --> 0:07:30.846
<v B>For all those people who aren't familiar with Monty Python skits, they're just like, 'I don't get why you were justifying that.' It's really... But there are various skits throughout time or movie references. So you can look them up later. Some people don't get it. Some people do. I won't judge people. Okay, we'll keep going. Well, I've

0:07:30.846 --> 0:07:41.360
<v C>already... I have already... We're what, only a few minutes in here? We're only eight minutes in. I've already made several two different references to British television. So that should tell you a lot about me off the bat.

0:07:41.960 --> 0:08:20.960
<v B>That is true. We also did talk about Doctor Who. Yes. Oh, right. So that you're... Okay, so you started doing this. You fell in love with the language. You... I don't know. I consider that a pretty intense thing, like going on the IRC channel and admitting you don't know what you're doing, but I think that takes a certain bravery. A lot of people would just sort of continue to Google a few times or whatever. It wouldn't necessarily own it up and just go online and say, 'I don't know what I'm doing. Someone help me.' So you went there. You got some help, it sounds like. Some snark, but some help. And you were able to make progress. So did you end up actually building something at that time in Python? Or just kind of experiment with it?

0:08:21.560 --> 0:10:18.860
<v C>Yeah. You know, I was building something actually when I got into this in the first place. I was trying to build a game. And I was trying to just solve for the initial early problems of the game, like how do we do animation? How do we do all these things? And so I was... I had a prototype that I had built in .NET. And so it was a matter of now trying to replicate that in Python. And I didn't get as far as I wanted. But that was because at the time, the person who was doing the art for me at the time was using Adobe Flash. And you're really limited in terms of being able to do SVG. You know, play the... Not SVGs. Play those old Flash FLVs and what have you. And anything really. So that I eventually had to move... For that project, I had to move over to Adobe Flash itself. Only to discover later that they were discontinuing it out from underneath me after selling me the license. Thanks, Adobe. I still will not use their products as a result. But nonetheless, even though I had to switch that project to Flash, I was still building stuff in Python. So I started building just tools and applications, trying things out in it. Because I enjoyed being able to quickly create a working desktop application that did something that solved some sort of need that I had. And it's funny because as I gained more experience with other languages like C++ and what have you, I kept hearing people say, 'Oh, you don't use Python for building GUIs.' And I kind of look at them funny, like, 'What are you talking about? I do all the time. Because I built stuff in C++. I built desktop applications there too, or tried. It takes a lot longer. There's a lot more boilerplate. Python, when you know how to use it well—and that's the key. When you know how to use Python well, you can create very maintainable, very performant user experiences

0:10:18.860 --> 0:10:44.700
<v C>in a fraction of the time that you would in other languages. And a lot of that is simply because of the introspective features of the language. Python knows about itself. It knows about its types. It knows about what it is and what it's trying to do as you're working with it. And when you learn to use these patterns, then you don't have to tell the computer as much because it's able to understand itself as it moves forward. I'm kind of mis-explaining it.

0:10:45.340 --> 0:10:47.420
<v A>No, I think it makes sense. I think it's a great topic.

0:10:47.420 --> 0:11:09.380
<v B>Maybe we come back to this as far as introspection, reflection, and how various languages handle us. Maybe we'll put a pin in that one. I think that might be an interesting topic once we queue it up. But okay, so you're building your game. You're working all this stuff in Python. By that time, was this part of your job? Or had you related the programming into your job? Or was this still just a side hobby?

0:11:10.199 --> 0:13:06.800
<v C>At the time, I didn't even have a job because of my disability. I couldn't work because I would have entire days or weeks without warning in which I just could not function. So I would just basically focus my attention since I had other support. I didn't have to work at the time. I was focusing on my recovery. So every available moment that I had within the confines of a workday, I would be working on building this game or the tooling I needed to build it. And starting about 2013, I realized I knew enough about software engineering at that point to actually run an internship program, which I started—an open source internship. And actually have over a dozen graduates from that too. And most of them have gone on to be themselves senior engineers. And I enjoyed that, being able to also speak life into other people. So I gained all this experience with software engineering, with management, with mentoring, with business analysis, with all these different facets. I had to do everything: DevOps, IT. I was the everything for this organization—unpaid, but it let me focus all of my energy on it. And then once I got to a point where I could start working, by that point, I was pretty experienced as an engineer. But it's amazing. A lot of companies just really don't want to hire people with disabilities and they'll find every excuse they can to avoid it. Because they prefer someone with the... It's backdoor discrimination. It's like, 'Well, you didn't have an internship at Google. You don't have a bachelor's of science in computer science from this prestigious university. You don't have a background that looks like mine. Therefore, you can't possibly be a good engineer.' And they never stop and consider that the reason I don't is because my background is different. My needs are different.

0:13:07.660 --> 0:14:32.440
<v C>And my experience is just as valid as theirs. But it looks different. And most companies would not consider that. So I spent six years searching for work. And it was getting really discouraging. And then I was finally offered a job at Canonical. And my boss there, when I was going through the interview process, was actually fighting for me. He said, 'I want him not in spite of his disabilities. I want it because of them. Because it gives them a different perspective. We have a bunch of traditional engineers around here. But this guy's got a different background. That's going to give him a different perspective on problems than we have. And we need that.' It was the first time I had actually had someone validate that I had something unique to bring to the table. And that was, his name was Eric. And that was so important to me. So I started my professional journey as a Senior Software Engineer, which is funny because it means that all the tough stuff that most people are having to get used to when they move into that role was the easy stuff for me. But all the stuff that's easy for everyone else, I hadn't been there for. So I likened it to getting on an airplane from the top of the Empire State Building. You know, you get in, you sit down, you turn to the guy going, 'Hey, how did you buckle your seatbelt?' Because I wasn't here for that part.

0:14:33.820 --> 0:15:08.513
<v B>Oh, wow. But that's an awesome, encouraging story, though, like the persistence that must have taken. And, you know, I think that some of those things are right, that it's really tough for people out there who are trying to get into the industry. You have that persistence is unfortunately needed, but is needed. And so I would say, like, you know, that's a great story. And I hope listeners will be encouraged by that as well, that like, stick with it and keep doing it. And, you know, going after what you want, because seems like you were able to finally find that person who gave you that opportunity and the springboard. And so,

0:15:08.547 --> 0:15:21.860
<v A>Yeah, and you only need one job at the end of the day, at least at any given time. So definitely put yourself out there, interview at a bunch of places. And you only need one and then you're in the door.

0:15:22.400 --> 0:16:41.240
<v C>Yeah. And the two rules I set for myself when I was interviewing that I always went back to and I encourage other people to do this, too, is if because I was dealing with a lot of the negative feelings of rejection. So there's two things I would remind myself of. Number one is if you get the initial if you get that initial interview, you're qualified. End of story, because if you weren't qualified, they wouldn't have taken the time to talk to you. It's not a question of whether or not you're qualified. It's a question of whether or not you are bringing the exact skills that they need for that position, because it's a lock and key model. They're not just looking for someone with a pulse—or hopefully not just looking for somebody with a pulse. Most of the time they're looking for someone with a specific skill set. So if you get that first and especially if you get like the second or the third interview, if you get rejected after that, in most cases, they're not rejecting you. They're just saying, 'You're great. You're good enough to consider for this. But someone else has fits that a little bit better.' That's not personal. That's just luck of the draw. The second thing is if you really do slam into discrimination, and I did many times, then that company wasn't worth working for anyway. They don't deserve you. So when they turn you down, it's their loss, not yours. You wouldn't want to work there. Because if you're going to get them the interview, you're going to get it in spades in your day-to-day.

0:16:41.240 --> 0:16:58.340
<v A>That makes sense. I wanted to clap back to something you said earlier about starting with kind of game development and the BBScript and then early Python. So many people start their journey by building games. Patrick, did you start by building games? Like what was your first program?

0:16:59.600 --> 0:17:07.160
<v B>Probably. It wasn't my sole intent to build games. But yeah, I think it's one of the earliest things I did—little like question response games. Yeah, absolutely.

0:17:07.160 --> 0:17:21.480
<v A>Yeah, I mean, my first program was, after, you know, like printing your name over and over again, my first kind of real thing was I made this arm wrestling game where you had to hit the space bar so many times for a second to win an arm wrestling match.

0:17:23.057 --> 0:17:39.020
<v A>And my question to you, to Jason C is like, you know, why is it, why is games the impetus for so many folks to get into programming? And given that, what does that tell us about getting young people into programming?

0:17:39.780 --> 0:18:20.040
<v C>Well, there's a couple of things. One is, you know, having interns for over 10 years and in the context of game development, one thing is that a lot of people get into programming, getting game development specifically because they view it mistakenly as an extension of playing the game, which is a totally different thing. Playing a game and building a game are not even remotely the same thing. And that's a splash of cold water to a lot of people. Like, 'Oh, wow, this is not as much fun as I thought it would be.' I actually wound up talking to one guy who was involved in building Duke Nukem. And he said, 'Yeah, I actually have never played the game.'

0:18:20.260 --> 0:18:22.820
<v A>Like the original 2D or the modern ones?

0:18:23.120 --> 0:20:01.620
<v C>I believe, if I'm remembering correctly, it was the original 2D. Wow, cool. And he said, 'You know, I never—he wrote the physics for it. He said, I never played the game. I never even saw the game. I wrote the physics for it. And I have never even, I don't even know what the game looks like. I never even bothered to look it up. I never played the game.' And it's like, so it's game development is itself, you know, we want to build the game that we want to play. And so that's sometimes the impetus of this—game doesn't exist. So I'm going to build it for myself. And that's a great way to get started. But it's important to remember that playing and building are two different things. I think the other reason that game development comes up a lot is because it's a good thing for us to put forward as an intro because game development touches every single facet of software engineering, or at least potentially touches every single facet. Anything that anybody is ever going to write in any code base anywhere has an application in some game. So when you're building a game, depending on the nature of the game, when you're building a game, you never know what you're going to need: pathfinding, search algorithms come up frequently, or sorting algorithms. Those matter—data, data entry, data retrieval. You have save files, you know, how do you render graphics? How do you do sound? How do you do network connections? How do you do all the way into AI and Machine Learning? You know, it's all of this could intersect with a game. So games become a very good way of practicing different skills because you need very little excuse to pick up something that you would otherwise have to come up with some really complex and unreachable business need for.

0:20:02.500 --> 0:21:54.240
<v A>Yeah. I feel like it's one of the interesting things about games; it's like—I equate it to, and I love games. So I'm going to say this as somebody who absolutely loves video games, but it can be kind of an endorphin shortcut or like a serotonin shortcut, kind of like eating a jelly donut. You know, it's like you get this really intense satisfaction of like beating a level of Pac-Man, even though you didn't practically do anything. And again, I love games, love that feeling. But I think a lot of people think that they can create, they can create that feeling again if they make a game and to your points, like they could do it even better. But what I've found in the few games that I've made is that when you program the game and know what you're doing—like under the hood, all the mechanics, the AI behind the Goombas and the turtles and all of that—you don't get that same endorphin rush when you beat the level. There's just, there's something about the fact that you knew what everything was going to do. Some people will claim you could make something so emergent that even you get an endorphin rush when you beat your own game. I'm not saying that's impossible, but I think as a first-time game designer, it's almost impossible. And so, that's what—that's a trap that a lot of people fall into is they make the game and they think they're making it for themselves, but it's never actually going to be satisfying for you to solve your own puzzle. You're not going to get that same rush. And so you really have to build it for other people. But it is interesting that it's ubiquitous. I mean, every almost maybe 80, 90% of the people I talked to got into programming from wanting to make a game. And I just think there's something really fascinating about that.

0:21:54.740 --> 0:23:36.820
<v C>Yeah, absolutely. And, you know, I will put a caveat: there are some occasions where building your own game can give you that. I mean, Marcus Person left Minecraft; you know, he built the game he wanted and he enjoyed it. And you know, I've built a couple of games where I genuinely enjoyed playing them when I was done. But I guess the thing is is that in both cases, you're not just building to scratch a personal itch, but also to build something that you think other people are going to enjoy. So that—oh, it's the same thing with writing. Because I'm also an author, obviously, as you mentioned, but I also write fiction, and yes, I write books for me, but I don't write books just for me. I'm writing a story that I think is going to mean something to someone else. And I was talking with someone recently, and I said, you know, it's writing the book for yourself is how you get started. Writing the book for someone else is how you finish. Because if you're not writing it for someone else, you're not going to have the impetus or the motivation to stick with it through the editing and the revision and the, you know, on and on and on the treadmill of actually finishing the book. The passion for creating a story that's going to mean something to someone else is what's going to get you over that line. And I think the same can be true of software in general. I mean, if you look at the people who are happiest in our industry, there are the people who are building something they genuinely believe in. If you don't believe in what you're building, it can be really hard to generate that passion because it's like, well, I'm doing this for a paycheck, but I'm really just doing this for someone else's bottom line. But when you focus it in line of, maybe this is why user stories help: you focus it in lines of 'I'm solving this so that this person can do this thing.' Then it becomes important. Then it becomes valuable. And that creates that motivation to keep going.

0:23:38.200 --> 0:24:25.725
<v B>I think this is like a great conversation and not to dwell here so we can keep going on, but I'll say, I think not to say that you're wrong, but I'll slightly disagree. So I've had that argument. And I think what you're saying is a very common approach where for a lot of people it is absolutely true to be able to—I want to say ship something. If I phrase it in another way, people say it and actually see the thing come out, actually understand why you're doing it. I find, for like, as just a personal self, that that isn't the only thing or even a very important thing for me. I've at times worked on stuff I actually thought was dumb or would never work or wasn't that useful. But the specific problem that I was there to solve and the people there to solve it, I saw that there was growth to be had. I saw that there was something I could learn. There was some way I could kick the ball for it. And often

0:24:27.244 --> 0:26:03.480
<v B>taking those things and leveraging them into the next thing. Right. And so those things aren't of infinite, you know, like a lifespan; you kind of got to go in with a mission and learn something. But I'll say, I think what you were to—I guess back up my point since I'm making a contrary point is like to back up what you're saying about, you know, finishing off a book or finishing off a game. Oftentimes that first 80% is really appealing. And the last 20% of the game's completion takes as long or longer and is really hard and it's drudgery. And you need a certain motivation to get through it. But I don't want to like discourage people that if you get through that 80% and then you don't finish, you got to be careful doing that only or always, or if you're in a startup, but just as like a learning experience, you can learn a lot from that first 80%. You can learn a lot more or the same from the last 20%, but there is value to be had there. And so going through unfinished game after unfinished game is also something you see happen from a lot of people who end up releasing independent titles that sort of—that, you know, four or five failed things that they made sure to learn something from it. And so I'll say that yes, but like just a caution out there: I think there are different flavors of folks. And when I interviewed people for my work talking about, 'Hey, is it a motivating driving factor for you to ship something? Or are you okay going through a number of like failed attempts at stuff and potentially never shipping?' Will that motivate or demotivate you? And it's an introspective question. I think a lot of people have to answer and aren't very thoughtful about. Most people haven't sat down and thought, 'Do I need to ship, or am I okay?'

0:26:04.529 --> 0:27:05.340
<v C>And to clarify what I'm saying, I'm saying that the motivation needed to ship is extrinsic. That's what I'm specifically referring to. Not that the motivation to do it is extrinsic, but the motivation to ship it. That 80%, to your point, that 80% can be intrinsic. But it's very difficult to get the intrinsic motivation all the way through. That extrinsic motivation has to kick in to get you over the hump in most cases. So you need a mixture of both. If it's all extrinsic, you won't get started. If it's all intrinsic, you won't finish. And that's okay. If, to your point, it's okay if you don't finish it. I've got a million unfinished projects that I will never finish. So learning from things is great, but it really is that extrinsic motivation that drives you like, 'Okay, you know what? This is now really tough, but I want to get this in someone else's hands.' And that's what gets it over the line.

0:27:06.080 --> 0:28:09.480
<v A>Yep. So one thing I was thinking about related to the motivation question is, and Patrick, you might be a little different on this, but on my side, I've used a zillion different languages, and I haven't felt particularly attached to any of them. And I don't really see—you know, I just kind of feel like, well, for this particular context, you know, for example, I'm on a microprocessor, and so it's just a lot easier to use C or, or, you know, I'm building in Unity, and so it's just a lot easier to use C#. Right? And so I'll just use whatever. But in your case, you know, you have spent a ton of time and energy on Python, you know, reading through, as you said, in the pre-show, you know, the documentation many, many times over. And so my question is, you know, what—you know, like, in the context of all these different languages and everything, what kept drawing you to Python and what caused you to dive so deeply into Python? What really is the impetus for that?

0:28:09.480 --> 0:28:44.790
<v C>Ironically, extrinsic motivation. I logged into that Python IRC room and I never left. And I became a regular in the room. I say never left in the—you know, sure. I log out at bedtime; you know, there were a couple of times I wasn't online at all, but like in general, this has been the core of if I'm involved in the Python community or any programming community, that's it. That's where you're going to find me. It's going to be on IRC. And I kept

0:28:46.748 --> 0:30:43.860
<v C>seeing the same questions showing up again and again and again. And I just began thinking, it's like we keep answering the same questions. Again, I train interns. It's like if I get the same question three times, I need to write it down somewhere because it's worth documenting at that point. If only to save myself the work of having to repeat the entire answer all over again. So I began writing a series of articles that was just attempting to document some of this tougher-to-understand stuff in Python. And the number one problem I saw with people coming into Python was they were bringing with it the assumptions from their language of origin. And this is, I would say, why most people get frustrated with Python is they're not writing Python for Python, like someone who starts in the language fresh would. They're writing Python as C++ or as Java or as Ruby or as JavaScript or whatever. And it becomes a very frustrating exercise to write Python code when you're trying to apply the patterns and the thought processes of another language because Python is very different in how it solves problems. And those differences are the reason why it is so easy to build a complete solution in a short span of time. But those advantages become stumbling blocks when you don't know they're there or you don't fully understand them. So what I began doing is explaining these core concepts. And I just thought, you know, it's just some post up on Dev.to, big deal. Until I got a message in chat one day and someone said, 'Did you look at the Android newsfeed?' I'm like, 'I never look at the newsfeed.' I don't know why. He said, 'You're on it.' Like, wait, what? My article series had gone viral for just a flash in a pan moment of about two days. It was—it was trending. I'm like,

0:30:43.860 --> 0:30:50.965
<v A>Wait, how did that—wait, let's dive into that. So, where was this hosted? And how did that virality happen? Do you have

0:30:50.965 --> 0:32:50.020
<v C>any? I have no clue. So this was on Dev.to. And I had a number of followers on there just from—that was where I was doing all my tech writing. And I would just write things down, and my somewhat snarky and I guess almost irreverent way of approaching certain things in coding just caught people's attention. They enjoyed it. They enjoyed it. So for some reason or another, for reasons I don't fully understand, those articles took off. And I—I wish I could crack the code and say why, but most virality online is just chance. Yeah. Anyway, but I realized this is there's something here. So at the time I was talking with a publisher that was wanting me to do this video course on C++, and I wanted to like turn it down. But around that time I started thinking like, 'Okay, I'm now being approached by publishers. I wonder if No Starch would take this.' And so I pitched the article series to them and said, 'I think I can turn this into a book.' And Bill Pollack took one look at it. He said, 'I think you're right.' And within a week I had a book contract for *Dead Simple Python*. So I just began starting out like, 'I'm just going to translate these articles,' but see, here's the trick. Like I started out just defining the things that I kept seeing and explaining, but it was more scattershot. It's like, 'Hey, this, this, this, this.' But I'm a very systematic individual. When I start writing the book, I'm like, 'All right, let's start from first concepts and go through,' but I don't want to drag into one for that same thing. This is a variable, boys and girls. You're coming from another language. You don't want that basic explanation again.' So it was, 'Let's start from first concepts without beating over the head with programming one-one again.' And which turns out no one else has done, at least not for Python. And I started—so I start going through it. And as I get about two thirds of the way through the book, I realize I don't understand half of this stuff.

0:32:51.460 --> 0:33:40.356
<v C>And I'm going, 'This is weird.' So I go to the documentation and I start digging into the inner workings of the language. And by time I—so I went from being a mediocre Python programmer at the beginning of it, just trying to document some basic things. By time I was at the end of it, I was a literal expert in the language. And my technical editors were four of the top guys in the Python room who are like answering everyone's questions. These are like super smart guys, experts in the language, really, really practice. And they're going through and they're going, 'Yep, you got it.' I'm like, 'I've actually done it. I've actually mastered Python in the process of writing a book.' If you want to learn something inside out, write a book. If you also don't want to do anything for four years of your life, write a book. You know,

0:33:40.542 --> 0:34:30.660
<v A>I love this dichotomy because—because I and Patrick, Patrick, I think, and I are a little bit similar in line on this. Both of us are not particularly social with respect to like developer communities and all of that. I mean, we have the podcast, love the podcast, love the listeners. We try and provide as much content as we can, but I'm not like, I've never really been into—to like, I've been on IRC like two or three times because people asked me to go on, and I just couldn't stick with it. And so I think there's—there's two, there's two kind of different ways to both achieve our goals. You know, in my case at least, you know, it's more like, you would set kind of a goal for myself. I would try my best to hack my way through it. And then what I would find—I mean, example, I keep going back to

0:34:32.550 --> 0:36:32.262
<v A>is—I didn't know Python. I hadn't even heard of Python, but I wanted to make a board game engine. So I wanted to make an engine upon which I would make new board games that I'd conceptualized, but, you know, I was having a hard time. You know, the incremental cost of coding up these board games in C or C++ is getting really expensive. So, so I thought I'll make this board game engine, but because it's an engine and people can do whatever—whatever they can create their own units and types and dice and everything—it needed to be very open-ended. So I thought, oh, I'll just have a variant, which is the C++ object that could be anything. It could be an int or a double or a string; could be anything. And then I'll just have one class, which is a map of variants to variants. And so this is super open-ended. It could kind of do anything. And after months of this—I mean, it was part-time, I still had my day job—but after months of this, I did a little bit of background reading. I realized I'd invented like the most janky version of Python ever. And so what I should have done is just used Python. And so I think that's something where you can kind of go too extreme on just trying to do things yourself based off your own first principles. You know, now on the other side of it, you want to also kind of, as Patrick was saying, take—take pride and take accomplishment and take solace if you need to in your own achievements personally, regardless of what the world outside is doing. So there's this place of good balance where, in your case, Jason, you saw this need, you addressed the need, you kind of iterated on that, and you were kind of constantly in communication with your audience. And that built up to writing this book. And I think it's just a phenomenal story. And I think the

0:36:32.650 --> 0:36:49.819
<v A>Bookmark exclamation on this and land the plane. I think there's different ways of kind of achieving what you want. And as long as you work hard, persevere, and continue to iterate, you'll eventually be able to learn any language or pursue any of these goals that you have out there.

0:36:50.080 --> 0:37:01.460
<v C>Yeah. I would agree. And I often like to say, there are two phrases I hate. Actually, there are three phrases I hate in programming.

0:37:03.080 --> 0:38:48.800
<v C>I hate the term 'best practices' because there's no such thing. There are good practices, but there's no objective best because no two projects are exactly the same, and 'best practice' here doesn't apply over there. So 'best practices' is very kind of it has a connotation of sort of arrogance about it. It was like, well, you know, I know the best way to do this. It's like, no, you know, the best way to do that in this project. So I don't like the term 'best practice'; I like good practices because it should be a dialogue. There should always be dialogue about it. Why do we do it this way? The second term I hate is YAGNI: You aren't going to need it. True. You don't want to add, you don't want to pile things on early on, but you want to think about where do you want to go with this thing and not code yourself into a corner? Like, like you were mentioning with the different types you recognize early on that you were going to, regardless of the direction you went in, you recognized early on that you were going to, you wanted to have that flexibility. And so you start making those decisions around that flexibility. You're not necessarily implementing all the flexibility right off the bat, but you're not making any decisions that are going to block you. And the third thing I hate is 'don't reinvent the wheel' because we reinvent the wheel all the time. We reinvent the wheel every day. How many variations of the wheel, the literal physical wheel, do we actually have in the world? And sometimes you can learn some of the best things from building something that already exists, building it again yourself. You can learn a ton from that process, even if you don't use it. And sometimes you build it and you go, 'Oh, I'm actually sitting on something that's right brilliant.' And if you fall in one of the kind of the 90% of situations where it's not, hey, you now understand that thing pretty well.

0:38:49.371 --> 0:40:09.879
<v B>Yeah, definitely. So I'll segue from Jason's map of variant to variant and to the conversation I put a pin in earlier. I'll pop the back up here, which is we talked about the—you were mentioning introspection. I said the word 'reflectivity.' Yeah. But you mentioned this about one of the things that captured sort of your attention in Python. We've also loosely tangentially referenced sort of dynamic typing and sort of like you were asking, 'How do you define a data structure?' So we're sort of bouncing around some set of topics here that I'm going to try to squish together arbitrarily. And let us talk about here, which is you were mentioning one of the things people do in Python that holds them up from loving Python is not doing Python Python, but doing something else in Python. And there are some languages, I guess, that pride themselves on being able to do whatever in that style. But you made this contention—I don't know, but I'll say maybe this is one of them—this sort of assuming that everything should be super strongly statically typed up front, you know, everything is compile-time known, all of this. Maybe that's part of why. If not, then, oh well, you can tell me I'm wrong, and then we can talk about it anyways. But I'll tee that up. But where are your thoughts, I guess, in that space?

0:40:10.259 --> 0:42:08.980
<v C>Yeah. Well, I want to briefly say that every language has its thing—capital T thing. We'll put a little T in one of the little trademarks and blah, blah, blah. Every language has its thing. And once you understand what the thing is, then you can get a pretty good handle on the language just to kind of frame this. C#'s thing is inversion of control. C++'s thing is memory management. Rust's thing is borrowing. Ruby's thing is lack of parentheses. I'm serious. That's what they hung everything on. And it's like, if you had to write a list of every feature of the language, which thing are they going to put at the absolute top of the list and say, 'This is first and foremost; this is what we're not compromising on.' Every language has that one thing about it. And Python's thing is introspection. That is that at any time you can look under the hood, you can look inside of something and you can see it working. You can see what's there and you can then maybe rewire it too. And this is one of the reasons why Python is so cool, because you can write a class that tightly integrates with every feature of the data model, every feature of the language. And it acts as a native type. You can make it so tightly coupled that the usage is just completely obvious. And that's one of the neat things about it. But the way it's able to do that is because it's exposing all of these what are called Dunder methods, double underscore methods that are how Python makes that object work with different parts of the language operators and what have you. And it's not just your data types; it's not just your classes that do this. It's all the classes that do this to some degree or another. I'll put an asterisk there because there's some really deep internals and integers that get interesting, but I'm not going there. But you have this ability to kind of dive down into the internals of anything.

0:42:10.116 --> 0:44:08.819
<v C>And this is Python's thing—that introspective; you can see, you can examine, and you can change anything. And that is oftentimes surprising for people who are used to data hiding. So if you're coming from C++, you're coming from Java, you're used to hiding your internals, locking everything away. You've got the gate with the dog and the guard. And then you've got these nice little getters and setters or what have you, and you're carefully controlling everything that comes in and everything that goes out. So in Python, you'll still write getters and setters and what have you, but you're not actually stopping anyone from examining the internals, which by the way, makes testing a lot easier. But rewinding a little bit to just touching on that whole dynamic typing thing, Python's way of working with variables is very different from other languages. So Python has—people fling around the phrase 'Python doesn't have variables,' which is not exactly true. But variables are not one thing in Python. It's two things that work together. You have a name and you have a value. So a name has, the name itself has a scope, but it has no type. It's a loosely bound language. So you create a name and it's scoped to wherever you define inside your function, inside your class, whatever. Actually, 'class' isn't a scope; inside your module. But you have, you have a name and it's scoped somewhere. Then you have a value, and that value sits in memory, and that value does not have a scope. You can access that value from anywhere, theoretically, but it has to be bound to a name. So you create a binding when you're doing an assignment in Python; you're creating a binding between this value and memory and this name. And where this becomes important, by the way, that value—that does have a type, and it does have a strict type.

0:44:08.920 --> 0:45:00.180
<v C>You can't change the type of the value. If it's a string, it's a string. This is not JavaScript. You can't compare a string and a number and get a value. It's just going to go, 'What are you doing? Why are you doing this to me? You're being irrational.' JavaScript will just let you. So a value has a type, but it has no scope. A name has a scope, but no type. And where this becomes really helpful is that anytime you do any form of assignment or any sort of passing, like even passing to a parameter and a function, what you're really doing is you're binding that name to the same value in memory that the other name pointed to. So if I say foo equals five, I'm creating a value five in memory. I'm drawing a line from that to the word 'foo.' And then I say bar equals foo. I'm not drawing a line between foo and bar. I am drawing a line between bar and the same value in memory that foo pointed to.

0:45:02.520 --> 0:45:09.852
<v C>Then you have to understand that with the exception of strings, integers, and booleans and floats, outside of those,

0:45:11.370 --> 0:47:01.440
<v C>and tuples, everything else is mutable. It can be changed, which means if you've bound two names to the same list in memory or the same dictionary, which would be a hash map for those of you coming from Java. If you bind two names to the same value, then it doesn't matter which name you use to change that value. When you change that value, the mutated or changed value is visible from both names. This is surprising to people at first because you expect to pass in a list and you modify the list. And wait, what happened? The original list got changed. Yes, because you're just rebinding. That's all you're doing. And then you're changing the list. But this is why Python is used so often for data science is because you can pass in something like a NumPy array—this huge, just ungodly half a gig of data array. And it doesn't matter how many times you pass it around; you have one copy in memory. And as long as you get used to that sort of thought process that I'm not making a copy when I'm doing assignment, I am rebinding. I'm creating an alias to this thing. Once you get that into your system as how this works, then it becomes a lot easier to write code where it's got a smaller memory footprint. You're not making extra copies of things because things are just—it's the same thing being passed around. And it becomes a lot easier to write long chains of functions that are processing something than in a language that would be like C++, where it's, you know, you got to think about 'Am I passing my reference? Am I passing my value? Am I passing my pointer?' And you have to think about all the semantics. You don't have to think about the semantics in Python once you're used to that idea of rebinding.

0:47:02.080 --> 0:48:27.820
<v A>Yeah. One of the things that I think, the introspection really teaches people, whether they're going to stick with Python or just use it and move on to another language is, the ability to have a deep connection between data and code. So imagine you're reading a YAML file or an XML file or JSON file or something into your program. You know, you can in Python because it's dynamically typed, because of all the introspection, you can read in a YAML file that has a name category and the name category has a first name category. And that first name category is Bob. And then when you read that file in and in Python, you can just say, 'Print my file dot names dot first name,' you'll get Bob. And so it's because Python is just creating that structure automatically. And it's not something statically typed like C++, where you have to predefine what you expect this JSON file is going to do. And so if you do something like read JSON in C++, it tends to get kind of ugly where it's going to read everything into dictionaries where you can't say, 'What is the type of this object?' Because because you're past that point, C++ can't easily do kind of runtime type inference stuff. Right?

0:48:27.960 --> 0:48:29.960
<v C>It becomes very complicated. Yeah.

0:48:29.960 --> 0:49:11.620
<v A>You know, this idea of like, I have my data, I have my code is kind of driven by my data. The way you realize that stuff in C++ is through things like Protocol Buffers, where you run this command and it generates a zillion lines of C++ that have a whole bunch of types in there. But I think seeing Python shows you kind of if you're willing to make sacrifices in other areas, like this is just such a beautiful way for working with data and code together. And I think that's one of the reasons I think why data scientists tend to really jump on another reason why they tend to jump on Python.

0:49:12.420 --> 0:50:06.580
<v C>Yeah. It's a very data-first language. And again, it still cares about those types. I think this is part of what makes it work. It's not saying that the type isn't important, but it's changing the focus from what is the particular framing of that data. Like C++ cares about not just does it have this structure, but is it actually an instance of this exact class that I've written? Whereas in Python, you have instead what's referred to as duck typing. If it looks like a duck and quacks like a duck, it's a duck. And Python doesn't really care whether it's a duck or a moose in a duck suit. If it can fit the basic criteria, then that is if it can fit the assumptions that you're making about the nature of the data, then you can work with it as if it is that data.

0:50:08.180 --> 0:51:24.200
<v C>And so you start seeing like there is inheritance in Python. There is, believe it or not, you can even do like, one of the things people ask when they come into Python is can I do an overloaded, you know, can I do an overloaded function that handles, you know, and the easy answer is no. And the true answer is yes, you actually can. There is a way to do overload. They're called single dispatch functions in Python, and you can do them. And I talk about them in the book. But it's not based on it is this class. It's based on it can do these things. And so you start being able to write your type checking type logic, not around being an instance of a thing, but having certain criteria. And there's these cool things called Abstract Base Classes where you can describe what you're expecting out of the data instead. It needs to be iterable or it needs to be numeric or whatever. You know, there's all these different Abstract Base Classes, and those are based on certain behavior being implemented on the type, not on the type itself. And so that's one of the reasons why it can be very quick to write some very complex code because you can work with that on the basis of what it does, not what it is.

0:51:24.940 --> 0:52:47.260
<v A>Yeah, that makes a bunch of sense. I wanted to pivot a little bit here. You know, one thing that is sort of like a staple of Python or is relatively famous or infamous of Python is the GIL, right? GIL is a Global Interpreter Lock. And so the idea here and, you know, actually JavaScript has the same thing. I don't know why Python gets so beat up for this. But, you know, the idea with the GIL is if you say I'll just kind of tee it up. If you say, you know, X equals two in Python, Python will, you know, before the way it will process that instruction, is it will claim a mutex. That's a global mutex across your entire Python program. It'll lock that. It'll say nobody else can run any instructions right now. It'll do the X equals two assignment and then it'll release that lock. And so now if you have another thread in the same process, it's executing Python. Now that other thread has the opportunity to do something. But but at any given time for a for a process, you know, only one instruction kit can get executed other than there are some exceptions, which we should definitely talk about. But, you know, what's your take on on that whole paradigm? And, you know, I heard that there's talk of them getting rid of it. And what's going on there?

0:52:48.240 --> 0:53:39.540
<v C>Well, so the GIL definitely gets a bad rap unfairly. So I need to I need to touch on the history of the attempts to remove it. There have been multiple attempts. Now, as of right now, it is now possible to compile Python without the GIL. They do have that, but you have to compile it yourself. There's some caveats to it. I'm not going to go into, but there have been other attempts to remove the GIL. And the funny thing is, is that it always has a negative impact on performance. But even that aside, the GIL actually does contribute some sanity because I'm going to back way up to first concepts here. Concurrency and parallelism are terms that we use interchangeably. And we should not be using them interchangeably because they're not even remotely the same thing. Concurrency means that while I'm waiting on one thing, I do something else.

0:53:41.780 --> 0:54:07.995
<v C>Parallelism means I'm doing two things at once. Now, the reason we tend to confuse these two things are because in many languages that are not, that don't have something similar to the GIL, threading is a way to achieve parallelism because those threads could split off into multiple CPUs. They're not guaranteed to split off onto separate CPUs, but they might. So the way

0:54:10.324 --> 0:55:10.660
<v C>threading tends to work in many languages then kind of bleeds those two concepts together. But you're actually doing two different things. So concurrency is needed in the context of I/O blocking. And this is where I am waiting on an input from the user. And so while I'm waiting on that user input or that network connection or whatever, I am I/O blocked. I can't do anything about that. I'm just waiting for someone else to say, hi, I'm here now. While I'm waiting, I'm going to be doing something. I'm going to be running some heavy calculations or whatever. What this is doing is it's improving the perceived responsiveness of your program. Your code's not actually faster. But what's happening is that because you're doing something while you're waiting, it appears to be faster because while that user was typing, some of those calculations were going on in the background. And this is crucial when you're doing UX design. Is because you're spending a lot of time waiting on the user to click on something. So you can do other stuff in the background. Meanwhile, that's concurrency.

0:55:12.560 --> 0:56:26.200
<v C>Parallelism is where you're trying to actually speed up some sort of super heavy thing like, say, a very complex mathematical calculation by having multiple CPUs work on it at a time. One CPU can only do one thing at a time. And it's going to actually put one thing on hold to run a separate instruction. And it'll typically be keeping multiple balls in the air at a time. It just switches so fast that we never notice that it's just like the human brain. We don't actually multitask. We just context switch rapidly. That's all we're actually doing. CPU is doing the same thing. But when you have multiple CPU cores in a machine, then you can do multiple things at once. Because CPU 1 is doing one thing. CPU 2 is doing a different thing. That's parallelism because you actually have two CPUs working for you at the same time. And that is useful for CPU block things where the thing that's holding you back is how long it's taking to actually do the math or what have you. So Python has tools for both of these things. Even with the GIL in place, you have asynchrony, which is a Python-controlled form of concurrency. And you have traditional threading, which is an operating system-controlled form of concurrency. And it has both of these tools to handle the I/O blocking.

0:56:27.704 --> 0:56:36.715
<v C>Similarly, it has a module which gets a lot of unfairly bad rap called multiprocessing that allows you to spin up multiple Python processes to be able to handle different things you want

0:56:40.140 --> 0:58:38.220
<v C>to do at the same time. Now, that's actually a good thing. Because multiprocessing has, in any language, a significant amount of overhead. When you add more threads, more processes, what you're actually doing is you are increasing the load on the machine to actually manage this. So the overhead of managing multiple threads and processes has a cost itself on performance. And when you get into it, this is not something you just throw a code and make it faster. You have to actually weigh the cost of managing those multiple threads or those multiple processes against the benefits to your code. And that requires a fair bit of experimentation. So because Python separates these two things out, then you can use the lighter things, asynchrony or threads, for I/O blocking. And then when you actually encounter a situation where parallelism is probably going to speed up your code, then you can pull that off the shelf and bring it in in a deliberate fashion, using only just as many processes or workers as necessary to actually speed up your code. Funny thing is, you would think more workers faster. But in most cases, two or three workers is all you're ever going to need. Bringing in 10, 20 workers is actually going to slow you way, way down. So there's all these things. And so the GIL, I find, is beneficial because it forces you to do this thinking up front. And you have to start thinking about how do I share data between these things? How do I get messages back and forth? And that gets into all sorts of snarly issues that you have in every language, like locking and deadlocking and live locking and the consumer producer problem. And you are forced by Python's GIL to solve these problems deliberately up front in your design. So when you actually implement it, you have less surprises. Not no surprises, less surprises.

0:58:39.345 --> 0:58:49.279
<v C>So that's kind of, that's my view on the GIL. And it is possible now to get rid of it, but I don't really see any need to in those cases.

0:58:49.280 --> 0:59:06.800
<v A>So, but if you get rid of it, then, then how do they handle all those things that you just mentioned? You know, what if, what if two different threads say one says X equals two and the other says X equals three, you know, without a GIL, how do, how do, how do they deal with that?

0:59:07.380 --> 0:59:29.660
<v C>And I would have to say, I don't know that there is a reason why it has taken them a decade to figure out how to get it out of Python. But we know that Rossum is directly involved in it and it's very experimental right now. So the stability and sustainability of it are completely, all I know is they just, we don't just announce that they figured out how to get rid of it. But.

0:59:31.020 --> 1:00:03.906
<v A>I think, you know, to your point, like there's, there's something really, there's a fundamental problem here, which is you fundamentally can't do two things at the same time to the same object and have a deterministic program. And so, and so it's like, it's like, it's like almost like a PR thing. It's like, it's like we got rid of the GIL because it's such bad PR, but like, you know, we can't, we, we're not going to like reverse gravity or anything here. So there, there's still like a lock at some point. Yeah. Yeah.

1:00:04.120 --> 1:00:49.519
<v C>And it's still on by default. Like if you download Python 3.11 right now or Python 3.12 beta and you compile it, it's going to have the GIL. You have to actually pass a specific flag. And the idea is it's one of my technical editors had a saying, if you know why you're not supposed to stick a fork in a toaster, then you're qualified to stick a fork in a toaster. Yeah. And I, my, my best guess is it's something along those lines. If you know why you should be getting rid of the GIL, then you're qualified to compile Python without the GIL. And you're going to be prepared to handle all of the consequences of trying to actually do the compilation. If compiling Python in the first place is a scary thought to you, you probably shouldn't be trimming off the GIL because you get your problems. It's a good point.

1:00:50.080 --> 1:01:16.975
<v A>You know, I think a good, a good analogy here is UDP versus TCP. Yeah. You know, in a sense like TCP, this is for sending things over the network. You know, the way TCP works is I send some bytes over the network and the other person receives some bytes and it just all, you know, shows up in order. And if the bytes don't get there, TCP will like retry and they'll handle it all for you. Lots

1:01:16.975 --> 1:01:24.602
<v C>of acknowledgements and inquiries. Did you get it? Yes, I get it. I'm sending the next piece. Okay. Go ahead and send it. I got it. All right. Good. Lots of back and forth. Yes,

1:01:24.602 --> 1:01:55.779
<v A>exactly. And so when I read, you know, 16 bytes from somebody else over a TCP socket, I know they're in order. I don't have to think about it. And the people who are using UDP, you know, are doing it because they understand TCP. They have a very specific thing that they need to solve, maybe sending video and it doesn't work as well with the latency of TCP. And they're kind of, they're using UDP, knowing all the limitations and writing their own user space kind of workarounds for them. Yeah. Yeah. So it sounds like the same, same kind of thing here.

1:01:56.344 --> 1:03:55.060
<v C>And the whole reason that GIL has gotten bad rap anyway is because people have been looking for a scapegoat for why Python is so stinking slow, which is one of the main reasons why people have disliked it historically is it has been slow. And there's been all these reasons. And what it came down to is just implementation because it is now, I think, don't quote me on this. I would have to look it up again, but I think I remember something along the lines of it since Python 3.8, it is now 30 times faster. It is at this point approaching Java in terms of performance. Wow. So, and this is just from work that we know and some other developers and Microsoft put a lot of money into this as well, into funding the speeding up of Python. And it's getting faster. Every release is getting faster. One person had a humorous conjecture that if they keep up the current speed gains, if that trajectory is unchanged to the 3.14 will be faster than C, which of course is impossible. But I mean, that's how dramatic the shift has been so far. It is huge. But a lot of times people think, okay, well, Python's slow because of the GIL. No, it has something to do with it. In fact, it's slower without it. Or they might think, oh, it's slow because it's an interpreted language. I hear that a lot. It's an interpreted language. Well, interpreted language doesn't actually mean anything. Most of what we use is an interpreted language. Compiled just means you're moving from one code form to another. And Python's compiled too. Compiled to the bytecode. But the default Python implementation historically was slow because that bytecode had to be run by an interpreter on the end user's machine. And there's been for a long time another flavor of Python called PyPy. P-Y-P-Y. And that was a just-in-time compiler. So that actually even then had the same performance as Java.

1:03:55.280 --> 1:04:28.800
<v C>Because it was running in the same way that the Java JVM runs. It actually compiles to machine code at the time of execution. Python was slow because Python was slow. And that's improving. But there's nothing inherent about what it is or how it did things, like, from a design standpoint that made it slow. It's just how it was coded. And as we learn more and as we're able to examine certain parts of the code base and improve things, then we're able to solve a lot of those performance issues.

1:04:28.800 --> 1:05:40.319
<v A>Yeah, that makes sense. One of the things that I first encountered when I was using Python was interops. You know, this is something that traditionally if you want to have something in, let's say, Rust and then something in JavaScript talk to each other. Well, you know, one is running on your browser and then you're sending packets to the Rust server. And so you don't really need these languages to be built in together. But Python really introduced me to the Python C API and Boost Python and these ways to, you know, use Python and C++ together. And there's even, like, you know, ways to do it in either direction where you have a C++ binary that has the Python SO and the Python VM linked into it. Or, you know, Python code that has shared libraries written in C++ that it's calling into. Like, what's your take on the overall interop kind of ecosystem? And do you tell people to run away from that or, like, how do you, where do you think that's going? What's your overall take on that?

1:05:40.580 --> 1:06:13.660
<v C>Oh, it's getting stronger, if anything. So there's one thing that's been holding back, I think, a lot of growth in this area. And that is this little file. As soon as I say this, a bunch of Python seniors out there are going to shut their spontaneously. And that's Python.c. And that is the Python, the C file that provided the primary endpoints for interacting with Python from a C level. And that thing was written to work. It was not written to be pretty. It was not written to be easy to use.

1:06:16.202 --> 1:06:29.770
<v C>And it certainly is usable, but it had a lot of things about it that just, it was difficult to work with. And they're in the process of deprecating that, moving away from Python C and into kind of an

1:06:32.605 --> 1:06:59.140
<v C>improved set of headers that just make working with it a lot better. Now, I'm going to full disclosure, I have never written a Python extension. I know about this from researching the book. I have not actually done it myself. But I do know I've talked to several people that have been very excited about a project called CFFI, which is this interface with Python, between Python and C. And it's kind of an improvement over Python.h.

1:07:02.085 --> 1:07:03.756
<v C>And this not only allows you

1:07:06.068 --> 1:09:05.600
<v C>to talk to C, but it also allows you to then make a second jump and talk to Rust, Java, or what have you—whatever language happens to be out there. And so there's a lot of innovation right now in being able to make Python a part of another solution. And I've been hearing this in different capacities. There's, in general, kind of this quiet little movement happening behind the scenes of programming as a whole, where some programmers are starting to move away from the walled garden model of 'I'm working in this ecosystem.' And more into this mosaic pattern where, okay, I'm writing this with a bit of Java, a bit of C++, a bit of Rust. And they're pulling in pieces, and they're connecting them together. And CFFI keeps coming up. And so it's interesting because it's—I don't know which came first, because I don't know enough about it. But it is kind of fun to see that. I also know there's an effort to get—not just an effort, it is working. Python is now, there's a version of Python running in WebAssembly outright. And that has enabled Python in the browser for the first time, which means that via WebAssembly, in a similar way, you can bring Python into a project that is also using JavaScript. Because Python's not being turned into JavaScript. Python is Python. It's running in WebAssembly. And then because JavaScript is also able to communicate through WebAssembly, they're able to work together on things. So I'm seeing a lot more of this kind of mosaic pattern. And I'm excited to see what's going to come out in the next few years. Because, you know, every language has its strengths and its weaknesses and its thing. And if we can move into a space where we can pick up a language on the basis of, 'this is good for this piece of the project because it's just easier to do this thing here.' And 'this thing over here is easier in this language.'

1:09:05.920 --> 1:09:19.460
<v C>And you don't have to decide between the two of them. Would be incredible. That would be, frankly, a much saner way to move forward in some projects than having to marry one language until death do us part.

1:09:19.460 --> 1:10:18.500
<v A>Your thing about dialog boxes comes to mind here. It's like, 'That's actually one thing that I don't know how to do in Python.' I mean, there are many things I don't know how to do, but that's off the top of my head. I wouldn't actually know. It's not obvious to me how I would make a Windows dialog box pop up in Python. I mean, I think that there's nothing. And in general with UI, you know, I find that the Python UI story is a little strange. I mean, there's PyTK, which I've honestly never used. I don't know too much about it. PyQt seems to be pretty popular. But if I want to use a web front end, like Electron or one of these things, it seems to be really dominating. You know, like Slack is written in Electron. Discord, the desktop clients are in Electron. It's not obvious to me how I would use Python with Electron. And so, yeah, I think the UI story in Python—what's your take on that? And where is that going?

1:10:19.140 --> 1:10:43.020
<v C>I've always enjoyed UI in Python. You know, Tkinter is okay for getting started, but I mean, it's not beautiful by any means. Well, it can be. It depends on where you're using it. It kind of tries to mirror whatever operating system you're in to mixed effects. But like just to create a, you know, a random dialog box in a program that otherwise doesn't have a UI, that's probably the fastest way to go about it.

1:10:48.615 --> 1:12:47.669
<v C>But I think Qt, aka Qt, is really an interesting space because PyQt, which was—what was it? Riverbank, I think was the company that was doing that one. That was an unofficial fork. Those are unofficial bindings. Like some other company did those bindings for Qt. So Qt, or they're officially known as Qt. Qt wound up acquiring another project called PySide, which was just another set of Python bindings. And they made that into the official bindings. So the space—the UI space in Python is, if anything, getting better because now Python is a first-class citizen in the Qt ecosystem. So they now develop officially in parallel the C++ and the Python bindings for Qt 5 and now Qt 6. And similarly, GTK, which is also known—well, it's more frequently known as GObject now, which is the whole GNOME ecosystem. That is also cross-platform. That's had bindings forever. I've done work in PyGObject before. But whether or not that works in Windows, that's GNOME's fault. It's whether or not it works in Windows that remains to be seen. And then there's some newer libraries that are coming out. There's been this huge influx of Python-based UX libraries in the last few years. There's some rather interesting players in the space now. So I think that—that's really starting to expand. And probably the data science and machine learning spaces are driving that because there's all these projects that are using Python for data science, using Python for AI and machine learning. And the people writing those need front ends, they need dashboards, and they don't want to move out of Python. And so it's driving that need for more web-based and more native UIs. So there's a lot more options now than

1:12:48.310 --> 1:12:59.920
<v C>there were eight years ago, certainly. Patrick, you've been super quiet. I'm curious what your thoughts are, especially coming in as the guy who hated Python or maybe hates the strong words.

1:12:59.920 --> 1:13:01.040
<v B>Strong thing. Yeah.

1:13:02.640 --> 1:13:32.620
<v B>No, I mean, you guys went in a separate direction from how I would have gone. But that's good. No, no. I think this has been a really interesting conversation. I guess I'll chime in on the mosaic pattern thing. I think CFFI is C Foreign Function Interface, yeah, just to drop it if it wasn't obvious. Yeah. I think Clang powered a lot of that back-end interop stuff. I think that's been sort of where the genesis has started. At least that's always how I see it associated with...

1:13:32.620 --> 1:13:39.357
<v C>Yes, Clang. The whole Clang LLVM. I mean, they've revolutionized C and C++. I'll make

1:13:40.622 --> 1:15:37.760
<v B>a prediction there. I too am excited because I tend to do a little dabbling across languages and think that's interesting. But I think that'll go the way a bit of microservices where people will overdo it. You'll make a lot of projects that are impossible to maintain because you have that hundred lines of Haskell that only one dude knew how to write, and he's gone now. And everyone's just like, 'Yeah, you keep it around, hope it doesn't break,' kind of thing. And then you've got to kind of like, it has a place and a time. I guess that's all the software engineering tropes. But I will say, I think the thing we didn't touch on that has been interesting for me is Python dependencies. So I know it got really brutal for a while going from Python 2 to Python 3, and whether your library would work in one or the other. And just getting into the nightmare of moving from 'I'm writing something on my computer for me' to 'I'm writing something as part of a team' has always been a bit of a struggle for me. Python as a scripting for myself—great. The pass by value versus pass by reference always stumbles. It stumbles with me a bit. But the, you know, this thing of, 'Oh, you had this weird version installed on your computer globally and just depended on it.' I need that has also gotten better with things like Pi or the V and V virtual environment. V E and V. I don't know. What's the other one? That's it. I don't know. Yeah. Bemv. Okay. So these things have made that story a lot better. And most of the libraries now being Python 3 compatible has also now makes Python 3 actually usable after what a decade or something ridiculous. So I feel that there's been a lot of growth there. And I'm curious to know, I guess, like what your thought is. You sort of sounds like lean in on the right 'Python is Python.' Don't worry so much about the typing. You can get all these things. There's been a lot of movement I see, again, not being part of this space, but people talking about adding type hints to their Python programs as a way to support those. What do they call the illities?

1:15:38.400 --> 1:15:50.000
<v B>Maintainability, scalability across teams, reproducible testability. I mean, that was a lot rambling. Sorry. But I'm all stored up. Yeah. I don't know. Feel free to respond or comment on any of those.

1:15:50.060 --> 1:17:48.769
<v C>Yeah. Well, I can respond to both of those. So one of the topics I've been passionate about is this issue of Python packaging. And I gave a talk a couple of times called 'Escape in the Cargo Cult.' So Python has been haunted by this phenomenon called Cargo Cult programming, specifically in the space of packaging. And this is what led to a lot of the nightmares. Like virtual environments aren't new. PIP, being able to install packages, not new. The main problem in that space has been that people don't understand how Python packaging works. And so they kept inventing it again. And they weren't inventing it because they were trying to understand it. They were inventing it because they thought there was nothing there. And so they would just try to figure it out. And then when they would half figure something out, then they'd say, 'Hey, I figured it out. Here's a template.' And then they'd start passing that around. And someone else would copy that template and modify it and understand none of it. And so you had this compounding problem of just all of these projects with these setup.py files that were just not reasonable, rational, or reusable. And all these assumptions that were leaking, you know, because every time you copy and paste code, you were copying and pasting the assumptions in the headspace of the programmer who wrote it. And most of those assumptions are not going to apply to your project. So you're going to have to then go back and understand what it is you just copy-pasted and vet whether or not those assumptions even make sense. That's assuming you can find them all. This is why I'm a huge advocate for if you find something on Stack Overflow, take 10 minutes and literally retype the whole thing. Just retype it. Just that mere action of retyping it is going to force you to interact with it at such a granular level that you're going to stop and go, 'Why am I doing this?' And it's going to lead you to vet those assumptions. So the Python packaging space has improved a lot. And part of it was the creation

1:17:49.410 --> 1:19:48.447
<v C>of the unofficial official body called the Python Packaging Authority. And they don't really have any official... They're like the advisory board. They're the people that build the packaging tools and they help steer Python in terms of packaging, but they don't really have any sort of, you know, hammer to hit it over the head with. Although the name deliberately makes it sound like they do. And they've helped bring a lot of clarity to this space. Moving away from the setup.py files, which were... It just tempted people to write too much convoluted logic to try and package. And they moved more towards the setup.cfg and PyProjectTOML files, which are declarative. They say, you're describing your project in a fairly standard fashion, and then you can pick a back end. Do you want to use setuptools? Do you want to use Poetry? Do you want to use Flit? And so that's reduced a lot of that insanity. And it's also standardized things like stating what your dependencies are and pinning versions for those dependencies. And so that has really driven a lot of the improvement in this space. If anyone is listening and thinking, you know, I'm struggling with this too, the two things I would do is: number one, figure out your packaging early. As early in the project as possible. I once built a game. It took me a month to build the game. It took me two years to package it. I am not kidding. Thank you, Kivvy, for literally declaring that shipping to the end user is an edge case. I wish I was kidding. That I'm quoting the maintainer. So figure out your packaging early. Figure it out at first, if at all possible. Second is do out-of-place testing. Write your tests in a separate folder from your source. So you have your source folder, SRC. Put your Python packages under that. Have as many packages as you want, but put all your packages under that. Put your packaging files external to that. So in the root of your repository. And then adjacent

1:19:49.510 --> 1:20:28.080
<v C>to, not inside of, adjacent to your source folder, put your tests folder. Write your tests there. What this is going to do is it's going to force you to only be able to run those tests in a virtual environment that has installed your package. Which means that all of the assumptions you've been making about your current working directory and about 'it works on my machine' are going to break. And you hit those problems early on, and you hit them often. Every time you make one of those faulty assumptions, your tests are going to break. And so you can solve it while it's still solvable. Great tip. You also touched on annotations, but I can come back around to that if you have any follow-up thoughts on packaging.

1:20:30.400 --> 1:21:52.260
<v B>No, I think that was great. I mean, I think, like I said, I feel there's been—this is probably wrong, but I feel there's been a sophistication growth in this sort of like, for people like me who, I won't say expert, that's maybe a bridge too far. But do a lot of programming in other languages to interact with Python and be productive by finding resources on stuff like how to get set up with a proper environment, how to make sure to get your dependencies bringing across is a huge thing. And to be clear, do most of my programming in C++, dependency story is easier because it's non-existent. Yeah. There are several people attempting to do it, but you just basically, as far as I know, a significant fraction of people just use no dependency management. And so I shouldn't throw stones, but I just say that, you know, there's that assumption in Python, you're going to sit down, you're going to bring all these batteries included—batteries not, you know, you bring them all in and then you just go. And when it works, amazing. And, you know, I think that, yeah, we were talking about annotations for types. And I think that was the other thing for me is how do I go from writing a script for myself and make sure that when I put that up on, you know, the team's GitHub and they go pull it down, that not only it runs dependencies, but also that they, when they're looking at one function, how are they understanding what's expected to be coming in, what's getting returned? That was always something that was a bit foreign.

1:21:52.480 --> 1:23:07.319
<v C>Yeah. And just one other note I'll mention on the packaging front, you said it seems like a sophistication. I would actually say it's a desophistication. They were—they were sophisticating themselves right into obscurity is what they were doing. And like everybody was being super sophisticated about their packaging at to the point of being esoteric. And so it was, it was, that was part of the problem. I think, you know, C++ never had the opportunity to be sophisticated, like to your point that you just, you, you download and you compile the thing or you bring in a DLL or some, or some such nonsense. And, and there's almost an assumption that this is going to hurt. So, you know, it's that—that's just an assumption right off the bat. Whereas because people were trying to make it as easy to package in Python as it was to write in Python, but they didn't understand the space. They were creating these really sophisticated solutions that weren't actually sophisticated at all. They were just cerebral. And because you—you take two cerebral things and slam them together, they're not going to work because they're two completely different thought spaces. So desophisticating it, making it more obvious, more like you don't have as much say now as you used to. And that's really a good thing because you shouldn't be reinventing packaging more than likely.

1:23:08.871 --> 1:25:06.580
<v C>To the type annotation thing, I think the thing that I understand about type annotations is Python is not JavaScript. And that was, I think, one of the driving factors that led to it being put in there. As I mentioned earlier, a value is still strictly typed, but you're strictly typing it on the basis of what it can do, or you're interacting with those types on the basis of what they can do. And so, Python's always had this saying, 'Explicit is better than implicit.' It's part of this poem called The Zen of Python that is kind of the tongue-in-cheek driver of decision-making in the language. Like, this is the best way to describe what our priorities are as a language. It was written in jest, but as you'll notice very quickly with Python programmers, the line between kidding and serious is spider silk thin. So, it's usually when we're making a joke, we're also being dead serious about it at the same time. Amazingly passive-aggressive bunch. I love them, though. So, type annotations became a way of explicitly defining the assumptions that you're making about what you can do with the value. You don't, in most cases, actually... Python does not actually use those type annotations itself. That's... The term 'annotation' is deliberate. It's like a comment. It's a special type of comment. That is just a reference for the software developer slash the static analysis tool, like MyPy, to be able to look at it and go, 'You're breaking this assumption.' And that's helpful because not everything fits neatly into this little bucket of type annotations. There's some times where you just finally—you're tearing your hair out, you just shut it off because there's just no way to do it. But most of the time, it's pretty reasonable to be able to say, 'This is... Here's the assumption I'm making. This thing you're passing in should be iterable because I'm going to be using it in a loop. So, this should be an iterable.'

1:25:06.940 --> 1:25:49.504
<v C>And this should be an integer because I'm going to assume it's a numeric value without a decimal point. And so on and so forth. So, you can... So, you're really describing the sort of data that you're expecting to be fit into those spaces. Now, I say it's rarely used by Python itself. There is one exception, and that is those single dispatch methods I mentioned earlier. It will actually look at the type annotation in that case. And the code itself will use that to determine which of the single dispatch functions to call based on the type of data that was passed in to the first argument of the function. And so, it can switch. I think match statements also can work with type 2, actually. The new match statements. Yeah,

1:25:50.517 --> 1:26:30.160
<v A>that makes sense. So, I wanted to give a bit of time here to talk about Dead Simple Python. So, this is a book that you wrote. It took an extraordinary amount of time and effort. You had to read through the guts of Python many times, talk to the core developers. A lot of them are editors on the book. And kind of talk us a little bit through, you know, who is the target audience for this book? And, you know, how do you expect that audience to use the book? Is it something where you expect people to read it cover to cover? Is it an encyclopedia? Or people are going to go to a specific chapter when they need to? You know, what's the audience and how are they going to use it?

1:26:30.160 --> 1:28:10.191
<v C>Sure. And I do have to, in full disclosure, clarify something. None of the core developers I spoke to were editors on the book. Python experts, certainly, are the editors. But none of them are. A core developer is someone who actually develops the Python language. And none of the guys who edited the book are officially mandated core developers. But I did talk to a couple of core developers in writing it. There are a couple of thank yous in there from some. In particular, the guy responsible for writing the Asyncio Library, actually, took a look at that chapter and helped me future-proof it. A couple others, which I appreciate. Anyway, but, Dead Simple Python was written for people who know another programming language and they want to understand Python deeply. Or maybe they even know a bit of Python. Maybe they've worked in Python before. But they continually find themselves baffled by the obvious solution. So there's another saying in Python: 'There should be one obvious way to do things.' And that seems very glib until you read the next line of the Zen of Python, which says, 'That way may not be obvious unless you're Dutch,' which is a reference to Weedle. And basically, the term simple in terms of this book and the term obvious in Python mean the same thing. It's not obvious or simple looking forward. You're looking at the problem. You're going, 'How in God's green earth am I supposed to do this? I can think of 50 different ways. Which way is right?' It's only obvious or simple retrospectively. Once you've actually found the best way to do it, then you look back and you go, 'Of course.'

1:28:12.099 --> 1:28:34.744
<v C>Nothing else would have made sense. It clicks. It's got that sort of psychological snap to it that you're just like, 'This makes more sense than anything else I could have thought of.' But only once you know it. And so the whole goal of the book is to help people develop that sort of ability to see things, to see the one obvious way,' in finger quotes, forward

1:28:36.330 --> 1:30:33.949
<v C>instead of just backwards. And I do that by explaining—well, first of all, I skip all of the sort of boring, you know, 'This is what a loop is.' 'This is what a variable is.' 'This is what a function is.' You know this stuff. You don't need a refresher. But what matters to someone picking up the Python language is: What is a loop in Python? What's special about a loop in Python? What's special about a variable or a function in Python? So understanding what makes it unique in this language. So the approach I take throughout the book is I will start from what I call the most sugar-free version. Like it'll be Python code, but it won't have any of the fancy special stuff. I'm literally doing it the most manual way possible. And then I add layer upon layer of abstraction. So by the time you actually get to that for loop or that assignment statement or whatever, you're going, 'Oh, so what's actually under the hood is this?' And because you understand what's under the hood, then it becomes sort of a pattern substitution. And you understand why you're using a for loop. It's because, okay, this is—I'm iterating. And I'm iterating in this way.' And so it really enables you to understand the whys and the wherefores of Pythonic patterns in a way that you can then apply it to your own code. The other thing I did with this book is I didn't give a project. There's tons of examples that you type through with me, and they're snarly in all the right places. Like I don't make any of them behave nicely. I took a lot of time to make these like really examples that really had a lot of hidden surprises where it would break in unexpected places. And you'd have to understand, 'Why is it breaking here and how do we fix that?' But I didn't give any project because the assumption was you're probably writing some code. You probably already have a goal in mind. You don't need me to hand you something to do. You're already doing something. What you need is the tools necessary to be

1:30:34.422 --> 1:31:16.340
<v C>able to solve that problem. So you could work through it cover to cover. But it is also written on the basis that you can just drop right to the chapter on the thing you're working with. Like, 'Okay, how does asyncio work in Python?' You can drop right into that. And the only assumption it's going to make is that anything that's been defined in a previous chapter, I don't need to go through again. If you do need it, there's an index, there's a glossary you can turn back if you need to. But it focuses on each piece at a time, layer after layer. So by the time you go through the whole book, you've covered the entire core language and front to back. And even touched on a few of the libraries in the process. That was the approach I took with the book.

1:31:17.220 --> 1:32:13.040
<v B>That's awesome. Yeah, I mean, I think you mentioned a couple of decisions on how to communicate the book and what to write. And I always appreciate that—that's one of the things with programming books in particular. You said best practices before. I'll say sometimes people give, 'This is the best book.' You want to learn something like, 'This is the best book.' And I always find it's like, really? Really? Like, the tone of the book, the style. Like, 'Learn such and such in four hours' is always the wrong answer. You can never learn it in that many hours. It's always a lot. But other than that, you know, I think like, it's sometimes you just need a certain kind of communication style. Maybe it's watching a YouTube video. Maybe it's, you know, reading a book. I think that I just love the fact that I feel for our field that we just have so much diversity in how to express the concepts. And somebody does need to learn how to write a for loop, but you don't have to write a book for them. You can write a book for the person who says, 'Yeah, I know what it is.' Cut to the good part, right? The part where, like, what makes it special. Exactly.

1:32:13.760 --> 1:34:07.380
<v C>I mean, there are, and this is one of the reasons why I signed it for this book, because there are a thousand books for here's how to code for the first time in Python. There's some great ones, you know, Python Crash Course, The Automate the Boring Stuff with Python, anything by Al Sweigart. It's awesome. You know, there's many others besides that that I could point to. It's a lot of great books for learning Python for beginners. But I noticed that with Python in particular, that there were exactly two types of books on the market. There was the Python for beginners. And then there was the here's how to train a neural network to recognize pictures of cats versus pictures of squashes running on a Raspberry Pi that is running on a potato battery in your grandmother's basement. Those are the only two types of books there are for Python. And there's this crater in the middle for all the people who are like, I'm not doing data science, machine learning, or this random Django thing over here. I just need to know how to write a list comprehension that makes sense. And that lack of those sorts of things in book form really, really drove this. So I hope there will be more people inspired by this to write similar books. I would love for there to be competition. Oh, that's great. But yeah, I think I think there was one book that was that was pretty close. And I won't I won't name it because I don't want to I don't want to poke fun at a fellow author. But I was asked like, 'Okay, well, is this similar?' And I'm like, 'No, it's not,' because I can look just like a list comprehension is like this is just a simple for an in range of, you know, one day. It's like, what about conditionals? What about accessing sub keys on it? What about unpacking a tuple in the middle of it? Like, none of this is half of it's not even documented.' And that's kind of the funny thing is like, I had to really dig into how does this work at all? Because no one wrote it down. So that was fun.

1:34:07.380 --> 1:34:18.660
<v B>Well, Jason, this has been great. We have, you know, just a couple minutes and we got to head out. But what if people want to catch up with you? So obviously the book, anything else like people to keep up with you or check out?

1:34:18.920 --> 1:35:11.599
<v C>Yeah. You know, in general links to every, I am ubiquitously found online as Codemouse92. So anywhere that I am, that's my screen name. I am. I just left the big bird blue site, the big blue bird site. Excuse me. I got that backwards. It was getting a bit musky in there. So I am now on Mastodon. If anyone's buying me, Codemouse9, do it. Mastodon.online. I have a terrible pun every Monday too. So be forewarned. If you follow me, prepare to groan. And I can be found on IRC pretty frequently as well. I don't know. I've been unplugging a lot more from social media. LinkedIn's pretty good too. But whenever I write new articles or whatever, they're probably going to be on dev.to. That's a neat community to check out. And then there's also my podcast, The Bug Hunters Cafe. So talk about debugging on there. So that can be fun too.

1:35:12.500 --> 1:35:34.900
<v B>Well, awesome. Thanks. I thought that was awesome. We covered a whirlwind of topics like basic, sophisticated, or all over the map. That was amazing. Definitely plenty of brain food here to kind of think about and ponder. But thanks for being on the show. It's been a great time. And thanks to all of our listeners again for hanging with us another episode. And we'll see you all next time.

1:35:35.380 --> 1:35:36.019
<v A>See you later.

1:35:36.700 --> 1:35:51.440
<v B>See ya. Music by Eric Barndoller.

1:35:53.120 --> 1:36:11.200
<v A>Programming Throwdown is distributed under a Creative Commons Attribution-ShareAlike 2.0 license. You're free to share, copy, distribute, transmit the work, to remix, adapt the work. But you must provide attribution to Patrick and I. And ShareAlike in kind.

