Lex Fridman Podcast - #341 – Guido van Rossum: Python and the Future of Programming

Episode Date: November 26, 2022

Guido van Rossum is the creator of Python programming language. Please support this podcast by checking out our sponsors: - GiveDirectly: https://givedirectly.org/lex to get gift matched up to $1000 -... Eight Sleep: https://www.eightsleep.com/lex to get special savings - Fundrise: https://fundrise.com/lex - InsideTracker: https://insidetracker.com/lex to get 20% off - Athletic Greens: https://athleticgreens.com/lex to get 1 month of fish oil EPISODE LINKS: Guido's Twitter: https://twitter.com/gvanrossum Guido's Website: https://gvanrossum.github.io/ Python's Website: https://python.org PODCAST INFO: Podcast website: https://lexfridman.com/podcast Apple Podcasts: https://apple.co/2lwqZIr Spotify: https://spoti.fi/2nEwCF8 RSS: https://lexfridman.com/feed/podcast/ YouTube Full Episodes: https://youtube.com/lexfridman YouTube Clips: https://youtube.com/lexclips SUPPORT & CONNECT: - Check out the sponsors above, it's the best way to support this podcast - Support on Patreon: https://www.patreon.com/lexfridman - Twitter: https://twitter.com/lexfridman - Instagram: https://www.instagram.com/lexfridman - LinkedIn: https://www.linkedin.com/in/lexfridman - Facebook: https://www.facebook.com/lexfridman - Medium: https://medium.com/@lexfridman OUTLINE: Here's the timestamps for the episode. On some podcast players you should be able to click the timestamp to jump to that time. (00:00) - Introduction (07:26) - CPython (12:38) - Code readability (17:00) - Indentation (33:36) - Bugs (45:04) - Programming fads (1:00:15) - Speed of Python 3.11 (1:25:09) - Type hinting (1:30:27) - mypy (1:35:43) - TypeScript vs JavaScript (1:51:42) - Best IDE for Python (2:01:43) - Parallelism (2:19:36) - Global Interpreter Lock (GIL) (2:29:14) - Python 4.0 (2:41:31) - Machine learning (2:51:13) - Benevolent Dictator for Life (BDFL) (3:02:49) - Advice for beginners (3:09:21) - GitHub Copilot (3:12:47) - Future of Python

Transcript
Discussion (0)
Starting point is 00:00:00 The following is a conversation with Guido Van Rossam, his second time on this podcast. He is the creator of the Python programming language, and his Python's Emeritus BDFL, benevolent dictator for life. And now, a quick few second mention of each sponsor. Check them out in the description. It's the best way to support this podcast. We got a gift directly for philanthropy, aid sleep, for naps, fund rise for real estate investing, inside tracker for bio data, and athletic greens for nutritional
Starting point is 00:00:32 health. Choose wisely, my friends. And now, onto the full ad reads, as always, no ads in the middle. I try to make this interesting, but if you skip them, please still check out our sponsors. I enjoy their stuff. Maybe you will do. This show is brought to you by Give Directly, a non-profit that lets you send cash directly to the people that need it. Give Directly donors include previous guests of this podcast, Jack Dorsey, and Elon Musk, Metallic buterin, all of whom happen to be be actually not Jack. Jack only's been on once, but I'm pretty sure he's going to be on again many more times. He's a fascinating human being. Anyway, Elon too. He'll be back on soon. And of course, the italic as well. After the merge. Anyway, all of that to say that the idea of giving directly to the people that
Starting point is 00:01:27 need it is actually a really powerful way to help people. There's a lot of science, there's a lot of studies behind it that showed that getting cash directly to the people that need it is actually the best way to help them. So I think a lot of philanthropy is based on the idea that you could have a lot of middlemen and you kind of fund that chain that's able to optimally redistribute the funding. And okay, there might be some interesting aspects of that idea, but what I think is especially interesting is that when you remove all of those middlemen and you give directly to the people that need it, it's actually really effective. I frankly love that idea.
Starting point is 00:02:05 You can visit givedirectly.org slash Lex to learn more, and send cash directly to someone living in extreme poverty. That's givedirectly.org slash Lex. This episode is also brought to you by Aitsleep and it's new pod three mattress. I love taking naps. I got very little sleep last night. I just had a crazy pile of tasks to finish and I had a crazy busy day today. So after I'm done recording these very
Starting point is 00:02:37 words that I'm speaking to you, I'm going to go lay down on an eighth sleep bed. Cold mattress, warm blanket. And I'm going to pass out for 20, 25, 30 minutes. And I'm going to, as opposed to feeling, a little bit tired, a little bit mentally exhausted. Maybe a little bit not so motivated to do work. I'm going to feel like a new human being. Excited to get right back into the trenches of programming and taking on the rest of the day.
Starting point is 00:03:12 Just powering through, super productive. All of that, thank you to a comfortable enriching joyful nap. Check it out and get special holiday savings of up to $400 when you go to 8sleep.com slash Lex. This episode is also brought to you by Fundrise, spelled F-U-N-D-R-I-S-E. It's a platform that allows you to invest in private real estate. As you know, looking at different markets
Starting point is 00:03:45 and investment opportunities and all the crazy financial stuff that's going out there in the world, I think it's a good idea to diversify. And that's why private real estate is an interesting place to diversify in. And of course, when you do that kind of diversification, you should be using the services that make it super easy. You don't need to be an expert in what is required
Starting point is 00:04:12 in this kind of investment. You don't need to go through super complicated paperwork and so on. They vet everything for you. They figure out what are good real estate projects that invest in and make it super easy for you to do so over 150,000 investors use it. Check it out. It takes just a few minutes to get started at Fundrise.com slash Lex. This show is also brought to you by Inside Tracker. The service I used to track biological data that
Starting point is 00:04:42 comes from my body is fed in as the raw signal into machine learning algorithms, the DNA data, fitness tracker data, blood data, all that kind of stuff, goes into the machine learning algorithm and gives a prediction, a recommendation about what I should do with my diet and less style changes. This is obviously the early steps in what will make the 21st century incredible, which is the personalization, the deep personalization, both medicine, lifestyle, diet, everything, career choices, mentorship, everything. Should be coming from rich, raw signal coming from your body. Maybe one day, coming from your brain. If one day come if you're in your brain.
Starting point is 00:05:25 If you have BCIs, brain computer interfaces, like neural link operating, this is such an exciting future. So I'm a huge supporter of this kind of future. If it's done right, if it's done in a way that respects people's privacy and people's rights, this is really, really a great way to help individuals optimize their life.
Starting point is 00:05:44 And get special savings for a limited time when you go to inside Tracker.com slash Lex This show is also brought to you by athletic greens and it's AG1 drink Which is an all-in-one daily drink to support better health and peak performance. It's my Zen temple that I return to plus a day. After a couple coffee, it's the first thing I drink every day. I also drink it after a long run.
Starting point is 00:06:13 And it gives me a certainty that I have all my nutritional bases covered. So all the crazy kind of diet stuff I'm doing, if I'm fasting, if I'm doing one meal a day, if I'm doing card of orange, a little carb, all that kind of diet stuff I'm doing if I'm fasting, if I'm doing one meal a day, if I'm doing carnivores, just a little carb, all that kind of stuff. Or if I'm fasting for multiple days, or if I'm doing crazy stretches of work or exercise, so both the mental and the physical fatigue that everything I'm doing to my body, in terms of challenging it, I know I have that basis covered. And so it's like a multivitamin, but Amazing multivitamin. I highly highly recommended and plus it also tastes good They'll give you one month supply a fish oil when you sign up at athletic greens.com slash Lex
Starting point is 00:07:00 This is the Lex Friedman podcast to support it. Please check out our sponsors in the description and now, dear friends, here's Guido and Rassam. Python 3.11 is coming out very soon. In it, see Python claimed to be 10 to 60% faster. How did you pull that off? And what's see Python? See Python is the last Python implementation standing also the first one that was ever created. The original Python implementation that I started over 30 years ago. So what does it mean that Python, the programming language, is implemented in another programming language called C? What kind of audience do you have in mind here?
Starting point is 00:07:57 People who know programming? No, there's somebody on a boat that's into fishing and have never heard about programming, but also some world-class programmers. You're gonna have to speak to both. Imagine a boat with two people. One of them has not heard about programming is really interfishing, and the other one is, like an incredible Silicon Valley programmer
Starting point is 00:08:17 that's programmed in everything. C, C++, Python, Rust, Java, and those the entire history of programming languages. So you're gonna have to speak to both. I imagine that boat in the middle of the ocean. Yes. I'm going to please the guy who knows how to fish first. Yes, please.
Starting point is 00:08:35 He seems like the most useful in the middle of the ocean. You got to make him have. I'm sure he has a cell phone. So he's probably very suspicious about what goes on in that cell phone. So he's probably very suspicious about what goes on in that cell phone, but he must have heard that inside his cell phone is a tiny computer. And a programming language is computer code that tells the computer what to do. It's a very low level language. It's zeroes and ones, and then there's assembly. And then oh yeah, we don't talk about these really low levels because those just confuse
Starting point is 00:09:07 people. I mean when we're talking about human language we're not usually talking about vocal tracks and how you position your tongue. I was talking yesterday about how when you have a Chinese person and they speak English there's a bit of a stereotype they often don't know. They can't seem to make the difference well between an L and an R. And I have a theory about that, and I've never checked his with linguists, that it probably has to do with the fact that in Chinese there is not really a difference, and it could be that there are regional variations in how native Chinese speakers pronounce that one sound that sounds too L to some, like L to some of them, like R to others.
Starting point is 00:09:56 So it's both the sounds you produce with your mouth throughout the history of your life, and what you're used to listening to. I mean, every language has that. Russian has the Slavic languages have sounds like the letters, like Americans or English speakers don't seem to know the sound. They seem uncomfortable with that sound. Yeah. So, yes.
Starting point is 00:10:22 Okay. So, we're not going to the shapes of tongues and the sounds that the mouth can make. Yeah. So I'm sure, yes. Okay. So we're not we're not going to the shapes of tongues and the sounds that the mouth can make fine. And similarly, we're not going into the ones and zeroes or machine language. I would say a programming language is a list of instructions like a cookbook recipe that sort of tells you how to do a certain thing, like make a sandwich. Well, acquire a loaf of bread, cut it in slices, take two slices, put mustard on one, put jelly on the other, or something, then add the cheese. I've heard that science teachers can actually do great stuff with recipes like that and trying
Starting point is 00:11:07 to interpret their students' instructions incorrectly until the students are completely unambiguous about it. Well, the language, see, that's the difference between natural languages and programming languages. I think ambiguity as a feature, not a bug in human spoken languages. That's the dance of communication between humans. Well, for lawyers, ambiguity certainly is a feature. For plenty of other cases, the ambiguity is not much of a feature, but we work around
Starting point is 00:11:44 it, of course. Well, what's more important is context. So with context, the precision of the statement becomes more and more concrete, right? But, you know, when you say, I love you to a person that matters a lot to you, the person doesn't try to compile that statement and return an error saying, please define love. Right. Now, but I imagine that my wife and my son interpreted very differently. Yes, even though it's the same three words, but in precisely still,
Starting point is 00:12:18 for sure, lawyers never have a lot of follow up questions for you. Nevertheless, the context is already different, different in that case. Yes, fair enough. So that's a programming language is ability to unambiguously state a recipe. Actually, let's go back. Let's go to Pepe. You go through and Pepe, the style guy for Python code, some ideas of what this language should look like, feel like, read like. And the big idea there is that code readability counts. What does that mean to
Starting point is 00:12:53 and how do we achieve it? So this recipe should be readable. That's a thing between programmers. Because on the one hand, we always explain the concept of programming language as computers need instructions. And computers are very dumb and they need very precise instructions because they don't have much context. In fact, they have lots of context, but their context is very different. But what we've seen emerge during the development of software, starting in the probably in the late 40s, is that software is a very social activity. A software developer is not a mad scientist who sits alone in his lab writing brilliant code. A software is developed by teams of people.
Starting point is 00:13:46 Even the mad scientist sitting alone in his lab can type fast enough to produce enough code so that by the time he's done with his coding, he still remembers what the first few lines he wrote mean. So even the mad scientist coding alone in his lab would be sort of wise to adopt conventions on how to format the instructions that he gives to the computer so that the thing is there is a difference between
Starting point is 00:14:17 in cookbook recipe and a computer program. The cookbook recipe, the author of the cookbook computer program. The cookbook recipe, the author of the cookbook writes it once, and then is printed in 100,000 copies, and then lots of people in their kitchens try to recreate that recipe, that particular pie or dish from the recipe. And so, there the goal of the cookbook author is to make it clear to the human reader of the recipe, the human amateur chef, in most cases. When you're writing a computer program, you have two audiences at once. It needs to tell the computer what to do, but it also is useful if that program is readable by other programmers, because computer software, unlike the typical recipe for a cherry pie, is so complex recipe for a cherry pie is so complex that you don't get all of it right at once. You end up with the activity of debugging and you end up with the activity of, so debugging is trying to figure out why your code doesn't run the way you thought it should run. That means broad, it could be stupid little errors, or it could be big logical errors.
Starting point is 00:15:48 It could be anything spiritual. Yeah, it could be anything from a typo to a wrong choice of algorithm to building something that does what you tell it to do, but that's not useful. does what you tell it to do, but that's not useful. Yeah, it seems to work really well. 90, 9% of the time, but does weird things, 1% of the time on some edge cases. That's pretty much all software nowadays. All good software, right? Well, yeah, for bad software, that 99 goes down a lot. So, but it's not just about the complexity of the program.
Starting point is 00:16:24 It's like you said said it is a social endeavor in that you're constantly improving that recipe for the cherry pie. But you're sort of you're in a group of people improving that recipe. Or the mad scientist is improving the recipe that he created a year ago and making it better. We're adding, adding something. He decides that he wants a, I don't know, he wants some decoration on his pie or icing or... So there's broad philosophical things
Starting point is 00:16:57 and there's specific advice and style. So first of all, the thing that people first experience when they look a python, it is very readable, but there's also a spatial structure to it. Can you explain the indentation style of Python and what is the magic to it? Spaces are important for readability of any kind of text. If you take a cookbook recipe and you remove all the sort of, all the bullets and other markup and you just crunch all the text together. Maybe you leave the
Starting point is 00:17:36 spaces between the words, but that's all you leave. When you're in a kitchen trying to figure out, oh, what are already ingredients and what are the steps? And where does this step end and the next step begin? You're going to have a hard time if it's just one solid block of text. On the other hand, what the typical cookbook does, if the paper is not too expensive, each recipe starts on its own page. Maybe there's a picture next to it. The list of ingredients comes first. There's a standard notation.
Starting point is 00:18:12 There's shortcuts so that you don't have to sort of write two sentences on how you have to cut the onion because there are only three ways that people ever cut onions in a kitchen, small, medium, and in slices, or something like that. Right. None of my examples make any sense to real cooks, of course, but... Yeah. We're talking to programmers with a metaphor of cooking.
Starting point is 00:18:38 I love it. But there is a strictness to the spacing that Python defines. So there's some looser things, some stricter things, but the four spaces for the indentation is really interesting. It really defines what language looks and feels like. Because indentation, sort of, taking a block of text and then having inside that block of text, a smaller block of text that is indented further as sort of a group. It's like you have a bulleted list in a complex business document and inside some of the bullets are other bulleted lists, you will indent those too. bulleted lists, you will indent those too. If each bulleted list is indented several inches,
Starting point is 00:19:33 then at two levels deep there's no space left on the page to put any of the words of the text. So you can't indent too far. On the other hand, if you don't indent at all, you can tell whether something is a top level bullet or a second level bullet or a third level bullet. So you have to have some compromise and based on ancient conventions and the sort of the typical width of a computer screen in the 80s and all sorts of things, sort of, we came up with sort of force spaces as a compromise. I mean, there are large groups of people who code with two spaces per indent level. For example, the Google Style Guide, all the Google Python code, and I think also all the Google C++ code is indented with only two spaces per lock.
Starting point is 00:20:26 If you're not used to that, it's harder to at the glance understand the code because the sort of the high level structure is determined by the indentation. On the other hand, there are other programming languages where the indentation is eight spaces or a whole tab stop in sort of classic unix. And to me, that looks weird because you sort of after three indent levels, you've got no room left. Well, there are some languages where the indentation is a recommendation.
Starting point is 00:20:59 It's a stylistic one. The code compiles, even without any indentation. And then Python really indentations are fundamental part of the language, right? It doesn't have to be four spaces. So you can code Python with two spaces per block or or six spaces or 12 if you really want to go wild, but sort of everything that belongs to the same blog needs to be indented the same way. In practice, in most other languages, people recommend doing that anyway. If you look at C or Rust or C++, all those languages, Java, don't have a requirement of indentation, but except in extreme cases, they're just as anal about having their code properly indented. So any IDE that the syntax highlighting that works with Java or C++, they will yell at you
Starting point is 00:22:03 aggressively if you don't do proper indentation. They suggest the proper indentation for you. In C, you type a few words and then you type a curly brace, which is their notion of sort of begin an indented block. Then you hit return and then it automatically indents for eight spaces depending on your style preferences or how your editor is configured. Was there a possible universe in which you considered having braces and Python? Absolutely, yeah. Well, it was a 6040, 7030, in your head. What was the trade-off. For a long time, I was actually convinced that the indentation was just better.
Starting point is 00:22:54 Without context, I would still claim that indentation is better. It reduces clutter. However, as I started to say earlier, context is almost everything. And in the context of coding, most programmers are familiar with multiple languages, even if they're only good at one or two. And apart from Python and maybe Fortran, I don't know how that's written these days anymore, but
Starting point is 00:23:26 all the other languages Java, Rust, CC++, JavaScript, typescript, Pearl are all using curly braces to sort of indicate blocks. And so Python is the odd one out. So it's a radical idea. Do you still, as a radical, renegade revolutionary, do you still stand behind this idea of space of indentation versus braces? Like what can you dig into it a little bit more? Why you still stand behind indentation? Because context is not the whole story. History in a sense provides more context.
Starting point is 00:24:07 So, for Python, there is no chance that we can switch. Python is using curly braces for something else, dictionaries mostly. We would get in trouble if we wanted to switch. Just like you couldn't redefine C to use indentation, even if you agree that indentation sort of in a greenfield environment would be better, you can't change that kind of thing in a language. It's hard enough to reach agreement over much more minor details. Maybe in the past in Python, we did have a big debate about taps for spaces and for spaces for as a fewer or more.
Starting point is 00:24:55 We came up with a recommended standard and options for people who want to be different. But yes, I guess the thought experiment I'd like you to consider is if you could travel back through time when the when the compatibility is not an issue, and you started Python all over again, can you make the case for indentations still? Well, it frees up a pair of matched brackets of which there are never enough in the world for other purposes. It really makes the language slightly easier to grasp for people who don't already know another programming language.
Starting point is 00:25:46 Because one of the things, and I mostly got this from my mentors who taught me coded before in not in any other language, a whole bunch of concepts in programming are very alien or sort of new and maybe very interesting, but also distracting and confusing. And there are many different things you have to learn. You have to sort of, in a typical 13 week programming course, you have to, if it's like really learning to program from scratch, you have to cover algorithms, you have to cover data structures, you have to cover syntax,
Starting point is 00:26:44 you have to cover variables, loops have to cover data structures, you have to cover syntax, you have to cover variables, loops, functions, recursion, classes, expressions, operators. There are so many concepts. If you can spend a little less time having to worry about the syntax. The classic example was often, oh, the compiler complains every time I put a semi column in the wrong place or I forget to put a semi column, Python doesn't have semi columns in that sense.
Starting point is 00:27:22 So you can't forget them. And you are also not sort of misled into putting them where they don't belong because you don't learn about them in the first place. The flip side of that is forcing the strictness onto the beginning programmer to teach them that programming is values attention to details details you don't get to just right the way you write an English name other details that they have to pay attention to I think they'll they'll still get the message about paying attention to details the interesting design choice. I still program quite a bit in PHP And I'm sure there's other languages like this, but the dollar sign before a variable.
Starting point is 00:28:06 That was always an annoying thing for me. It didn't quite fit into my understanding of why this is good for a program of language. I'm not sure if you ever thought about that one. That is a historical thing. There is a whole lineage of programming languages. PHP is one, Pearl was one. The Unix shell is one of the oldest or all the different shells. The dollar was invented for that purpose because the very earliest shells had a notion of scripting, but they did not have a notion of parameterizing the scripting. And so a script is just a few lines of text where each line of text is a command that is read by a very primitive command processor that then sort of takes the first word on the line as the name of a program and passes all the all the rest of the line as text into the program for the program to figure
Starting point is 00:29:13 out what to do with as arguments. And so by the time scripting was slightly more mature than the very first script. There was a convention that just like the first word on the line is the name of the program, the following words could be names of files, input.text, output.html, things like that. The next thing that happens is, oh, it would actually be really nice if we could have variables and especially parameters for scripts. Parameters are usually what starts this process. But now you have a problem because you can't just say the parameters are x, y, and z.
Starting point is 00:30:05 And so now we call, say, let's say, x is the input file and y is the output file. And let's forget about z for now. I have my program and I write program x, y. Well, that already has a meaning because that presumably means x itself is the file. It's a file name. it's not a variable name. And so the inventors of things like the Unix shell
Starting point is 00:30:35 and I'm sure job command language at IBM before that had to use something that made it clear to the script processor. Here is an X that is not actually the name of a file, which you just pass through to the program you're running. Here is an X that is the name of a variable. And when you're writing a script processor, you try to keep it as simple as possible. Because as certainly in the 50s and 60s, the thing that interprets the script was itself had to be a very small program because it had to fit in a very small part of memory.
Starting point is 00:31:22 And so saying, oh, just look at each character. And if you see a dollar sign, you jump to another section of the code and then you gobble up characters, say until the next space or something. And you say, that's the variable name. And so it was sort of invented as a clever way to make parsing of things that contain both variable and fixed parts, very easy in a very simple script processor. It also helps, even then it also helps the human author and the human reader of the script to quickly see, oh, 20 lines down in the script, I see a reference to xyz. Oh, it has a dollar in front of it. So now we know that xyz must be one of the parameters of the script. Well, this is fascinating. Several things to say, which is the leftovers from the simple script processor languages are now in code bases
Starting point is 00:32:26 like behind Facebook or behind most of the back end, I think PHP is probably still runs most of the back end of the internet. Oh yeah, I think there's a lot of it in Wikipedia too for example. It's funny that those decisions are not funny, it's fascinating that those decisions permeate through time. Just like biological systems, right? I mean, that the sort of the inner workings of DNA have been stable for, well, I don't know how long it was, like 300 million years, half a billion years. Yeah.
Starting point is 00:33:00 And there are all sorts of weird quirks there that don't make a lot of sense if you were to design a system like self-replicating molecules from scratch. Well, that system has a lot of interesting resilience. It has redundancy that results. Like it messes up in interesting ways that still is resilient when you look at the system level of the organism. Code doesn't necessarily have that computer programming code.
Starting point is 00:33:29 You'd be surprised how much resilience modern code has. I mean, if you look at the number of bugs per line of code, even in very well tested code that in practice works just fine. There are actually lots of things that don't work fine. And there are error correcting or self correcting mechanisms at many levels, including probably the user of the code. Well, in the end, the user who sort of is told, well, you got to reboot your your PC is part of that system. And a slightly less drastic thing is reload page, which we all know how to do without thinking about it when something weird happens. You try to reload a few times before you say, oh, there's something really weird.
Starting point is 00:34:28 Or try to click the button again if the first time doesn't work. Well yeah, that we should all have learned not to do that because that's probably just going to turn the light back off. Yeah, true. So do it three times. That's the right lesson. And I wondered how many people actually like the dollar sign. Like you said, it is documentation. So to me, it's whatever the opposite of synch
Starting point is 00:34:55 tactic sugar is syntactic poison. To me, it is such a pain in the ass that I have to type in a dollar sign. Also, super aerobro prone. So it's not self-documenting. It's a bug generating thing. It is a kind of documentation. That's the pro and the con is, it's a source of a lot of bugs. But actually, I have to ask you, this is a really interesting idea of bugs per line of code. If you look at all the computer systems out there from the code that runs nuclear weapons to the code that runs all the amazing companies that you've been involved with and not the code that runs Twitter and Facebook and Dropbox and Google and Microsoft, Windows and so on and we like laid out. When that be a cool cool table, bugs for line of code?
Starting point is 00:35:47 Let's put actual companies aside. Do you think we'd be surprised by the number we see there for all these companies? That depends on whether you've ever read about research that's been done in this area before. And I don't know, that the last time I saw some research like that, there was probably in the 90s and the research might have been done in the 80s. But the conclusion was across a wide range of different software, different languages, different companies, different development styles. The number of bugs is always, I think it's in the order of about one bug per thousand lines in sort of mature software that Interesting. As good as it gets.
Starting point is 00:36:45 Can't give you some facts here. There's a lot of newspapers. So you said mature software, right? So here's a report from a programming analytics company. Now this is from a developer perspective. Well, let me just say what it says, because this is very weird and surprising. On average, a developer creates 70 bugs per 1,000 lines of code.
Starting point is 00:37:12 15 bugs per 1,000 lines of code find their way to the customers. This is in software they've had. Oh, I was wrong by an order of an actual there. Fixing a bug takes 30 times longer than writing a line of code. That I can believe. Yeah.
Starting point is 00:37:28 75% of a developer's time is spent on debugging. That's for an average developer. They analyze this 15, 15, 15, 15, 100 hours a year. And you ask the loan, $113 billion to spend annually on identifying and fixing bugs. And I imagine this is marketing literature for someone who claims to have a golden bullet or a silver bullet that makes all that investment in fixing bugs go away, but that is usually
Starting point is 00:38:00 not going to happen. Well, they're referencing a lot of stuff, of course, but it is a page that is, you know, there's a contact us button at the bottom, presumably, if you just spend a little bit less than a hundred billion dollars, we're willing to solve the problem for you. Right. And there's also a report on stack exchange, a stack overflow and the exact same topic. But when I open it up at the moment, the page says stack overflow is currently offline for maintenance. Oh, that is ironic. Yes. By the way, their error page is awesome. Anyway.
Starting point is 00:38:36 I mean, can you believe that number of bugs? Oh, absolutely. Isn't that scary that 70 bucks per 1000 lines of code? So even 10 bucks per 1000 lines. Well, that's about one bug after every 15 lines and that's when you're first typing it in. Yeah, from a developer, but like how many bugs are going to be found? If you're typing it, well, the development process is extremely iterative. Typically, you don't make a plan for what software you're going to release a year from now. Well, the development process is extremely iterative. Yeah. Typically, you don't make a plan for what software you're going to release a year from now, and work out all the details because actually all the details themselves consist, they sort
Starting point is 00:39:18 of compose a program. And that being a program, all your plans will have bugs in them too, and inaccuracies. But what you actually do is, you do bunch of typing, and I'm actually really bad typist, that just I've never learned to type with 10 fingers. I need to use Well, I use all 10 of them, but not very well But I never I never too could tap in class and I never sort of corrected that so the first time I Seriously learned I had to learn the layout of a quality keyboard was actually in college in my first programming classes where we used punch cards.
Starting point is 00:40:09 And so with my two fingers, I sort of backed out my code. What's anyone give you a little coding demonstration? They'll have to produce like four lines of code They'll have to produce like four lines of code. And now see how many times they use the backspace key because they made a mistake. And some people, especially when someone else is looking will backspace over 20, 30, 40 characters to fix a typo earlier in a line. If you're
Starting point is 00:40:48 slightly more experienced, of course, you use your arrow buttons to go or your mouse to, but the mouse is usually slower than the arrows. But a lot of people, when they type a 20 character word, which is not unusual. And they realized they made a mistake at the start of the word. They backspace over the whole thing and then retype it. And sometimes it takes three, four times to get it right. So I don't know what your definition of bug is. Arguably mistyping a word and then correcting it immediately is not a bug. On the other hand, you already
Starting point is 00:41:27 do sort of lose time. And every once in a while, there's sort of a typo that you don't get in that process. And now you've typed like 10 lines of code and somewhere in the middle of it, you don't know where yet is a typo or maybe a thinko where you forgot that you had to initialize a variable or something. But those are two different things. And I would say, yes, you have to actually run the code to discover that typo. But forgetting to initialize a variable is a fundamentally different thing because that thing could go undiscovered. That depends on the language in Python, it will not. And sort of modern compilers are usually pretty good
Starting point is 00:42:11 at catching that even for C. So for that specific thing, but actually deeper, there might be another variable that his initialized, but logically speaking, the one you meant related. Yep. It's like name the same, but it's a different thing. And you forgot to initialize whatever, some counter or some some basic variable that
Starting point is 00:42:36 you use. I can tell that you've coded. Yes. By the way, I should mention that I use the Kinesis keyboard, which has the backspace under the thumb. And one of the biggest reasons I use that keyboard is because you realize in order to use the back space, I usually keyboard, you have to stretch your pinky out. And like the for most normal keyboards, the back space is under the pinky. And so I don't know if people realize the pain they go through in their life because of the backspace keeping so far away.
Starting point is 00:43:12 So with the canesas, it's right under the thumb seat, don't have to action move your hands, the backspace and the delete. And what do you do if you're ever not with your own keyboard and you have to use someone else a specific keyboard that has that standard layout. So first of all, it turns out that you can actually go your whole life always having a keyboard. So this, well, except for that little tablet that you're using, so we're not taking right now, right? Yeah, so it's very inefficient note-taking, but I'm not, I'm just looking stuff up, but in most cases, I would be actually using the keyboard here
Starting point is 00:43:49 Right now. I just don't anticipate you have to calculate how much typing do you anticipate if I anticipate quite a bit then I'll just I have a keyboard People with me and same same with I mean the embarrassing I've accepted being the weirder that I am, but, you know, when I go on an airplane and I anticipate to do programming or a lot of typing, I will have a laptop and I will pull out a cany-sis keyboard in addition to the laptop. And it's just, who I am, you have to accept who you are. But also it's a you know for a lot of people for me certainly there's a comfort space where there's a certain kind of setups that are maximize productivity and it's like some people have a warm blanket that they like
Starting point is 00:44:40 when they watch a movie. I like the kinesis keyboard, takes me to a place of focus. And I still, mostly, I'm trying to make sure I use the state of the art ID use for everything, but my comfort place, just like the Kinesis keyboard, is still E-Max. So I still use, I still, I mean, that's one of the debates I have with myself about everything from a technology perspective is how much to hold on to the tools you're comfortable with, versus how much to invest in using modern tools. And the signal that the community's provided with is the noisy one because a lot of people year to year get excited about new tools and
Starting point is 00:45:26 you have to make a prediction. Are these tools defining a new generation or something that will transform programming or is this just a fad that will pass? Certainly with JavaScript, frameworks, and front end and back end of the web, there's a lot of different styles that came and went. I remember learning what was it called? Action script. I remember for Flash, learning how to program and Flash, learning how to design, do graphic animation, all that kind of stuff in Flash, say with Java Applets. I remember creating quite a lot of Java Applets, thinking that this potentially defines the future of the web. And it did not.
Starting point is 00:46:06 Well, you know, in most cases like that, the particular technology eventually gets replaced. But many of the concepts that the technology introduced or made accessible first are preserved of course because yeah, we're not using Java applets anymore, but the notion of reactive web pages that sort of contain little bits of code that respond directly to
Starting point is 00:46:46 something you do like pressing a button or a link or hovering even, has certainly not gone away. And that those animations that were made painfully complicated with Flash, I mean, Flash was an innovation when it first came up and when it was replaced by JavaScript equivalence stuff, it was a somewhat better way to do animations, but those animations are still there. Not all of them, but sort of, again, there is an evolution and often so often with technology that the sort of the technology that was eventually thrown away or replaced was still essential to sort of get started. There wouldn't be jet planes without propeller planes. I bet you. But from a user perspective, yes, from the feature set, yes, but I, from a program perspective, it feels like all the time I've spent with action script, all the time I've spent with Java on the applet side for the GUI development.
Starting point is 00:47:59 Well, no, Java, I have to push back. That was useful. That, because it transfers, but the flash doesn't transfer. So some things you learn and invest time in. What, yeah, what, what you learned the skill you picked up learning action script was sort of it was, it was perhaps a super valuable skill at the time you picked it up. If you learned action script early enough, but that skill is no longer in demand. Well, that's the calculation you have to make when you're learning new things.
Starting point is 00:48:38 Like today, people started learning programming. Today, I'm trying to see what are the new languages to try, what are the new systems to try, what are the new ideas to try to keep improving. That's why we start when we're young, right? But that seems very true to me, that when you're young, you have your whole life ahead of you, and you're allowed to make mistakes. In fact, you should feel encouraged to do a bit of stupid stuff. Try not to get yourself killed or seriously maimed.
Starting point is 00:49:15 Try stuff that deviates from what everybody else is doing. Nine out of ten times, you'll just learn why everybody else is not doing that or why everybody else is doing it some other way and one out of ten times you sort of you discover something that's better or that's that somehow works. I mean there are all sorts of crazy things that were invented by accident, by people trying stuff together. That's great advice to try, read them stuff, make a lot of mistakes. Once you're married with kids, you're probably going to be a little more risk of hers because now there's more at stake and you've already hopefully had some time where you were experimenting
Starting point is 00:50:03 with crazy shit. I like how marriage and kids solidifies their choice of programming language. How does that? The Robert Frost poem with the road less taken, which I think is misinterpreted by most people. But anyway, I feel like the choices you make early on, especially if you go all in, they're going to define the rest of your life's trajectory in a way that like you basically are picking a camp. So you know, there's if you invest a lot in PHP, if you invest a lot in .NET, if you invest a lot in JavaScript, you're going to stick there. That's your life journey. It's very hard only as far as that
Starting point is 00:50:48 Technology remains relevant. Yes. I mean if if at age 16 you learn coding in C and By the time you're 26 C is like a dead language your 26 C is like a dead language, then there's still time to switch. There's probably some kind of survivor bias or whatever it's called in sort of your observation that you pick a camp because there are many different camps to pick. And if you pick .net, then then you can coast for the rest of your life because that technology is now so ubiquitous, of course, that it's even if it's if it's bound to die, it's going to take a very long time. Well, for me personally, I had a very difficult and in my own head brave leap that I had to take relevant to our discussion,
Starting point is 00:51:46 which is most of my life at programs in C&C++. And so having that hammer, everything looked like a nail. So I would literally even do scripting in C++. I would create programs that do script-like things. And when I first came to Google, and before then, it became already, before TensorFlow, before all of that, there was a growing realization that C++
Starting point is 00:52:13 is not the right tool for machine learning. We could talk about why that is. It's unclear why that is. A lot of things has to do with community and culture and how they're merges and stuff like that. But for me, they decided to take the leap to Python, like all out, basically switched completely from C++ except for a highly performant robotics applications. There's still a culture of C++ in this base of robotics.
Starting point is 00:52:42 That was a big leap. Like I had to, you know, like, like, people have like existential crises or midlife crises or whatever, yet to realize almost like walking away from a person you love. Because I was sure that C++ would have to be a lifelong companion. For a lot of problems, I would want to solve C++ would be there. And it was a question to say, well, that might not be the case. Because C++ is still one of the most popular languages in the world, one of the most used, one of the most dependent on. It's also still evolving quite a bit.
Starting point is 00:53:18 That is not a sort of a fossilizing community. They are doing great innovative work actually. A lot. But the sort of their innovations are hard to follow if you're not already a hardcore C++ user. Well, this was the thing. It pulls you in. It's a rabbit hole.
Starting point is 00:53:37 I was a hardcore. The all-meta programming, template programming. Like, I would start using the modern C++ as a develop, right? Not just the shared pointer and the garbage collection. That makes it easier for you to work with some of the flaws, but the detail, like the meta programming, the crazy stuff that's coming out there, but then you have to just empirically look and step back and say what language am I more productive in? Sorry to say what language do I enjoy my life with more and Readability and able to think through and all that kind of stuff that those questions are harder to ask when you already have a
Starting point is 00:54:20 loved one which in my case was C++. And then there's Python, like that meme, was the grass is greener on the other side. Am I just infatuated with a new, fad, new cool thing? Or is this actually going to make my life better? And I think a lot of people face that kind of decision. It was a difficult decision for me when I made it. At this time, it's an obvious switch if you're
Starting point is 00:54:45 into machine learning, but at that time, it wasn't quite yet so obvious. So it was a risk. And you know, you have the same kind of stuff with them. I still, because of my connection to WordPress, I still do a lot of back-end programming at PHP. And the question is, you know, no JS Python, do you switch to do you switch back end to any of those programming? There's the case for no JS for me. While more and more and more of the front end, it runs in JavaScript. And fascinating cool stuff is on this JavaScript. Maybe use the same programming language for the back end as well. The case for same program language for the backend as well.
Starting point is 00:55:26 The case for Python for the backend is, well, you're doing so much programming outside of the web in Python, so maybe use Python for the backend. And then the case for PHP, well, most of the web still runs at PHP. You have a lot of experience with PHP. Why fix something that's not broken? Those are my own personal struggles, but I think they reflect the struggles of a lot of people with different programming languages, with different problems that are trying to solve. It's a weird one.
Starting point is 00:55:57 And there's not a single answer, right? Because depending on how much time you have to learn new stuff, where you are in your life, what you're currently working on, who you want to work with, what communities you like, there's not one right choice. Maybe if you can look back 20 years, you can say, well, that whole D2 or through action script was a waste of time. But nobody could know that. So you can beat yourself up over that. You just need to accept that not every choice you make is going to be perfect. Maybe, sort of, keep a plan B in the back of your mind.
Starting point is 00:56:50 be sort of keep a plan B in the back of your mind, but don't overthink it. Don't try to, sort of, don't create a spreadsheet with like, where you're trying to estimate, well, if I learn this language, I expect to make $X million in a lifetime and if I learn that language I expect to make Y million dollars in a lifetime and which is higher and what which has more risk and where's the chance that it's like picking picking a stock Kind of kind of but I Think with stocks you can do diversifying your investment as good with productivity in life. Boy, that spreadsheet is possible to construct. Like if you actually carefully analyze what your interests in life are, what you think
Starting point is 00:57:40 you can maximally impact the world. There really is better and worse choices for programming language. They're not just about the syntax, but about the community, about where you predict the community's headed, what's large systems are programmed in that. But can you create that spreadsheet? Because that's sort of you're mentioning a whole bunch of inputs that go into that spreadsheet, where you have to estimate things that are very hard to measure and even harder. I mean, they're hard to measure retroactively and they're even harder to predict. Like, what is the better community? Well, better is one of those incredibly difficult words. What's better for you is not better for someone else. No, but we're not doing a public speech about what's better.
Starting point is 00:58:29 We're doing a personal spiritual journey. I can determine a circle of friends, circle one and circle two. And I can have a bunch of parties with one and a bunch of parties with two. And then write down or take a mental note of what made me happier. Right? And that, you know, you have, if you're a machine learning person, you want to say, okay, I want to build a large company that does, that is grounded in machine learning, but also has a sexy interface that has a large impact in the world.
Starting point is 00:59:01 What languages do I use? You look at what Facebook is using, you look at what Twitter is using, then you look at performance more newer languages like Rust, or you look at languages that have taken that most of the community uses in machine learning space that's Python. And you can like think through, you can hang out and think through it. And it's always an invest. And the the level of activity of the community is also really interesting, like you said, C++ and Python are super active in terms of the development of the language itself. But do you think that you can make objective choices there?
Starting point is 00:59:37 No, no, but there's a gut you build up. Don't you believe in that gut feeling of... Everything is very subjective, and yes, you most certainly can have a gut feeling and your gut can also be wrong That's why there are billions of people because they're not all right. I mean Clearly there are more people living in the Bay area who have plans to Sort of create a Google-sized company Then there's room in the world for Google-sized companies. And they're going to have to do it out in the market, the space.
Starting point is 01:00:10 And there's many more choices than just the programming language. Speaking of which, let's go back to the boat with the fisherman who's tuned out long ago. I thought the programmer, let's jump around and go back to see Python that we tried to define as the reference implementation. And one of the big things that's coming out in 3.11 was the right way to not- We tend to say 3.11 because it really was like, we went 3.8, 3.9, 3.10, 3.11, and we're planning to go up to 3.99.
Starting point is 01:00:42 99. What happens after 99? Probably just 3..100. One of my make it there. Okay. And go all the way to $4.20. I got it. Forever Python V3. We'll talk about four, but more for fun. So $3.11 coming out one of the big sexy things in it is it'll be much faster. So how of the big sexy things in it is it'll be much faster. So how did you beyond hiring a great team or working with a great team make it faster? What are some ideas that makes it faster? It has to do with simplicity of software versus performance. And so even though C is known to be a low level language, which is great for writing sort of a high performance language interpreter, when I originally started Python or C Python, I didn't expect there would be great success and fame in my future.
Starting point is 01:01:47 So I try to get something working and useful in about three months. And so I sort of, I cut corners. I borrowed ideas left and right when it comes to language design as well as implementation. I also wrote much of the code as simple as it could be. And there are like, there are many things that you can code more efficiently by adding more code. It's a bit of a time space, trade-off, where you can compute a certain thing from a small number of inputs.
Starting point is 01:02:39 And every time you get presented with a new input, you do the whole computation from the top. That can be simple looking code. It's easy to understand. It's easy to reason about that you can tell quickly that it's correct, at least in the sort of mathematical sense of correct, because it's implemented in C, maybe it performs relatively well,
Starting point is 01:03:07 but over time, as the requirements for that code and the need for performance go up, you might be able to rewrite that same algorithm using more memory, maybe remember previous results, so you don't have to recompute everything from scratch, like the classic example is computing prime numbers. Like, it's 10 a prime number. Well, you sort of, is it divisible by 2? Is it divisible by 3? Is it divisible by 4? And we go all the way to, is it divisible by 9? And it is not, well, actually 10 is divisible by 2, so there we stop, but say 11. It's divisible by 10.
Starting point is 01:03:58 The answer is 9. It's no, 10 times in a row. So now we know 11 is a prime number. On the other hand, if we already know that two, three, five, and seven are prime numbers, and you know a little bit about the mathematics of how prime numbers work, you know that if you have a rough estimate for the square root of eleven, you don't actually have to check is it divisible by four, or is it divisible by five? You'll all you have to check in the case of eleven is it divisible by 4 or is it divisible by 5? If you all you have to check in the case of 11 is it divisible by 2? Is it divisible by 3?
Starting point is 01:04:31 Because take 12. If it's divisible by 4, 12 divided by 4 is 3. So you should have come across the question, is it divisible by 3 first? So if you know, basically nothing about prime numbers except the definition, maybe you go for x from 2 through n minus 1 is n divisible by x. And then at the end, if you got all nodes for every single one of those questions, you know, oh, it must be a prime number. Well, the first thing is you can stop iterating
Starting point is 01:05:10 when you find a yes answer. And the second is you can also stop iterating when you have reached the square root of n, because you know that if it has a divisor larger than the square root, and also have a divisor larger than the square root, and also have a divisor smaller than the square root, then you say, oh, except for two, we don't need to butter with checking for even numbers, because all even numbers are divisible by two.
Starting point is 01:05:37 So if it's divisible by four, we would already have come across the question, is it divisible by two? And so now you go, special case,, is it divisible by two? And so now you go, special case, check, is it divisible by two? And then you just check three, five, seven, eleven. And so now you sort of reduced your search base by 50% again, by skipping all the even numbers it kept for two.
Starting point is 01:06:00 If you think a bit more about it, or you just read in your book about the history of math, one of the first algorithms ever written down, all you have to do is check, is it divisible by any of the previous prime numbers that are smaller than the square root? And before you get to a better algorithm than that, you have to have several PhDs in this creed math. So that's as much as I know. So, of course, that same story applies to a lot of other algorithms. String matching is a good example of how to come up with an efficient algorithm. Sometimes the more efficient algorithm is not so much more complex than the
Starting point is 01:06:45 inefficient one, but that's an art and it's not always the case. In the general cases, the more perform at the algorithm, the more complex it's going to be. There's a kind of trade-off. The simpler algorithms are also the ones that people invent first, because when you're looking for a solution, you look at the simplest way to get there first. And so if there is a simple solution, even if it's not the best solution, not the fastest or the most memory efficient or whatever, a simple solution and simple is fairly subjective, but mathematicians have also
Starting point is 01:07:29 thought about sort of what is a good definition for simple, in the case of algorithms. But the simpler solutions tend to be easier to follow for other programmers who haven't made a study of a particular field. And when I started with Python, I was a good programmer in general. I knew sort of basic data structures and new to C language pretty well. But there were many areas where I was only somewhat familiar with the state of the art. And so I picked, in many cases, the simplest way I could solve a particular sub-problem because when you're designing and implementing a language, you have to, like, you have many hundreds of little problems to solve. And you have to have solutions for every one of them
Starting point is 01:08:27 before you can sort of say, I've invented a programming language. First of all, so see Python. What kind of things does it do? It's an interpreter. It takes in this readable language that we talked about that is Python. What is this supposed to do? The interpreter basically, it's sort of a recipe for understanding recipes.
Starting point is 01:08:54 So instead of a recipe that says bake me a cake, we have a recipe for well, given the text of a program, how do we run that program? And that is sort of the recipe for building a computer. The recipe for the baker and the chef. What are the algorithmically tricky things that happen to be low hanging fruit that could be improved on? Maybe throughout the history of Python, but also now, how is it possible that 3.11 in year 2022, it's possibly gets such a big performance
Starting point is 01:09:32 improvement? We focused on a few areas where we still felt there was low hanging fruit. Yes, where we still felt there was low hanging fruit. The biggest one is actually the interpreter itself. And this has to do with details of how Python is defined. So I don't know if the fisherman is going to follow this story. He already jumped off the boat. He's this board. Yeah, stupid. Python is actually, even though it's always called an
Starting point is 01:10:07 interpreted language, it's, there's also a compiler in there. It just doesn't compile to machine code. It compiles to bytecode, which is sort of code for an imaginary computer that is called the Python interpreter. So it's compiling code that is more easily digestible by the interpreter or digestible at all. It is the code that is digested by the interpreter. That's the compiler. We tweaked very minor bits of the compiler.
Starting point is 01:10:35 Almost all the work was done in the interpreter. Because when you have a program, you compile at once, and then you run the code a whole bunch of times. Or maybe there's one function in the code that gets run many times. Now, I know that sort of people who know this field are expecting me to, at some point, say, we built a just in time compiler, Actually, we didn't. We just made the interpreter a little more efficient. What's a just in time compiler? That is a thing from the Java world, although it's now applied to almost all programming languages, especially
Starting point is 01:11:20 interpreted ones. So you see the components that, not like a just in time compiler, but it's a compiler that creates byte code that is then fed to the interpreter. And the compiler was there something interesting to say about the compiler. It's interesting. They haven't changed that tweet that at all or much. We changed some parts of the bytecode, but not very much. And so we only had to change the parts of the compiler where we decided that the breakdown of a Python program
Starting point is 01:11:52 in bytecode instructions had to be slightly different. But that didn't gain us the performance improvements. that didn't gain us the performance improvements. That performance improvements were like making the interpreter faster in part by sort of removing the fat from some internal data structures used by the interpreter, but the key idea is an adaptive specializing interpreter. The key idea is an adaptive specializing interpreter. Let's go. What is adaptive about it?
Starting point is 01:12:29 What is specialized about it? Well, let me first talk about the specializing part because the adaptive part is the second order effect. But they're both important. So bytecode is a bunch of machine instructions, but it's an imaginary machine. But the machine can do things like call of function, add two numbers, print a value. Those are sort of typical instructions in Python. And if we take the example of adding two numbers, actually in Python, the language, there's no such thing as adding two numbers.
Starting point is 01:13:11 There's just the compiler doesn't know that you're adding two numbers. You might as well be adding two strings or two lists or two instances of some user-defined class that happened to implement this operator called add. That's a very interesting and fairly powerful mathematical concept. It's mostly a user interface trick because it means that a certain category of functions can be written using a single symbol, the plus sign, and a bunch of other functions can be written using another single symbol, the multiply sign.
Starting point is 01:13:55 So, if we take addition, the way traditionally in Python the add bytecode was executed is pointers, pointers, and more pointers. So first, we have two objects. An object is basically a pointer to a bunch of memory that contains more pointers. Pointers all the way down. Well, not quite, but there are a lot of them. So to simplify a bit, we look up in one of the objects, what is the type of that object, and does that object type define an ad operation?
Starting point is 01:14:36 And so you can imagine that there is a sort of a type integer that knows how to add itself to another integer. And there is a type floating point number that knows how to add itself to another floating point number. And the integers and floating point numbers are sort of important, I think mostly historically, because in the first computers, you used the sort of the same bit pattern when interpreted as a floating point number, had a very different value than when interpreted as an integer. Can I ask a dumb question here? Please do. Given the basics of int and float and ad, who carries the knowledge of how to add two integers? Is it the integer? It's the type integer versus the type integer and
Starting point is 01:15:26 the type float. What about the operator? Is the operator just exist as a platonic form possessed by the integer? The operator is more like it's an index in a list of functions that the integer type defines. And so the integer type is really a collection of functions, and there is an add function, and there's a multiply function, and there are like 30 other functions for other operations. There's a power function for example. And you can imagine that in memory, there is a distinct slot for the add operations. Let's say the add operation is the first operation of a type and the multiply is the second operation of a type.
Starting point is 01:16:21 So now we take the integer type and we take the floating point type. In both cases, the ad operation is the first slot and multiplies the second slot. But each slot contains a function and the functions are different because the ad to integer's function because the add to integers function interprets the bit patterns as integers, the add to float function interprets the same bit pattern as a floating point number. And then there is the string data type, which again interprets the bit pattern as the address of a sequence of characters. There are lots of lies in that story, but that's sort of a basic idea.
Starting point is 01:17:14 I can tell, I can tell the fake news and the fabrication going on here at the table. But where's the optimization? Is it on the operators, is it different? So the optimization? Is it on the operators? Is it a different? So the optimization is the observation that in a particular line of code. So now you write your little Python program and you write a function and that function sort of takes a bunch of inputs
Starting point is 01:17:43 and at some point it adds two of the inputs together. Now I bet you, even if you call your function a thousand times, that all those calls are likely all going to be about integers, because maybe your program is all about integers, or maybe on that particular line of code where there's that plus operator, every time the program hits that line, the variables A and B that are being added together happen to be strings. And so what we do is instead of having this single byte code that says, here's an ad operation and the implementation
Starting point is 01:18:26 of add is fully generic. It looks at the object from the object it looks at the type, then it takes the type and it looks at looks up the function pointer, then it calls the function. Now the function has to be has to look at the other argument and it has to double check that the other argument has the right type. And then there's a bunch of error checking before it can actually just go ahead and add the two bit patterns in the right way. What we do is every time we execute an add instruction like that, We keep a little note of in the end, after we hit the code that did the addition for a particular type, what type was it? And then after a few times through through that code if it's the same type all the time.
Starting point is 01:19:27 We say, oh, so this add operation, even though it's the generic add operation, it might as well be the add integer operation. And add integer operation is much more efficient because it just says, assume that A and B are integers, do the addition operation, do it right there in line, and produce the result. And the big lie here is that in Python,
Starting point is 01:19:58 even if you have great evidence that in the past it was always two integers that you were adding. At some point in the future, that same line of code could still be hit with two floating points or two strings, or maybe a string and an integer. That's not a great lie. That's just the fact of life. I didn't account for what should happen in that case in the way I told the story. There is some accounting for that. And so what we actually have to do is, when we have the ad integer operation,
Starting point is 01:20:33 we still have to check are the two arguments in fact integers. We applied some tricks to make those checks efficient and we know statistically that the outcome is almost always, yes, they were, they are both integers. And so we quickly make that check and then we proceed with the sort of add integer operation. And then there is a fallback mechanism
Starting point is 01:21:01 where we say, oops, one of them wasn't an integer. Now we're going to pretend that there was just the fully generic ad operation. We wasted a few cycles believing it was going to be two integers and then we had to back up. But we didn't waste that much time and statistically and statistically, most of the time, basically we're sort of hoping that most of the time we guess right, because if it turns out that we guessed wrong too often, or we didn't have a good guess at all, things might actually end up running a little slower.
Starting point is 01:21:42 So, someone with arms with this knowledge and a copy of the implementation, someone could easily construct a counter example where they say, oh, I have a program and now it runs five times as slow in Python 311 than it did in Python 310. But that's a very unrealistic program. That's just like an extreme fluke. It's a fun reverse engineering task, though. So there's people like fun, yes. So there's some presumably heuristic of what defines a momentum of saying, you know, you seem to be working adding two integers, not two generic
Starting point is 01:22:27 types. So how do you figure out that heuristic? I think that the heuristic is actually we assume that the weather tomorrow is going to be the same as the weather today. So you don't need two days of the weather? No. That is already so much better than then then then we're guessing randomly that's so how do you find this idea? Hey, I wonder if instead of adding to generic types, we start assuming that the weather tomorrow is the same as the weather today. Where do you find the idea for that? Because that ultimately, for you to do that, you have to kind of understand how people are using the language, right?
Starting point is 01:23:12 Python is now the first language to do a thing like this. This is a fairly well-known trick, especially from other interpreted languages that had reason to be sped up. We occasionally look at papers about HHVM, which is for Facebook's efficient compiler for PHP. There are tricks known from the JVM and sometimes it just comes from academia. So the trick here is that the type itself doesn't, the variable doesn't know what type it is. So this is not a statically typed language where you can, you can get support to have a shortcut to saying its ints. There's this trick that is especially important for for interpretive languages with dynamic typing because if, if the compiler could read in the source,
Starting point is 01:24:07 these x and y that we're adding are integers, the compiler can just insert a single add machine code that hardware machine instruction that exists on every CPU and did-o for floats. But because in Python, you don't generally declare the types of your variables. You don't even declare the existence of your variables. They just spring into existence when you first assign them, which is really cool and sort of helps those beginners because there is less bookkeeping.
Starting point is 01:24:44 They have to learn how to do before they can start playing around with code. But it makes the interpretation of the code less efficient. And so we're trying to make the interpretation more efficient without losing the the super dynamic nature of the language. That's always the challenge. 2.5 got the PEP-44 type hints. What is type hinting and is it used by the interpreter, the hints, or is it just syntactic sugar? So the type hints is an optional mechanism that people can use,
Starting point is 01:25:28 and it's especially popular with sort of larger companies that have very large code bases written in Python. Do you think of it as almost like documentation saying these two variables are this type? More than documentation. I mean, so it is a sub language of Python where you can express the types of variables. So here is a variable and it's an integer. And here's an argument to this function and it's a string. And here is a function that returns a list of strings.
Starting point is 01:26:00 But that's not checked when you run the code. But exactly, there is a separate piece of software called a static type checker that reads all your source code without executing it and thinks long and hard about what it looks from just reading the code that code might be doing and double checks if that makes sense if you take the types as annotated into account. So this is something you're supposed to run as you develop. It's like a linter. Yeah, linter. That's definitely a development tool, but the type annotations currently are not used for speeding up the interpreter. And there are a number of reasons many people don't use them. Even when they do use them,
Starting point is 01:26:52 they sometimes contain lies where the static type checker says, everything's fine. I cannot prove that this integer is ever not an integer, but that runtime somehow someone manages to violate that assumption. And the interpreter ends up doing just fine. If we started enforcing type annotations in Python, many Python programs would no longer work.
Starting point is 01:27:22 And some Python programs wouldn't even be possible because they're too dynamic. And so we made a choice of not using the annotations. There is a possible future where eventually three, four, five releases in the future, we could start using those annotations to sort of provide hints because we can still say, well, the source code leads us to believe that these X and Y are both integers, and so we can generate an add integer instruction. But we can still have a fallback that says, But we can still have a fallback that says, oh, if somehow the code at runtime provided something else, maybe it provided two decimal numbers, we can still use that generic ad operation as a fallback. But we're not there.
Starting point is 01:28:19 Is there currently a mechanism or do you see something like that? We can almost add like an assert inside a function that says, please check that my type hints are actually mapping to reality. Sort of like insert manual static typing. There are third party libraries that are in that business. It's possible to do that kind of thing. It's possible for third-party library to take a hint and enforce it.
Starting point is 01:28:50 Well, yes. But what we actually do is, and I think this is a fairly unique feature in Python, the type hints can be introspective at runtime. So while the program is running, they mean Python is a very introspectable language. You can look at a variable and ask yourself, what is the type of this variable? And if that maybe that variable happens to refer to a function, you can ask, what are the arguments to the function? And nowadays, you can also ask, what are the
Starting point is 01:29:26 type annotations for the function? So the type annotations are there inside the variable as it's at runtime. They're mostly associated with the function object, not with each individual variable, but you can sort of map from the arguments to the variables. And that's what a third party library can help. Exactly. And the problem with that is that all that extra runtime type checking is going to slow your code down instead of speed it up. I think the reference this sales pitchy blog post that says 75% of developers time is spent on debugging, I would say that in some cases
Starting point is 01:30:06 that might be okay. It might be okay to pay the cost of performance for the catching of the types, the type errors. And in most cases, doing it statically before you ship your code to production is more efficient than doing it at runtime piecemeal. Yeah. Can you tell me about NYPY MyPy project? What is it? What's the mission? And in general, what is the future of static typing in Python? Well, so MyP pie was started by a finished developer, Yucca Leto-Selo. So many cool things out of Finland, I gotta say. Just that part of the world. I guess people have nothing better to do if it goes long cold winters. I don't know. I think Yucca lived in England when he invented that stuff actually, but my pie is the original static type checker for Python.
Starting point is 01:31:08 And the type annotations that were introduced with PEP 484 were sort of developed together with the static type checker. And in fact, Yuka had first invented a different syntax that wasn't quite compatible with Python. And Yuka and I sort of met at a Python conference in, I think, in 2013. And we sort of came up with a compromised syntax that would not require any changes to Python and that would let my pie sort of be an add on static type checker for Python.
Starting point is 01:31:53 Just out of curiosity, it was like double colon or something. What was the proposing that would break Python? I think he was using angular brackets for types like in C++ or Java generics. Yeah, you can't use angular brackets in Python. It'll be too tricky for time. Well, the key thing is that we already had a syntax for annotations. We just didn't know what to use them for yet. So type annotations were just the sort of most logical
Starting point is 01:32:27 thing to use that existing dummy syntax for. But there was no there was no syntax for defining generics directly syntactically in the language. My pie literally meant my version of Python, where my it refers to Yucca. He had a parser that translated my pie into Python by like doing the type checks and then removing the annotations and all the angular brackets from the positions where he was using them. But a pre-processor model doesn't work very well with the typical workflow of Python development projects. That's funny. I mean, that could have been another major split if it became successful. Like if you watch TypeScript versus JavaScript, it's like a split in the community over Types, right? That seems to be stabilizing now.
Starting point is 01:33:30 It's not necessarily a split. There are certainly plenty of people who don't use TypeScript, but just use the original JavaScript notation, just like there are many people in the Python world who don't use type annotations and don't use static type checkers. Now I know, but there is a bit of a split between TypeScript and JavaScript, old school JavaScript, EES, whatever. Well, in the JavaScript world, transpilers are sort of the standard way of working anyway, which is why TypeScript being a transpiler itself is not a big deal.
Starting point is 01:34:06 And transpires for people don't know. It's the exact thing you said with my advice. It's the code, I guess you call it pre-processing code that translates to one language to the other. And that's part of the culture, part of the workflow of the JavaScript community. So that's right. At the same time, an interesting development in the JavaScript slash TypeScript world at the moment is that there is a proposal under consideration. It's only a stage one proposal that proposes to add a feature to JavaScript where just like Python, it will ignore certain syntax when running the JavaScript code. And what it ignores is more or less a superset of the TypeScript annotation syntax.
Starting point is 01:34:57 Interesting. So that would mean that eventually if you wanted to, you could take TypeScript and you could shove it directly into JavaScript interpreter without translation. The interesting thing in the JavaScript world, at least the Web browser world, the web browsers have changed how they deploy and they sort of update their JavaScript engines much more quickly than they used to in the early days. And so there's much less of a need for translation in JavaScript itself. Because most browsers just support the most recent version of ECMO script, just an attention of attention. If you were recommend somebody use a thing,
Starting point is 01:35:48 would you recommend TypeScript or JavaScript? I would recommend TypeScript, just because of the strictness of the typing. It's an enormously helpful extra tool that helps you sort of keep your head straight about what your code is actually doing. I mean, it helps with editing your code, it helps with ensuring that your code is not too incorrect. And it's actually quite compatible with JavaScript. Never mind this syntactic sort of hack that is still years in the future. But any library that is written in pure JavaScript can still be used from TypeScript programs.
Starting point is 01:36:37 And also the other way around, you can write a library in TypeScript and then export it in a form that is totally consumable by JavaScript. That sort of compatibility is sort of the key to the success of TypeScript. Yeah, just to look at it is almost like a biological system that's evolving. It's fascinating to see JavaScript evolve the way it does. Well, maybe we should consider that biological systems are just engineering systems, too, right? Yes. Just very advanced with more history. But it's almost like the most visceral in the JavaScript world because there's just so much code written in JavaScript that for its history was messy. If you talk about bugs per line of code, I just feel like JavaScript eats the cake or whatever the terminology is. It beats Python by a lot
Starting point is 01:37:34 in terms of the number of bugs, meaning like way more bugs in JavaScript. And then the, obviously, the browsers are developing. I mean, just there's so much active development. It feels a lot more like evolution Where a bunch of stuff is born and dies and this experimentation and debates versus Python is more All that stuff is happening, but there's just a longer history of stable working giant software systems written in Python versus JavaScript is just a giant. Beautiful. I would say mess of code. It's very different culture and to some extent differences in culture are random, but to some extent the differences have to do with the environment. And the fact that JavaScript is primarily the language for developing web applications, especially the client side, and the fact that it's basically the only language for developing web applications,
Starting point is 01:38:39 makes that community sort of just have a different nature than the community of other languages. Plus the graphical component and the fact that they're deploying it on all kinds of shapes of screens and devices and all that kind of stuff, it just creates a beautiful chaos. Anyway, back to my pie. So what, okay, you met you talked about a syntax that could work Where does it currently stand? What's the future static typing and Python? It is still controversial, but it is much more accepted than when my pie and pep 484 were young What's the connection between pep 4844 type hints and my pi.
Starting point is 01:39:26 My pi was the original static type checker. So it might by quickly evolved from Yuka's own variant of Python to a static type checker for Python and sort of PEP-484, that was it like a very productive year where like many hundreds of messages were exchanged, debating the merits of every aspect of that PEP. And so my PEP is a static type for Python. It is itself written in Python. Most additional static typing features that we introduced in the time since 36 were also prototyped through my pi. My pi being an open source project with a very small number of maintainers. It was successful enough that people said this static type checking stuff for Python is actually worth an investment for our company. But somehow they chose not to support
Starting point is 01:40:40 making mypy faster, say, or adding new features to my pie, but both Google and Facebook and later Microsoft developed their own static type checker. I think Facebook was one of the first they decided that they wanted to use the same technology that they had successfully used for HHVM. Because they had a bunch of compiler writers and sort of static type checking experts who had written the HHVM compiler. And it was a big success within the company. And they had done it in a certain way.
Starting point is 01:41:26 They wrote a big, highly parallel application in an obscure language named OCaml, which is apparently mostly very good for writing static typecheckers. Interesting. I have a lot of questions about how to write a static type checker then. That's very confusing. Facebook wrote their version and they worked on it in secret for about a year and then they came clean and went to open source. Google in the meantime was developing something called PyType which was mostly interesting because as you may have heard,
Starting point is 01:42:05 they have won gigantic Mono repo. So all the code is checked into a single repository. Facebook has a different approach. So Facebook developed Pyre, which was written in OCaml, which worked well with Facebook's development workflow. Google developed something they called Pytip, which was actually itself written in Python. It was meant to fit well in their static type checking needs in Google's gigantic Mono repo. Google Google has in one giant got it. So
Starting point is 01:42:46 the just to clarify this static type checker Philosophically is a thing that's supposed to exist outside of the language itself and it's just a workflow Like a debugger for the program. It's a linter for people who don't know a linter Maybe you can correct me, but it is a thing that runs the code continuously pre-processing to find issues based on style, documentation. I mean, there's all kinds of linters, right? It can check that what usual things there's a linter do. Maybe check that you haven't too many characters in a single line. Linter's often do static analysis where they try to point out things that are likely mistakes, but not incorrect according to the language specification.
Starting point is 01:43:35 Like, maybe you have a variable that you never use. For the compiler, that is valid. You might be planning to use it in a future version of the code, and the compiler might just optimize it out, but the compiler is not going to tell you, hey, you're never using this variable. A Linter will tell you that variable is not used. Maybe there's a typo somewhere else where you meant to use it, but you accidentally use something else, or there are a number of sort of common scenarios. And a Linter is often a big collection of little heuristics where by looking at the combination of how your code is laid out, maybe how it's indented, maybe the common structure, but also just things like definition of names,
Starting point is 01:44:29 use of names, it'll tell you likely things that are wrong. And in some cases, linters are really style checkers. For Python, there are a number of linters that check things like, do you use the Pep8 recommended naming scheme for your functions and classes and variables? Because classes start with an uppercase and the rest starts with a lower case.
Starting point is 01:44:57 There's differences there. And so the linter can tell you, hey, you have a class whose first letter is not an uppercase letter. And that's just, I've just find it annoying. If I wanted that to be an uppercase letter, I would have typed an uppercase letter. But other people find it very comforting that if the Linter is no longer complaining about their code that they have followed all the style rules, maybe it's a fast way for a new developer joining a team to learn the style
Starting point is 01:45:27 rules, right? Yeah, there's definitely that. But the best use of a limter is probably not so much to sort of enforce team uniformity, but to actually help developers catch bugs that the compilers for whatever reason don't catch. And there's lots of that in Python. And so, but a static type checker focuses on a particular aspect of the limiting, which I mean, my pie doesn't care how you name your classes and variables. But it is meticulous about when you say that it was an integer here and you're passing a string there, it will tell you, hey, that string is not an integer. So some things wrong, either you were incorrect when
Starting point is 01:46:19 you said it was an integer or you're incorrect when you're passing it to string. If this is a race of static type checkers, if somebody winning, as you said, it's interesting that the companies didn't use to invest in this centralized development of my pie. Is there a future for my pie? What do you see as that? Well, one of the companies went out and everybody uses
Starting point is 01:46:44 like a pie type, whatever Google is called. Well, Microsoft is hoping that Microsoft's horse in that race called pi right is going to win. Pi right, right? Like RIG HD? Correct. Yeah, my, all my word processors tend to typo correct that as pyride the name of the I don't know what it is
Starting point is 01:47:10 Some kind of semi-precious metal. Oh, right. I love it. Okay, so okay, that's the microsoft hope, but it okay So let me ask the question a different way is there going to to be ever a future where the static type checker gets integrated into the language? Nobody is currently excited about doing any work towards that. That doesn't mean that five or 10 years from now, the situation isn't different. The situation isn't different. At the moment, all the static type checkers still evolve at
Starting point is 01:47:54 a much higher speed than Python and its annotation syntax evolve. You get a new release of Python once a year. Those are the only times that you can introduce new annotations syntax. There are always people who invent new annotation syntax that they're trying to push. And worse, once we've all agreed that we are going to put some new syntax in, we can never take it back. At least a sort of deprecating and existing feature takes many releases because you have to assume that people started using it as soon as we announced it. And then you can't take it away from them
Starting point is 01:48:38 right away. You have to start telling them, well, this will go away, but we're not going to tell you that it's an error yet. And then later it's going to be a warning. And then eventually three releases in the future. Maybe we remove it. On the other hand, the typical static type checker still has a release like like every month, every two months, certainly many times a year. Some type checkers also include a bunch of experimental ideas that aren't official standard Python syntax yet. The static type checkers also just get better at discovering things that sort of are unspecified by the language, but that sort of could make sense. And so each static type checker actually has it's sort of strong and weak points.
Starting point is 01:49:37 So it's cool. It's like a laboratory of experiments. Yeah. Microsoft is going on and you get to see. And you see that everywhere, right? Because there is not one single JavaScript engine either. There is one in Chrome. There is one in Safari. There is one in Firefox. But that said, you said there's not interest. I think there is a lot of interest in type hinting, right?
Starting point is 01:50:01 In the PEP 484. Actually, like how many people use that? Do you have a sense? How many people use? Because it's optional, it's a sugar. I can't put a number on it, but from the number of packages that do interesting things with it at runtime and the fact that there are,
Starting point is 01:50:21 like now, three or four very mature type checkers that each have their segment of the market. And then there is a pie charm, which has a sort of more heuristic based type checker that also supports the same syntax. My assumption is that many, many people developing Python software professionally for some kind of production situation are using a static type checker, especially anybody who has a continuous integration
Starting point is 01:50:56 cycle probably has one of the steps in there, they're testing routine that happens for basically every commit is run a static type checker. And in most cases, that will be my pie. So I think it's pretty popular topic. According to this web page, 20 to 30% of Python, 3 code bases are using type hints Wow, I wonder how they measured that did they just scan all of GitHub? Yeah, that's what it looks like. Yeah, they did a quick sent not all of but like a random sampling
Starting point is 01:51:40 So you mentioned pie charm. Let Let me ask you the big subjective question. What's the best IDE for Python? And you're extremely biased now that you're with Microsoft. Is it PyCharm VS Code Vim or EMEX? Historically, I actually started out with using Vim, but when it was still called VI. For a very long time, I think from the early 80s to, I'd say, two years ago, I was EMEX user. Nice. Between, I'd say, 2013 and 2018, I dabbled with PyCharm, mostly because it had a couple
Starting point is 01:52:33 of features. I mean, PyCharm is like deriving an 18 wheeler truck whereas E-Max is more like driving a you're comfortable Toyota car. That's that you've had for a hundred thousand miles and you know what every little rattle of the car means. I was very comfortable in E-Max but there were certain things it couldn't do, it wasn't very good at that sort of, at least the way I had configured it, I didn't have very good tooling in Emacs for finding the definition of a function. Got it. When I was at Dropbox exploring a 5 million line Python code base, just grapping all that code for where there, where is there a class, Fubar, well, turns out that if you grab all 5 million lines of code, there are many classes with the
Starting point is 01:53:33 same name. And so PyCharm, sort of once you fired it up and once it's indexed, your repository was very helpful. But the soon as I had to edit code, I would jump back to Emex and do all my editing there because I could type much faster and switch between files. When I knew which file I wanted much quicker
Starting point is 01:53:59 and I never really got used to the whole PyCharm user interface. Yeah, I feel torn in that same kind of way because I've used pie charm off it on exactly in that same way. And I feel like I'm just being an old grumpy man for not learning how to quickly switch between files and all that kind of stuff. I feel like that has to do with shortcuts has to do with, I mean, you just have to get accustomed just like with touch typing. Yeah, you have to just want to learn that. I mean, if you don't need it much, you don't need
Starting point is 01:54:29 touch typing either. You can type with two fingers just fine in the short term, but in the long term, your life will become better psychologically and productivity-wise if you learn how to type with 10 fingers. If you do a lot of keyboard input. Before everyone emails and stuff, right? Like you look at the the next 20, 30 years of your life, you have to anticipate where technology is going. Do you want to invest in handwriting notes? Probably not. More and more people are doing typing versus handwriting notes. So you can anticipate that. So there's no reason to actually practice handwriting. There's more reason to practice typing. You can actually estimate back to the spreadsheet, the number of paragraphs, sentences, or words you write for the rest
Starting point is 01:55:17 of your life. You probably, you probably go again with the spreadsheet of my life. Yes. I mean, all of that is not actual, like, converted to a spreadsheet, but it's a gut feeling. Like, I have the same kind of gut feeling about books. I've almost exclusively switched to Kindle now for e-book readers, even though I still love and probably always will, the smell, the feel, the physical book. And the reason I switched to Kindle is like, all right, well, this is really paving the future is going to be digital in terms of consuming books and content of that nature. So you should get, you know, you should let your brain get
Starting point is 01:55:59 accustomed to that experience. And that's anyway, it feels like pie charm or VS code. I think pie charm is the most sophisticated feature full Python ID. It feels like I should probably at some point very soon switch entire like I'm not allowed to use anything else for Python than this ID or VS code. It doesn't matter, but walk away from EMACs for this particular application. So I think I'm limiting myself in the same way that using two fingers for typing is limiting myself. This is a therapy session. This is not even a answer. But I'm sure a lot of people are thinking this way. I'm not going to stop you. I think that sort of everybody has to decide for themselves which one they want to invest more time in.
Starting point is 01:56:50 I actually ended up giving VS Code a very tentative try when I started out at Microsoft and really liking it. And it sort of, it took me a while before I realized why that was. And I think that actually the founders of VS Code may not necessarily agree with me on this. But to me, VS Code is, in a sense, the spiritual successor of EMAX. Because as you probably know, as an old EMAX hack, the key part of EMAX is that it's mostly written in Lisp. And that new features of EMAX usually update all the Lisp packages and add new list packages. And oh yeah, there's also some very obscure thing improved in the part that's not in list, but that's usually not why you would upgrade to a new version of Emax.
Starting point is 01:57:59 There's a core implementation that sort of can read a file and it can put bits on the screen and it can manage memory and buffers. And then what makes it an editor full of features is all the list packages. And of course the design of how the list packages interact with each other and with that sort of that base layer of the core immutable engine. But almost everything in that core engine in EMAX case can still be overridden or replaced. And so VS Code has a similar architecture where there is like a base engine that you have no control over. I mean, it's open source, but nobody except the people who work on that part changes it
Starting point is 01:58:59 much. And it has sort of a package manager and a whole series of interfaces for packages and an additional series of conventions for how packages should interact with the lower layers and with each other. And powerful primitive operations that let you move the cursor around or select pieces of text or delete pieces of text or interact with the keyboard and mouse and whatever peripherals you have. And so the extreme extensibility and the package ecosystem that you see in VS Code is a mirror of very similar architectural features in EMAX.
Starting point is 01:59:51 Well, I'll have to give it a serious try because as far as the hype and the excitement in the general programming community VS Code seems to dominate. The interesting thing about PyCharm and what is it, PHPStorm, which are these JetBrains specific IDs that are designed for one programming language. It's interesting to, when an ID is specialized, right?
Starting point is 02:00:18 They're usually actually just specializations of IntelliJ, because underneath it's all the same editing engine with different veneer on top. Where in VS Code many things you do require loading third-party extensions. In pie charm, it is possible to have third-party extensions, but it is a struggle to create one. Yes, we need. It's not part of the culture, all that kind of stuff. Yeah, I remember that might have been five years ago or so, we were trying to get some better MyPie integration into PyCharm. Because MyPi is sort of, Py from tooling and PyCharm had its own
Starting point is 02:01:13 type checking, heuristic thing that we wanted to replace with something based on MyPi, because that was what we were using in the company. And for the guy who was writing that by charm extension, it was really a struggle to sort of find documentation and get the development workflow going and debug his code and all that.
Starting point is 02:01:40 So that was not a pleasant experience. Let me talk to you about parallelism in your post titled reasoning about a sink I owe some of four. You talk about a fast food restaurant Silicon Valley that has only one table. Is this a real thing? I just wanted to ask you about that. Is that just like a metaphor you're using or is that an actual restaurant in Silicon Valley? It was it was a metaphor of course.
Starting point is 02:02:10 I can imagine such a restaurant. So for people who don't then read the thing you should you should, but it was a idea of a restaurant where there's only one table and you show up one at a time and they are prepared and I actually looked it up and there is restaurants like this throughout the world. And it just seems like a fascinating idea. You stand online, you show up, there's one table, they ask you all kinds of questions that cook just for you. That's fascinating. It sounds like you'd find places like that in Tokyo. It sounds like a very Japanese thing. Or in the Bay Area, there are pop-up places that probably more or less work like that. But I've never eaten at such a place. The fascinating thing is you propose it to fast food.
Starting point is 02:02:50 This is all for burger. It was one of my rare, sort of, more literary or poetic moments where I thought I'll just open with a crazy example to catch your attention. And the rest is very dry stuff about locks and semaphores. And how a semaphore is a generalization of a lock. Well, it was very poetic and well delivered. And it actually made me wonder if it's real or not because you don't make that explicit. And it feels like it could be true. And in fact, I wouldn't be surprised if somebody like listens to this and knows exactly a restaurant like this in Silicon Valley. Anyway, can we step back and can you just talk about parallelism, concurrency, threading, asynchronous, all of these different
Starting point is 02:03:36 terms? What is it? So high philosophical level. The fisherman is back in the boat. Well, the idea is if the fisherman has two fishing rods, since fishing is mostly a matter of waiting for a fish to nibble. Well, it depends on how you do it, actually. But if you're doing the style of fishing where you throw it out and then you let it sit for a while until maybe you see a nibble. One fisherman can easily run two or three or four fishing rods. And so as long as you can afford the equipment,
Starting point is 02:04:13 you can catch four times as many fish by a small investment in four fishing rods. And so since your time, you sort of say you have all Saturday to go fishing. If you can catch four times as much fish, you have a much higher productivity. And that's actually, I think, how deep sea fishing is done. You could just have a rod and you put in the hole so you can have many rods.
Starting point is 02:04:37 What is there an interesting difference between parallelism and concurrency and asynchronous? Is there one subset of the other to you? Like, how do you think about these terms? In the computer world, there is a big difference when people are talking about parallelism, like a parallel computer, that's usually really several complete CPUs that are sort of tied together and share something like memory or an I-O bus. Concurrency can be a much more abstract concept where you have the illusion that things happen simultaneously, but what the computer actually does is it spends a little time running some this program for a while, and then it spends some time running that program for a while, and then spending some time for the third program
Starting point is 02:05:38 for a while. So parallelism is the reality and concurrency is part reality part illusion. Yeah, parallelism typically implies that there is multiple copies of the hardware. You write that implementing synchronization primitives is hard in that blog post. And you talk about locks and semaphores. Why is it hard to implement synchronization primitives? before is, why is it hard to implement synchronization permittance? Because at the conscious level, our brains are not trained to sort of keep track of multiple things at the same time. Like, obviously, you can walk and chew gum at the same
Starting point is 02:06:19 time, because they're both activities that require only a little bit of your conscious activity. But try balancing your checkbook and watching a murder mystery on TV. You'll mix up the digits or you'll miss an essential clue in the TV show. So what is the matter that the programmer, the human is bad? Because the programmer is at least with a current state of the art is responsible for writing the code correctly. And it's hard enough to keep track of a recipe that you just execute one step at a time. Chop the carrots, then peel the potatoes, mix the icing. You need your whole brain when you're reading a piece of code, what is going on? Okay, we're loading the number of mermaids in variable A and the number of more men in variable B. And now we take the average or whatever.
Starting point is 02:07:31 I like. We're just jumping from metaphor to metaphor. I like it. You have to keep in your head. What is in A? What is in B? What is in C? Hopefully you have better names. And that is challenging enough. hopefully you have better names. And that is challenging enough. If you have two different pieces of code that are sort of being executed simultaneously, whether it's using the parallel or the concurrent approach.
Starting point is 02:08:01 If like A is the number of fishermen and B is the number of programmers. But in another part of the code, A is the number of mermaids and B is the number of merman. And somehow that's the same variable. If you do it sequentially, if first you do your mermaids, more people computation and then you do your people in the boat computation. It doesn't matter that the variables are called A and B, and that is literally the same variable, because you're done with one use of that variable. But when you mix them together, suddenly the number of more people replaces the number of fishermen, and your computation goes dramatically wrong.
Starting point is 02:08:45 And there's all kinds of ordering of operations that could result in the assignment of those variables, and so you have to anticipate all possible orderings. And you think you're smart, and you'll put a lock around it. And in practice, in terms of bugs per line of per a thousand lines of code. This is an area where everything is worse. So a lock is a mechanism by which you forbid only one chef can access the oven at a time. Something like that. And then some of fours allow you to do what multiple ovens. That's not a bad idea because if you're sort of, if you're preparing, if you're baking cakes
Starting point is 02:09:29 and you have multiple people, all baking cakes, but there's only one oven. Yeah. Then maybe you can tell that the oven is in use, but maybe it's preheating. And so you have to, maybe you make a sign that says, oven in use, and you flip the sign over and it says oven is free when you're done baking your cake. That's a lock. That's sort of
Starting point is 02:09:52 and what do you do when you have two ovens or maybe you have ten ovens? You can put a separate sign on each oven or maybe you can sort of someone who comes in wants to see at a glance and maybe there's an electronic sign that says there are still five ovens available. Or maybe there are already three people waiting for an oven so you can't... If you see an oven that's not in use, it's already reserved for someone else who got in line first. And so what the restaurant metaphor was trying to explain. Yeah.
Starting point is 02:10:32 So your now tasks you're sitting as a designer Python with a team of brilliant court developers and have to try to figure out to what degree can any of these ideas be integrated and not. So maybe this is a good time to ask, what is a sync I.O. and how has it evolved since Python 3.4? Well, yeah. So we had this really old library for doing things concurrently, especially things that had to do with I.O. and networking I.O. was especially a sort of a popular topic. And in the Python standard library, we had a brief period where there was lots of development. And I think it was late 90s, maybe early 2000s. And like, two little modules were added
Starting point is 02:11:30 that were the state of the art of doing asynchronous IO, or sort of non-blocking IO, which means that you can keep multiple network connections open and sort of service them all in parallel, like a typical web server does. So I always input an app with you writing either to the network or read it from the network connection or reading and writing to a hard drive, the story, also possible. And you can do the ideas you could do to multiple while also doing computation.
Starting point is 02:12:02 So running some code that does some fancy stuff. Yeah, like when you're writing a web server, when a request comes in, a user, the sort of needs to see a particular web page, you have to find that page maybe in the database and format it properly and send it back to the client. And there's a lot of waiting, waiting for the database, waiting for the network, and so you can handle hundreds or thousands or millions of requests concurrently on one machine.
Starting point is 02:12:33 Anyway, waste of doing that in Python were kind of stagnated. I forget it might have been around 2012, 2014, when someone for the umpteenth time actually said, these async chat and async core modules that you have in the standard library are not quite enough to solve my particular problem. Can we add one tiny little feature? And everybody said, no, that stuff is not too to but you're not supposed to use that stuff right your own using
Starting point is 02:13:10 Third-party library and then everybody started a debate about what the right third-party library was and somehow I felt that there was actually a queue for well, maybe we need a better state of the art module in the standard library for multiplexing input output from different sources. You could say that it spiraled out of control a little bit. It was at the time, it was the largest Python enhancement proposal that was ever proposed.
Starting point is 02:13:44 And you were deeply involved with that. At the time, I was very much involved with that. I was like the lead architect. I ended up talking to people who had already developed serious third-party libraries that did similar things and sort of taking ideas from them and getting their feedback on my design. libraries that did similar things and sort of taking ideas from them and getting their feedback on my design and eventually we
Starting point is 02:14:15 put it in the standard library and after a few years I got distracted. I think the thing, the big thing that distracted me was actually type annotations. But other people kept it alive and kicking and it's being quite successful actually in the world of Python web clients. So initially what are some of the design challenges there in that debate for the PEP and what are some things that got rejected, what are some things that got accepted to the stand out to you? There are a couple of different ways you can handle parallel IO and this happens this happens at an architectural level in operating systems as well. Like Windows prefers to do it one way
Starting point is 02:14:52 and Unix prefers to do it the other way. You have an object that represents a network endpoint, say a connection with web browser that you're client. And say you're waiting for an incoming request. Two fundamental approaches are, okay, I'm waiting for an incoming request, I'm doing something else, come wake me up or sort of come tell me when something interesting happened, like a packet came in on that network connection. And the other paradigm is we're on a team of a whole bunch of people with maybe a little mind and we can only manage this web connection and I'm just blocked until something comes in.
Starting point is 02:15:51 And then I'm already waiting for it. I get the data, I process the data, and then I go back to the top and say, now, sort of, I'm waiting for the next packet. Those are about the two paradigms. One is a paradigm where there is notionally a threat of control, whether it's an actual operating system, threat or more an abstraction in AsyncIO. We call them tasks. But a task in AsyncIO or a thread in other contexts is devoted to one thing,
Starting point is 02:16:26 and it has logic for all the stages. Like when it's a web request, like, first wait for the first line of the web request, parse it because then you know if it's a get or a post or a put or whatever or an error. Then wait until you have a bunch of lines until there's a blank line, then parse that as headers, and then interpret that, and then wait for the rest of the data to come in if there is any more that you request. I expect that sort of standard web stuff.
Starting point is 02:17:02 And the other thing is, and there's always endless debate about which approach is more efficient and which approach is more error prone, where I just have a whole bunch of stacks in front of me and whenever a packet comes in, I sort of look at the number of the pack that there's some number on the pack and I say, oh, that packet goes on this pile and then I can do a little bit and then the sort of that pile provides my context. And as soon as I'm done with the processing, I sort of, I can forget everything about what's going on because the next packet will come in from some random other client and it's that pile or it's this pile.
Starting point is 02:17:46 And every time a pile is maybe empty or full or whatever, the criteria is I can toss it away or use it for a new space. But several traditional third-party libraries for asynchronous I.O. processing in Python chose the model of a callback. And that's that's the idea where you have a bunch of different stacks of paper in front of you and every time someone gives you a piece, gives you new sheet, you decide which stack it belongs to. And that leads to a certain style of spaghetti code that I find sort of aesthetically not pleasing and I was sort of never very successful and I had heard many stories about people who were also sort of complaining about that style of coding. It was very prevalent in JavaScript at the time at least because it was like how the JavaScript event loop basically works. And so I thought, well, the task-based model where
Starting point is 02:18:54 each task has a bunch of logic, we had mechanisms in the Python language that we could easily reuse for that. And I thought thought I want to build a whole library for asynchronous networking I.O. and all the other things that may need to be done asynchronously based on that paradigm. And so I just chose a paradigm and tried to see how far I could get with that. And it turns out that it's pretty good paradigm.
Starting point is 02:19:26 So people enjoy that kind of paradigm programming for asynchronous I.O. Relative to callbacks. Okay, beautiful. So how does that all interplay with the infamous GIL, the global interpreter lock? Maybe can you say what the Gil is and how does it dance beautifully with Asin Kayao?
Starting point is 02:19:50 The global interpreter lock solves the problem that Python originally was not written with either asynchronous or parallelism in mind at all. There was no concurrency in the language. There was no parallelism, there were no threads. Only a small number of years into Python's initial development. All the new cool operating systems like Sunowaz and Silicon Graphics, IRIS and then eventually POSIX and Windows all came with threading libraries that let you do multiple things in parallel. And there is a certain sort of principle which many CPUs as there are threads in the program. And those CPUs were completely independently. And if you don't have enough CPUs, the operating system sort of simulates those extra CPUs. On the other hand, if you have enough CPUs,
Starting point is 02:21:05 you can get a lot of work done by deploying those multiple CPUs. But Python wasn't written to do that. And so, as libraries for multi-threading were added to see, As libraries for multi-threading were added to C, but every operating system vendor was adding their own version of that, we thought, and maybe we were wrong, but at the time we thought, well, we quickly want to be able to support these multiple threads because they seemed at the time in the early 90s when they were new at least to me. They seemed a cool, interesting programming paradigm. And one of the things that Python at least at the time felt was nice about the language was that we could give a safe version of all kinds of cool, new operating system toys to the Python programmer like I remember
Starting point is 02:22:10 One or two years before threading I had spent some time adding networking sockets To Python and they were very literal translation of the networking sockets that were in the BSD operating system, so Unix BSD. But the nice thing was if you were using sockets from Python, then all the things you can do wrong with sockets in C would automatically give you a clear error message instead of just ending up with a malfunctioning, hanging program. And so we thought, well, we'll do the same thing with threading. But we didn't really want to rewrite the interpreter to be thread safe, because that was like, that would be a very complex refactoring of all the interpreter code and all the runtime code, because all the objects were written with the assumption that there's only one thread.
Starting point is 02:23:09 So we said, okay, well, we'll take our losses, we'll provide something that looks like threads. As long as you only have a single CPU on your computer, which most computers at the time did, it feels just like threads because the whole idea of multiple threads in the OS was that even if your computer only had one CPU, you could still fire up at many threads as you wanted.
Starting point is 02:23:38 Well, within reason, maybe 10 or 12, not 5,000. And so we thought we had conquered the abstraction of threads pretty well because multi-core CPUs were not in most Python programmers' hands anyway. And then, of course, a couple of more iterations of Moore's Law and the computer is getting faster. And at some point, the chip designers decided that they couldn't make the CPUs faster, but they could still make them smaller. And so they could put multiple CPUs on one chip. And suddenly, there was all this pressure about do things in parallel and that's where
Starting point is 02:24:27 the solution we had in Python didn't work. And that's sort of the moment that the GIL became infamous. Because the GIL was the solution we used to take this single interpreter and share it between all the different operating system threats that you could create. And so as long as the hardware physically only had one CPU that was all fine, and then as hardware vendors were suddenly telling us, oh, you got to paralyze. Everything's got to be paralyzed. People started saying, oh, but we can use multiple threads in Python
Starting point is 02:25:13 and then they discovered, oh, but actually all threads run on a single core. Yeah. I mean, is there a way, is there ideas in the future to remove the global interpreter law guilt? Like maybe multiple sub interpreters, some tricky interpreters on top of interpreters kind of thing?
Starting point is 02:25:35 Yeah, there are a couple of possible futures there. The most likely future is that we'll get multiple sub interpreters Which each run a completely independent Python program nice But they're there's still some benefit of of sort of faster communication between Those programs, but it's also managing for you this running of multiple Python programs. Like, so you just hidden from you, right?
Starting point is 02:26:10 It's hidden from you, but you have to spend more time communicating between those programs because the sort of, the attractive thing about the multi-threaded model is that the threads can share objects. At the same time, that's also the downfall of the multi-threaded programming model, because when you do share objects, you weren't, and you didn't necessarily intend to share them, or there were aspects of those objects that were not reusable. You get all kinds of concurrency bugs.
Starting point is 02:26:49 And so the reason I wrote that little blog post about SEMA Force was that concurrency bugs are just harder. It would be nice if Python had no globally interpreter lock, and it had so-called free threading, but it would also cause a lot more software bugs. The interesting thing is that there is still a possible future where we are actually going to or where we could experiment at least with that, because there is a guy working for Facebook who has developed a fork of CPython that he called the no-gill interpreter,
Starting point is 02:27:37 where he removed the gill and made a whole bunch of optimizations so that the single threaded case doesn't run too much slower. And multi-threaded case will actually use all the cores that you have. And so that that would be an interesting possibility if we would be willing as Python core developers to actually maintain that code indefinitely, and if we're willing to put up with the additional complexity of the interpreter and the additional overhead for the single threaded case. And I'm personally not convinced that there are enough people needing the speed of multiple threads with their Python programs that it's worth to sort of take that performance hit and that complexity hit.
Starting point is 02:28:46 And I feel that the GIL actually is a pretty nice goldilocks point between no threads and all threads all the time. But not everybody agrees on that. So that is definitely a possible future. The sub interpreters look like a fairly safe bet for 3-12, so say a year from now. A year. So the goal is to do a new version every year for Python. Let me ask you perhaps a fun question, but there's a philosophy to it too. Will there ever be a Python 4.0? Now, before we say it's currently a joke and probably not, we're gonna go to 3.99 or 3.99. Can you imagine possible features that Python 4.0 might have
Starting point is 02:29:41 that would necessitate the creation of the new 4.0. Given the amount of pain, enjoy, suffering, and triumph that was involved in the move between version 2 and version 3. Yeah, well, as a community and as a core development team, we have a large amount of painful memories about the Python 3 transition, which is one reason that sort of everybody is happy that we've decided there's not going to be a 4.0 at least, not anytime soon, and if there is going to be one, it will sort of plan the transition very differently. Because clearly we underestimated the pain the transition caused for our users in the Python 3 case. And had we known we could have sort of
Starting point is 02:30:48 designed Python 3 somewhat differently without making it any worse. We just thought that we had a good plan, but we underestimated where, what sort of the users were capable of when it comes to that kind of transition. By the way, I think we talked way before a year and a half before the Python 2 officially end of life.
Starting point is 02:31:16 Oh, yeah. What was your memory of the end of life? Did you shed a tear on January 1st, 2020? remember the end of life, did you shed a tear on January 1st, 2020? Did was there? Everyone was standing alone. The core team had basically moved on years before. It was purely, it was a little symbolic moment to signal to the, the remaining users that there was no longer going to be any new releases or support for Python 27. Did you shed a single tear while looking out over the horizon? I'm not not a very poetic person and I don't shed tears like that but no.
Starting point is 02:32:08 had tears like that, but no. We actually had planned a party, but the party was planned for the U.S. Python conference that year, which would never happen, of course, because of the pandemic. Oh, is it like a Mars? Yeah, the conference was going to be, I think, late April that year. So that was a very difficult decision to cancel it. They did. Anyway, if we're going to have a Python 4, we're going to have to have both a different reason for for having that and a different process for managing the transition. Can you imagine a possible process that, so I think you're implying that if there is a 4.0 in some ways it would break back compatibility? Well, so here is a concrete thought I've had.
Starting point is 02:32:58 And I'm not unique, but not everyone agrees with this. So this is definitely a personal opinion. If we were to try something like that no-gill Python, my expectation is that it would feel just different enough, different enough, at least for the part of the Python ecosystem that is heavily based on C extensions. And that is like the entire machine learning data science, scientific Python world is all based on C extensions for Python. And so those people would likely feel the pain the most because they even if we don't change anything about the syntax of the language and the semantics of the language when you're writing Python code. We could even say, suppose that after Python say 319 instead of 320, we'll have 4.0. Suppose that's the time when we flip the switch to 4.0,
Starting point is 02:34:16 we'll not have a GIL. Imagine it was like that. So I would probably say that particular year, the release that we name 4.0 will be syntactically. It will not have any new syntactical features. No new modules in the standard library, no new built-in functions. Everything will be at the Python level will be purely compatible with Python 3.19. However, extension modules will have to make a change. They will have to be recompiled. They will have the same binary interface, the semantics and APIs for some things that are frequently accessed by C extensions will be different. And so for a pure Python user, 4.0 would be breeze, except that there are very few pure Python users left, because everybody who is using Python for something significant is using third-party extensions.
Starting point is 02:35:34 There are like, I don't know, several hundreds of thousands of third-party extensions on the PiPI service. And I'm not saying they're all good, but there is a large list of extensions that we'd have to do work. And some of those extensions are currently already low on maintainers, and they're struggling to keep afloat. So there you can give a huge heads up to them if you go to 4.0 to really keep developing it. Yeah, we'd probably have to do something like several years before, who knows, maybe five years earlier, like three to fifteen, we would have to say, and I'm just making the specific numbers up. But at some point, we'd have to say
Starting point is 02:36:27 that no-gill Python could be an option. It might be a compile time option. If you want to use no-gill Python, you have to recompile Python from source for your platform using your toolset. All you have to do is change one configuration variable and then you just run make or configure and make and it will build it for you.
Starting point is 02:36:53 But now you also have to use the no-gill compatible versions of all extension modules you want to use. And so as long as many extension modules don't have fully functional sort of variants that work within the no-gill world, that's not a very practical thing for Python users, but it would allow extension developers to test the waters, see what they need to see and tactically to be able to compile it, all maybe they're using functions that are defined
Starting point is 02:37:33 by the Python free runtime that won't be in the Python for runtime, those functions will not work. They'll have to find an alternative, but they can experiment with that and sort of write test applications. And that would be a way to transition and that could be a series of releases where the Python 4 is more and more imminent. We have supported more and more third-party extension modules
Starting point is 02:38:03 to have solid support that works for no-gill Python for that new API. And then sort of Python 4.0 is like the official moment that the mayor comes out and cuts the ribbon and now Python, now the sort of no guild mode is the default and maybe the only mode there is. The internet wants to know from Reddit. It's a small and fun question. There's many fun questions. But out of the Pi Pi packages, Pi Pi packages. Do you have ones you like?
Starting point is 02:38:46 Do you, in your opinion, are there must have Pi Pi libraries or ones you use all the time constantly? Oh my, that... I should really have a standard answer for that question, but like a positive standard answer, but my current standard answer is that I'm not a big user of third-party packages. When I write Python code, I'm usually developing some tooling around building Python itself. And the last thing we want is dependencies on third-party packages. So I tend to just use the standard library. And that's where you're focusing. That's where you're going is. But do you do you keep an eye of what's out there
Starting point is 02:39:30 to understand where the standard library could be moving, should be moving. It's a good kind of landscape of what's missing from the sale library. Well, usually when something's missing from the standard library nowadays, it is a relatively new idea, and there is a third party implementation, or maybe possibly multiple third party implementations, but they evolve at a much higher rate than they could when they're in the standard library. So it would be a big reduction in activity to incorporate things like that in the standard library. So I liked that there is a lively package ecosystem and that sort of recent trends in the standard library are actually that we're doing the occasional
Starting point is 02:40:25 spring cleaning where we're just, we're choosing some modules that have not had a lot of change in a long time and that maybe would be better off not existing at all at this point, because there might be a better third party alternative anyway. And we're sort of slowly removing those. That I often, those are things that I sort of, I spiked somewhere in 1992 or 1993. If you look through the commit history, it's very sad. All cosmetic changes, like changes in the indentation style or the name of this other standard library module got changed. Or nothing of any substance, the API is identical to what it was 20 years ago.
Starting point is 02:41:23 since the API is identical to what it was 20 years ago. So speaking of packages, they have a lot of impact on a lot of people's lives. This makes sense to you why Python has become the primary, the dominant language for the machine learning community. So packages like PyTorch, TensorFlow, SecondLearn, and even the lower level stuff like NumpyiSide, PyPandas, MappLotlib with Visualization. Can you, like, this makes sense to you why it
Starting point is 02:41:54 permeated the entire data science machine learning AI community? Well, it's, part of it is an effect that's as simple as we're all driving on the right side of the road, right? It's compatibility. And part of it is not quite as fundamental as driving on the right side of the road, which you have to do for safety reasons. I mean, you have to agree on something. They could have picked JavaScript or Pearl. There was a time in the early 2000s that it really looked like Pearl was going to dominate like biosciences, because DNA search was all based on regular expressions. Pearl has the fastest and most comprehensive regular expression engines still does.
Starting point is 02:42:46 I spent quite a long time with Pearl. That was another letting go of this kind of data processing system. The reasons why Python became the lingua franca of scientific code and Machine learning in particular and data science It really had a lot to do with Anything was better than C or C++ Recently a guy who worked at Lawrence Livermore National Laboratories in the sort of computing division wrote me his memoirs and he had his own view of how he helped
Starting point is 02:43:42 something he called computational steering into existence. And this was the idea that you take libraries that in his days were written in Fortran that that solved universal mathematical problems. And those libraries still work, but the scientists that use the libraries, use them to solve continuously different specific applications and answer different questions. And so those poor scientists were required to use, say, Fortran, because Fortran was the language that the library was written in. And then the scientist would have to write
Starting point is 02:44:27 an application that sort of uses the library to solve a particular equation or set off, of answer a set of questions. And the same for C++, because there's interoperability. So the dusty decks are written either in C++ or 4Tran. And so Paul Dubois was one of the people who, I think in the mid-90s, saw that you needed a higher level language for the scientists to sort of tie together the fundamental mathematical
Starting point is 02:45:09 algorithms of linear algebra and other stuff. And so gradually some libraries started appearing that did very fundamental stuff with arrays of numbers in Python. I mean, when I first created Python, I was not expecting it to be used for arrays of numbers much. I thought that was like an outdated data type. And everything was like objects and strings. And like Python was good and fast at string manipulation and objects obviously, but arrays of numbers were not very efficient and the multi-dimensional arrays didn't even exist in the language at all. But there were people who realized that Python had extensibility that was flexible enough that they could write third-party packages that did support large
Starting point is 02:46:09 arrays of numbers and operations on them very efficiently. And somehow they got a foothold through sort of different parts of the scientific community. I remember that the Hubble Space Telescope people in Baltimore were somehow big Python fans in the late 90s. And at various points, small improvements were made and more people got in touch with using Python to derive these libraries of interesting algorithms. And like once you have a bunch of scientists who are working on similar problems, say they're all working on stuff that comes in from the Hubble Space Telescope, but they're looking at different things. Some are looking at stars in this galaxy, other are looking at galaxies.
Starting point is 02:47:04 The math is completely different, the underlying libraries are still the same. And so they exchange code, they say, well, I wrote this Python program, or I wrote a Python library to solve this class of problems. And the other guys either say, oh, I can use that library 2, or if you make a few changes, I can use that library 2. Why start from scratch in Pearl or JavaScript, where there's not that infrastructure for a raise of numbers yet, where in Python you have it. And so more and more scientists, a different place is doing different different work discovered Python. And then, then people who had an idea for an important new fundamental library decided, oh, Python is actually already known to our users. So,
Starting point is 02:48:03 let's use Python as the user interface. I think that's how tensor, I imagine at least that's how tensor flow ended up with Python as the user interface. Right. But with TensorFlow, there's a deeper history of what the community is. It's not just like what packages it needs.
Starting point is 02:48:22 It's like what the community leans on for programming language because TensorFlow Had a prior library that was internal to Google, but there was also competing machine learning frameworks like the anno Cafe they were in Python. There was some scala Some other languages, but Python was really dominating it. And it's interesting because there's other languages from the engineering space, like MATLAB, that a lot of people used, but different design choices by the company, by the core developers led to it not spreading. And one of the choices with MATLAB by Mathworks is to
Starting point is 02:49:07 not make it open source, right? Or not, you know, having people pay. It was a very expensive product. And so, universities especially disliked it because it was a price per seat. I remember hearing. I remember hearing. Yeah, but I think that's not why it failed or I failed to spread. I think universities didn't like it, but they would still pay for it. The thing is it didn't feed into that GitHub open source packages culture so like and that's somehow a precondition for For viral spreading the hacker culture like the tinker or culture With with python it feels like you can build a package from scratch
Starting point is 02:49:51 Just solve a particular problem and get excited about sharing that package with others and that creates an excitement about a language I tend to like python's approach to open source in particular because it's sort of It's almost egalitarian. There's little hierarchy. There's obviously some because like you all need to decide whether you drive on the left or the right side of the road sometimes. But there is a lot of access for people with little power. You don't have to work for a big tech company to make a difference in the Python world. We have
Starting point is 02:50:33 affordable events that really care about community and support people and sort of the community is is like a big deal at our conferences and in the PSF. When the PSF funds events, it's always about growing the community. The PSF funds very little development. They do some, but most of the money that the PSF forks out is to community fostering things. So speaking of egalitarian, last time we talked four years ago, it was just after you stepped down from your role as the benevolent dictator for life, BDFO. Looking back, what are your insights and lessons
Starting point is 02:51:28 you learn from that experience about Python developer community, about human nature, about human civilization, life itself? Oh my. I probably held on to the position too long. I remember being just extremely stressed for a long time and it wasn't very clear to me what was leading, what was causing this stress. And looking back, I should have sort of relinquished my central role as
Starting point is 02:52:15 BDFL sooner. What were the pros and cons of the BDFL role? Like, what were the, you not relinquishing it? What are the benefits of that for the community and what are the drawbacks? Well the benefits for the community would be things like Clarity of vision and sort of a clear direction because I I a clear direction because I had certain ideas in mind when I created Python. And while I sort of let myself be influenced by many other ideas as Python evolved and became more successful and more complex and more used. I also stuck to certain principles and it's still hard to say what are Python's core principles. But the fact that I was playing
Starting point is 02:53:16 that role and sort of always very active grew the community in a certain way. It modeled to the community how to think about how to how to solve a certain problem. Well, that was a source of stress, but it was also beneficial. It was a source of stress for me personally, but it was beneficial for the community because people sort of over time had learned how I was thinking and could predict, but how I would decide about a particular issue. And not always perfectly, of course, but there wasn't a lot of jerking around like this year, we're all, but this year the Democrats are in power and we're doing these kind of things and now the Republicans are in power and they roll all that back and do those kind of things. Unfortunately, the successor structure with the steering council has sort of found a similar way of leading the community in a fairly steady direction without stagnating. And for me personally, it's more fun because there are things I can just ignore.
Starting point is 02:54:41 Yeah, oh, yeah, there's a bug in multi processing. Let someone else decide whether that's important to solve or not. I'll stick to typing in the ASEAN KAYO and the faster interpreter. Yeah, it allows you to focus a little bit more. What are interesting differences in culture if you can comment on between Google Dropbox and Microsoft from a Python programming perspective, all places you've been to, the positive. Is there a difference or is it just about people and there's great people everywhere? Or is there a culture difference? So Dropbox is much smaller than the other two in your list.
Starting point is 02:55:25 So, Dropbox is much smaller than the other two in your list. So, that is a big difference. The set of products they provide is narrower, so they're more focused. Small code based. Yeah, and Dropbox, sort of, at least during the time I was there, had the tendency of sort of making a big plan, putting the whole company behind that plan for a year, and then evaluate, and then suddenly find that everything was wrong about the plan, and then they had to do something completely different. So there was like the annual engineering re- reorg was sort of an unpleasant tradition at
Starting point is 02:56:08 Dropbox because like, oh, there's a new VP of engineering. And so now all the directors are being reshuffled. And this guy was in charge of infrastructure one year. And the next year he was made in charge of I didn't know product developments. It's fascinating because like you don't think about these companies internally, but I you know drop box to me from the very beginning was one of my favorite services. There's certain like programs and online services that make me happy, make me more efficient and all that kind of stuff. But one of the powers of those kinds of services,
Starting point is 02:56:45 they disappear. You're not supposed to think about how it all works, but it's incredible to me that you can sync stuff effortlessly across so many machines so quickly. And like, don't have to worry about conflicts. They take care of the, you know, as a person that comes from version repositories and all that kind of stuff, you know, as a person that comes from a version of repositories and all that kind of stuff or merge is super difficult and just keeping different versions of different
Starting point is 02:57:10 files is very tricky. The fact that they could take care of that, I just, I don't know, the, the engineering behind the scenes must be super difficult both on the computer infrastructure and the software. A lot of internal sort of hand-wringinging about things like that, but the product itself always worked very smoothly. Yeah, well, there's probably a lot of lessons to that. You can have a lot of turmoil inside on the engineering side, but if the product is good, the product is good, and maybe don't mess with that either, you know, when it's good, keep it's like with Google, focus on the search and add.
Starting point is 02:57:49 Right. And the money will come. Yeah. And make sure that's done extremely well. And don't forget what you do extremely well. In what ways do you provide value and happiness to the world? Make sure you do that well. Is there something else to say about Google Microsoft? Microsoft does that at a very fascinating shift recently. With the new CEO, what you know, recent CEO with purchasing GitHub, embracing open source culture, embracing the
Starting point is 02:58:19 developer culture is pretty interesting to see. That's like why I joined Microsoft. I mean, after retiring and thinking that I would stay retired for the rest of my life, which of course was a ridiculous thought. But I was done working for a bit, and then the pandemic made me realize that work can also provide a source of full film and keep you out of trouble. Microsoft is a very interesting company
Starting point is 02:58:51 because it has this incredible, very long and varied history. And this amazing catalog of products that many of which also date way back. I mean, I've been talking to a bunch of Excel people lately and Excel is like 35 years old and they can still read spreadsheets that they might find on an old floppy drive. Yeah, there's, man, there are so many incredible tools through the years. Excel, one of the great shames of my life is that I've never learned how to use Excel well.
Starting point is 02:59:39 I mean, it just always felt like so many features are there. It's similar to the IDEEs, like PI Charm. It feels like I converge quickly to the dumbest way to use a thing to get the job done when clearly there's so much more power on your fingertips. Yeah. But I do think there's probably expert users
Starting point is 02:59:58 of Excel and then. Oh, Excel is a cash cow actually. Oh, it actually brings in money. Oh, yeah. A lot cow actually. Oh, it actually brings in money. Oh, yeah. A lot of the engineering sort of, if you look deep inside Excel, there's some very good engineering, very, very impressive stuff.
Starting point is 03:00:17 Okay, now I need to definitely learn. It's a little better. I had issues because I'm a keyboard person, so I had issues coming up with shortcuts. Microsoft sometimes, it's changed over the years, but sometimes they kind of want to make things easier for you on the surface and therefore make it harder for like people that like to have shortcuts and all that kind of stuff to optimize their workflow. Now, Excel is probably, people are probably yelling at me. It's like, no, Excel probably has a lot of ways to optimize the workflow.
Starting point is 03:00:48 In fact, I keep discovering that there are many features in Excel that only exists at keyboard shortcuts. Yeah, that's the sense I have. And now, like, I'm embarrassed that it's just, you just have to know what they are. Yeah. That's like, there's no logic or reason to the assignment of the keyboard shortcuts because they go back even longer than 35 years. Can you maybe comment about such in Adela and how hard it is for CEO to sort of pivot company, towards open source, or develop a culture?
Starting point is 03:01:23 Is there something you could see about like, what's the role of leadership in such a pivot and definition of a new vision? I've never met him, but I hear he's just a really sharp thinker, but he also has an incredible business sense. He took the organization that had very solid pieces, but that was also struggling with all sorts of shameful things, especially the Steve Balmer time. I imagine, in part through his personal charm and thinking. And of course, the great thrust that the rest of the leadership has in him, he managed to really turn the company around and sort of change it from openly hostile to open source to actively embracing open source. And that doesn't mean that suddenly Excel is going to go open source. And that doesn't mean that suddenly Excel is going to go open source.
Starting point is 03:02:29 But that means that there's room for a product like VS Code, which is open source. Yeah, it's fascinating. It gives me faith that large companies with good leadership can grow, can expand, can change, and pivot, and so on, develop, because it gets harder and harder as the company gets large. You wrote a blog post in response to a person looking for advice about whether it was a
Starting point is 03:02:53 CS degree to choose a 9-5 job or to become an entrepreneur. It's an interesting question. If you just think from first principles right now, somebody has took a few years in programming, has loved software engineering, in some sense creating Python as an entrepreneur and endeavor. That's a choice that a lot of people that are good programmers have to make. Do I work for a big company or do I create something new? Or you can work for a big company and create something new there?
Starting point is 03:03:32 Oh, inside the... Yeah, I mean, big companies have individuals who create new stuff that eventually grows big all the time. And if you're the person that creates it and you think it grows big, you'll have a chance to move up quickly in the company to run that thing. If that's your aspiration, what can also happen is that someone is brilliant engineer and sort of builds a great first version of a product and has no aspirations to then become a manager and grow the team from five people to 20 people to a hundred people to a thousand people and be in charge of hiring and meetings and they move on to inventing
Starting point is 03:04:21 another crazy thing inside the same company or sometimes they found a startup or they moved to a different great larger small company. There is all sorts of models. And sometimes people do have this whole trajectory from engineer buckling down writing code, not 9 to 5 but more like, noon till midnight, seven days a week, and coming up with a product and sort of staying in charge, if you take Drew Hauston Dropox's founder, he is still the CEO. At least when I was there, he had not checked out or anything. He was good CEO, but he had started out as the technical inventor or co-inventer. So he was someone who, I don't't know if he always aspired that I think when when he was 16. He already started a company
Starting point is 03:05:29 So maybe maybe he did but he sort of It turned out that that he he did have the the personal sort of skill set Needed to to grow and and stay on top and other people sort of are brilliant engineers and horrible at management. I count myself at least in the second category. So your first love and still your love is to be the quote unquote individual contributor.
Starting point is 03:05:59 So the programmer. Yeah. Do you have advice for a programming beginner on how to learn Python the right way? Find something you actually want to do with it. If you say, I want to learn skill X. That's not enough motivation. You need to pick something and it can be a crazy problem you want to solve. It can be completely unrealistic. But something that challenges you into actually learning coding in some language. And there's so many projects out there you can look for like that. That doesn't have to be some big ambitious thing.
Starting point is 03:06:53 It could be writing a small bot. If you're into social media, you can write a red bot or a Twitter bot or some aspect of automating something that you do every single day, processing files, all that kind of stuff. Nowadays, you can take machine learning components and sort of plug those things together. So you can do cool stuff with them. So that's actually a good, really good example. So if you're interested in machine learning, the state of machine learning is such that like a tutorial that takes an hour can get you to start using pre-trained models to do something super cool. And that's a good way
Starting point is 03:07:32 to learn Python because you learn just enough to run this model and that's like a sneaky way to get in there to figure out how to import stuff, had to write basic IO, how to run functions. And I'm not sure if it's the best way to learn the basics and Python, but it could be nice to just get fall in love first and then figure out the basics, right? Yeah, you can't expect to learn Python
Starting point is 03:07:58 from a one hour video. Or from blanking out on the name of someone who wrote a very funny blog post where he said, I see all these ads for things like learn Python in 10 days or so and he said the goal should be learn Python in 10 years. That's hilarious but I completely disagree with that. I think the criticism behind that is that the, the place is just like the blog post from earlier, the places that tell you learn Python on five minutes or 10 minutes,
Starting point is 03:08:36 they're actually usually really bad tutorials. So the thing is I do believe that you can learn a thing in an hour to get some interesting quick, like, it hooks you. I mean, this, but it just takes a tremendous amount of skill to be that kind of educator, Richard Feynman was able to condense a lot of ideas and physics in a very short amount of time, but that takes a deep, deep understanding. So yes, of course, the actual, I think the 10, the 10 years is about the experience, the pain along the way. And there's something you have to practice.
Starting point is 03:09:10 You can memorize the syntax, but, well, I couldn't, but maybe, maybe someone else can, but that doesn't make you a coder. Yeah. Actually, coding has changed in fascinating ways, because so much of coding is copying pasting from stack overflow and then adjusting, which is another way of coding. And I don't want to talk down to that kind of style of coding because it's kind of nicely efficient. But you know where that is going? Code generation.
Starting point is 03:09:40 No, seriously, get to co-pilot. Yeah, co-pilot. I use it every day and it really? Yeah, it writes a lot of code for me. And usually it's slightly wrong, but it still saves me typing. Because all I have to do is like change one word in a line of text that otherwise it generated perfectly. And like, how many times are you looking for like, Oh, what was I doing
Starting point is 03:10:06 this morning? I was looking for a begin marker. And I looking for an end marker. And so begin is blah, blah, blah search for begin. This is the begin token. And then the next line, I type E. And then the next line, I type E, and it completes the whole line with end instead of begin. That's a very simple example. Sometimes it, it sort of, if I name my function right, it writes at 5 or 10 line function. And you know Python enough to very quickly then detect the issues. It's like, it becomes a really good dance partner then. It doesn't save me a lot of thinking, but since I'm a poor typist, I'm very much appreciative of all the typing it does for me. Much better actually than the previous generation of suggestions that are also still built in VS Code, where when you hit like a dot,
Starting point is 03:11:08 it tries to guess what the type is of the variable to the left of the dot and then it gives you a list. Pub down menu of what the attributes of that object are, but Copilot is much, much smoother than that. What's fascinating here that you use GitHub Co-Pilot, do you think do you worry about the future of that? Did the automatic co-generation, the increasing amount of that kind of capability are programmers, jobs threatened, or is there still a significant role for humans? Our programmers jobs threatened by the existence of Stack Overflow. I don't think so. It helps you take care of the boring stuff.
Starting point is 03:11:53 You shouldn't try to use it to do something that you have no way of understanding what you're doing yet. A tool like that is always best when the question you're asking is, please remind me of how I do this, which I could look up how to do it. But right now, I've forgotten whether the method is called Foo or Bar or what the shape of the API is does it use a builder object or a constructor or a factory or something else and what are the parameters. It serves that role. It's like a great assistant, but the creative work of sort of deciding what you want, what you want to go to do is totally yours. What do you think is the future of Python
Starting point is 03:12:50 in the next 10, 20, 50 years, 100 years? You look forward, you ever think about, you ever imagine a future of human civilization or living inside the metaverse on Mars, human robots everywhere. What part does Python play in that? It'll eventually become sort of a legacy language that plays an important role, but that most people have never heard of and don't need to know about,
Starting point is 03:13:19 just like all kinds of basic structures in biology, like mitochondria. So it permeates all of life, all of digital life, but people just build on top of it. And they only know the stuff that's on top of it. You guys, you build layers of abstractions. I mean, most programmers nowadays rarely need to do binary arithmetic, right? Yeah, or even think about it, or even learn about it, or they could go quite far without knowing. I started building little digital circuits out of nend gates that I build myself with transistors and resistors. So I sort of, I feel very blessed that with that start when I was a teenager,
Starting point is 03:14:14 I learned some of the basic, at least, concepts that go into building a computer. that go into building a computer. And I sort of every part, I have some understanding what it's for and why it's there and how it works. And I can't forget about all that most of the time, but I sort of, I enjoy knowing, oh, if you go deeper, you at some point, you get to
Starting point is 03:14:49 nan gates and half-adders and shift registers and When it comes to the point of how do you how do you actually make a chip out of silicon? I have no idea That's just magic to me But you enjoy knowing that you can walk a while towards the lower and lower layers, but you don't need to. It's nice. The other day, as a sort of mental exercise, I was trying to figure out if I could build a flip-flop circuit out of relays.
Starting point is 03:15:21 I was just sort of trying to remember, oh, how does it really really work? Yeah, there's like this electromagnetic force that pulls a switch open or shut. And you can have like, it can open one switch in another, shut another. And you can have multiple contacts that go at once and how many relays do I really need to
Starting point is 03:15:47 sort of represent one bit of information? Can the relay just feed on itself? And I don't think I got to the final solution, but it was fun that I could still do a little bit of problem solving and thinking at that level. And it's cool how we build on top of each other. So there's people there just You used to it on the shoulders of giants and there's others who stand on your shoulders, and it's a giant Beautiful, higher. Yeah, I feel I sort of cover this middle layer of the technology stack where I sort of Peters out below the
Starting point is 03:16:29 the level of of nan gates. And at the top, I sort of I lose track when it gets to machine learning. And then eventually the machine learning will build higher and higher layers that will help us understand the lowest layer of the physics. And thereby the universe figures out how it itself works. Maybe, maybe not. Yeah, I did. I mean, it's possible. I mean, if you think of human consciousness, if that's even the right concept, it's interesting that sort of we have this super parallel brain that does all these incredible parallel operations like image recognition. I recognize your face. Does a huge amount of processing that goes on in parallel.
Starting point is 03:17:17 There's lots of nerves between my eyes and my brain. And the brain does a whole bunch of stuff all at once, because it's actually really slow circuits, but there are many of them that all work together. On the other hand, when I'm speaking, everything is completely sequential. I have to sort of string words together, one at a time, and when I'm thinking about stuff, when I'm understanding the world, I'm also thinking
Starting point is 03:17:48 of everything like one step at a time. And so we've sort of, we've got all this, this incredible parallel circuitry in our brains. And eventually we use that to simulate a single threaded much much higher level of interpreter. It's exactly, I mean that's the illusion of it. That's the illusion of it for us. That is a single sequential set of thoughts. And all of that came from a single cell through the process of embryogenesis. So DNA is the code. DNA holds the entirety of the code, the information and how to use that information to build
Starting point is 03:18:34 up an organism. The entire like, the arms, the legs, the brain. So you don't buy a computer, you buy a... You buy a seed, a diagram. And then you plant the computer and it builds itself in almost the same way and then does the computation. And then it eventually dies. It gets stale but gives birth to young computers more and more and gives them lessons, but they figure stuff out on their own and over time, it goes on that way. And those computers, when they go to college, try to figure out how to program and they
Starting point is 03:19:14 built their own little computers. They're increasingly more intelligent, increasingly higher and higher levels of abstractions. Isn't it interesting that you see of you see the same thing appearing at different levels though because you have like cells that create new cells and eventually that builds a whole organism but then the animal or the plant or the human has its own mechanism of replication. That is sort of connected in a very complicated way to the mechanism of replication of the cells. And then if you look inside the cell,
Starting point is 03:20:00 if you see how DNA and proteins are connected, then there is yet another completely different mechanism whereby proteins are mass produced using enzymes and a little bit of code from DNA. And of course, viruses break into it at that level. And while the mechanisms might be different, it seems like the nature of the mechanism is the same. And it cares across natural languages and programming languages, humans, maybe even human civilizations or intelligent civilizations, and then all the way down to the single cell organism.
Starting point is 03:20:45 It is fascinating to see what abstraction levels are built on top of individual humans, and how you have like whole societies that sort of have a similar self-preservation. I don't know what it is, instinct, nature, abstraction as the individuals have and the selves have. And they self-replicate and breed in different ways. It's hard for us humans to introspect because we have a very focused on our particular layer
Starting point is 03:21:19 of abstraction. But from an alien perspective looking on Earth, they'll probably see the higher level organism of human civilization as part of this bigger organism of life on Earth itself. In fact, that could be an organism just conversation, you're an amazing human being. You're gracious enough to talk to me when I was first doing this podcast, and one of the earliest first people I've talked to somebody I admired for a long time is just a huge honor. You did it at that time, and you did it again.
Starting point is 03:21:59 You're awesome. Take your legs. Thanks for listening to this conversation with Guido and Rossum. To support this podcast, please check out our sponsors in the description. And now, let me leave you some words from Oscar Wilde. Experience is the name that everyone gives to their mistakes. Thank you.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.