← Lex Fridman

Guido van Rossum: Python and the Future of Programming

Episode 3412022-11-26English

Guests: Guido van Rossum

Listen to this episode00:00 / 3:22:36
Reading settings
Reading preferences
Text size
Download in-depth read
Read offline

In-depth read pending

Downloads are not available yet.

§01Transcript · 00:00–10:08

00:00Can you imagine possible features

00:03that Python 4.0 might have

00:07that would necessitate the creation of the new 4.0?

00:12Given the amount of pain and joy, suffering and triumph

00:18that was involved in the move

00:20between version two and version three.

00:23The following is a conversation with Guido van Rossum,

00:28his second time on this podcast.

00:29He is the creator of the Python programming language

00:33and is Python's emeritus BDFL, Benevolent Dictator for Life.

00:38This is the Lex Friedman Podcast.

00:41To support it,

00:41please check out our sponsors in the description.

00:44And now, dear friends, here's Guido van Rossum.

00:47Python 3.11 is coming out very soon.

00:52In it, CPython claimed to be 10 to 60% faster.

00:57How'd you pull that off?

00:59And what's CPython?

01:00CPython is the last Python implementation standing,

01:04also the first one that was ever created.

01:06The original Python implementation

01:08that I started over 30 years ago.

01:10So what does it mean that Python,

01:12the programming language,

01:13is implemented in another programming language called C?

01:16What kind of audience do you have in mind here?

01:19People who know programming?

01:21No, there's somebody on a boat that's into fishing

01:23and they've never heard about programming,

01:25but also some world-class programmers.

01:27So you're gonna have to speak to both.

01:29Imagine a boat with two people.

01:31One of them has not heard about programming,

01:33is really into fishing.

01:34And the other one is like an incredible

01:38Silicon Valley programmer that's programmed in everything.

01:41C, C++, Python, Rust, Java,

01:45and knows the entire history of programming languages.

01:47So you're gonna have to speak to both.

01:49- I imagine that boat in the middle of the ocean.

01:51- Yes.

01:52- I'm gonna please the guy who knows how to fish first.

01:55- Yes, please.

01:55(both laugh)

01:57- He seems like the most useful in the middle of the ocean.

01:59You gotta make him happy.

02:01- I'm sure he has a cell phone.

02:03So he's probably very suspicious

02:06about what goes on in that cell phone,

02:07but he must have heard that inside his cell phone

02:10is a tiny computer.

02:12And a programming language is computer code

02:15that tells the computer what to do.

02:17- It's a very low level language.

02:20It's zeros and ones, and then there's assembly, and then--

02:24- Oh yeah, we don't talk about these really low levels

02:27because those just confuse people.

02:30I mean, when we're talking about human language,

02:32we're not usually talking about vocal tracts

02:35and how you position your tongue.

02:37I was talking yesterday about how

02:39when you have a Chinese person and they speak English,

02:44this is a bit of a stereotype they often don't know,

02:48or they can't seem to make the difference well

02:51between an L and an R.

02:54And I have a theory about that,

02:55and I've never checked this with linguists,

02:58that it probably has to do with the fact

03:02that in Chinese there is not really a difference.

03:05And it could be that there are regional variations

03:08in how native Chinese speakers pronounce that one sound

03:13that sounds like L to some of them, like R to others.

03:19- So it's both the sounds you produce with your mouth

03:23throughout the history of your life

03:25and what you're used to listening to.

03:27I mean, every language has that.

03:28Russian has-- - Exactly.

03:29- The Slavic languages have sounds like zh,

03:31the letter zh, like Americans or English speakers

03:36don't seem to know the sound zh.

03:39They seem uncomfortable with that sound.

03:43Yeah, so I'm, oh yes, okay, so we're not going

03:47to the shapes of tongues and the sounds

03:50that the mouth can make, fine.

03:51Words-- - And similarly,

03:52we're not going into the ones and zeros or machine language.

03:56I would say a programming language is a list

03:58of instructions like a cookbook recipe

04:02that sort of tells you how to do a certain thing,

04:06like make a sandwich.

04:08Well, acquire a loaf of bread, cut it in slices,

04:12take two slices, put mustard on one,

04:16put jelly on the other or something,

04:20then add the meat, then add the cheese.

04:22I've heard that science teachers can actually

04:26do great stuff with recipes like that

04:29and trying to interpret their students' instructions

04:32incorrectly until the students

04:34are completely unambiguous about it.

04:37- With language, see, that's the difference

04:39between natural languages and programming languages.

04:42I think ambiguity is a feature, not a bug

04:46in human spoken languages.

04:48That's the dance of communication between humans.

04:54- Well, for lawyers, ambiguity certainly is a feature.

04:58For plenty of other cases, the ambiguity

05:03is not much of a feature, but we work around it, of course.

05:08What's more important is context.

05:11So with context, the precision of the statement

05:14becomes more and more concrete.

05:16Right, but when you say I love you

05:19to a person that matters a lot to you,

05:22the person doesn't try to compile that statement

05:24and return an error saying, please define love.

05:27Right? - No, but I imagine

05:30that my wife and my son interpret it very differently.

05:34- Yes. - Even though it's

05:36the same three words. - But imprecisely still.

05:40- Oh, for sure. - Lawyers have a lot

05:43of follow-up questions for you.

05:44- Nevertheless, the context is already different

05:47in that case. - Yes, fair enough.

05:49So that's a programming language,

05:52is ability to unambiguously state a recipe.

05:57Actually, let's go back.

05:59Let's go to PEP8.

06:01You go through in PEP8 the style guide for Python code,

06:05some ideas of what this language should look like,

06:09feel like, read like.

06:11And the big idea there is that code readability counts.

06:14What does that mean to you?

06:16And how do we achieve it?

06:17So this recipe should be readable.

06:19- That's a thing between programmers.

06:21Because on the one hand, we always explain the concept

06:26of programming language as computers need instructions

06:31and computers are very dumb

06:32and they need very precise instructions

06:35because they don't have much context.

06:37In fact, they have lots of context,

06:39but their context is very different.

06:42But what we've seen emerge during the development

06:46of software starting in the, probably in the late 40s,

06:50is that software is a very social activity.

06:56A software developer is not a mad scientist

06:59who sits alone in his lab writing brilliant code.

07:02A software is developed by teams of people.

07:08Even the mad scientist sitting alone in his lab

07:11can type fast enough to produce enough code

07:14so that by the time he's done with his coding,

07:17he still remembers what the first few lines he wrote mean.

07:22So even the mad scientist coding alone in his lab

07:26would be sort of wise to adopt conventions

07:31on how to format the instructions

07:35that he gives to the computer.

07:37So that the thing is, there is a difference

07:40between a cookbook recipe and a computer program.

07:44The cookbook recipe, the author of the cookbook

07:47writes it once and then it's printed in 100,000 copies.

07:52And then lots of people in their kitchens

07:55try to recreate that recipe,

07:57that particular pie or dish from the recipe.

08:03And so there, the goal of the cookbook author

08:08is to make it clear to the human reader of the recipe,

08:14the human amateur chef in most cases.

08:18When you're writing a computer program,

08:23you have two audiences at once.

08:26It needs to tell the computer what to do,

08:32but it also is useful if that program

08:37is readable by other programmers.

08:40Because computer software,

08:41unlike the typical recipe for a cherry pie,

08:45is so complex that you don't get all of it right at once.

08:50You end up with the activity of debugging

08:55and you end up with the activity of...

08:58So debugging is trying to figure out

09:03why your code doesn't run the way

09:04you thought it should run.

09:06- That means broadly, it could be stupid little errors

09:08or it could be big logical errors.

09:11- It could be anything--

09:12- Spiritual.

09:14- Yeah, it could be anything from a typo

09:16to a wrong choice of algorithm

09:19to building something that does what you tell it to do,

09:24but that's not useful.

09:26- Yeah, it seems to work really well 99% of the time,

09:30but does weird things 1% of the time on some edge cases.

09:35- That's pretty much all software nowadays.

09:37- All good software, right?

09:38- Well, yeah, for bad software.

09:41- That 99 goes down a lot.

09:44But it's not just about the complexity of the program.

09:47Like you said, it is a social endeavor

09:50in that you're constantly improving

09:53that recipe for the cherry pie.

09:55But you're in a group of people improving that recipe.

10:00Or the mad scientist is improving the recipe

10:04that he created a year ago and making it better.

10:08Or adding something.

§02Transcript · 10:10–21:08

10:10He decides that he wants, I don't know,

10:13he wants some decoration on his pie or icing.

10:16- So there's broad philosophical things

10:19and there's specific advice on style.

10:22So first of all, the thing that people first experience

10:24when they look at Python,

10:26there is a, it is very readable,

10:30but there's also like a spatial structure to it.

10:34Can you explain the indentation style of Python

10:37and what is the magic to it?

10:39- Spaces are important for readability of any kind of text.

10:44If you take a cookbook recipe

10:47and you remove all the sort of,

10:52all the bullets and other markup,

10:55and you just crunch all the text together,

10:57maybe you leave the spaces between the words,

10:59but that's all you leave.

11:01When you're in the kitchen trying to figure out,

11:05oh, what are the ingredients and what are the steps?

11:09And where does this step end and the next step begin?

11:12You're gonna have a hard time

11:14if it's just one solid block of text.

11:16On the other hand, what a typical cookbook does

11:20if the paper is not too expensive,

11:23each recipe starts on its own page.

11:26Maybe there's a picture next to it.

11:28The list of ingredients comes first.

11:31There's a standard notation.

11:34There's shortcuts so that you don't have to

11:38sort of write two sentences on how you have to cut the onion

11:43because there are only three ways

11:44that people ever cut onions in a kitchen,

11:46small, medium, and in slices, or something like that.

11:50- Right.

11:52- None of my examples make any sense

11:53to real cooks, of course, but.

11:55- Yeah.

11:56(laughing)

11:58We're talking to programmers with a metaphor of cooking.

12:00I love it.

12:01But there is a strictness to the spacing that Python defines.

12:06So there's some looser things, some stricter things,

12:10but the four spaces for the indentation

12:13is really interesting.

12:14It really defines what the language looks and feels like.

12:19- Because indentation sort of taking a block of text

12:23and then having inside that block of text

12:27a smaller block of text that is indented further

12:31as sort of a group, it's like you have a bulleted list

12:36in a complex business document

12:39and inside some of the bullets are other bulleted lists.

12:43You will indent those too.

12:45If each bulleted list is indented several inches,

12:50then at two levels deep, there's no space left on the page

12:54to put any of the words of the text.

12:56So you can't indent too far.

12:58On the other hand, if you don't indent at all,

13:01you can't tell whether something is a top-level bullet

13:04or a second-level bullet or a third-level bullet.

13:06So you have to have some compromise.

13:10And based on ancient conventions

13:15and the sort of the typical width of a computer screen

13:19in the '80s and all sorts of things,

13:23we came up with sort of four spaces as a compromise.

13:30I mean, there are large groups of people

13:34who code with two spaces per indent level.

13:38For example, the Google Style Guide,

13:40all the Google Python code,

13:43and I think also all the Google C++ code

13:45is indented with only two spaces per block.

13:48If you're not used to that,

13:50it's harder to, at a glance, understand the code

13:55because the sort of the high-level structure

13:58is determined by the indentation.

14:01On the other hand, there are other programming languages

14:04where the indentation is eight spaces or a whole tab stop

14:09in sort of classic Unix.

14:11And to me, that looks weird

14:12because you sort of, after three indent levels,

14:15you've got no room left.

14:17- Well, there's some languages

14:19where the indentation is a recommendation,

14:22it's a stylistic one.

14:23The code compiles even without any indentation.

14:27And then Python, really,

14:29indentation is a fundamental part of the language, right?

14:32- It doesn't have to be four spaces.

14:34So you can code Python with two spaces per block

14:39or six spaces or 12 if you really want to go wild.

14:44But sort of everything that belongs to the same block

14:49needs to be indented the same way.

14:52In practice, in most other languages,

14:55people recommend doing that anyway.

14:57If you look at C or Rust or C++,

15:02all those languages, Java,

15:05don't have a requirement of indentation,

15:08but except in extreme cases,

15:11they're just as anal about

15:14having their code properly indented.

15:17- So any IDE that the syntax highlighting

15:22that works with Java or C++,

15:24they will yell at you aggressively

15:26if you don't do proper indentation.

15:28- They'd suggest the proper indentation for you,

15:32like in C you type a few words

15:36and then you type a curly brace,

15:38which is their notion of sort of begin an indented block.

15:43Then you hit return

15:46and then it automatically indents four or eight spaces

15:49depending on your style preferences

15:52or how your editor is configured.

15:53- Was there a possible universe

15:55in which you considered having braces in Python?

15:59- Absolutely, yeah.

16:00- What is it, 60/40, 70/30 in your head?

16:04What was the trade-off?

16:07- For a long time, I was actually convinced

16:10that the indentation was just better.

16:14Without context, I would still claim

16:20that indentation is better.

16:22It reduces clutter.

16:25However, as I started to say earlier,

16:29context is almost everything.

16:31In the context of coding,

16:34most programmers are familiar with multiple languages,

16:38even if they're only good at one or two.

16:41Apart from Python and maybe Fortran,

16:46I don't know how that's written these days anymore,

16:48but all the other languages, Java, Rust, C, C++,

16:52JavaScript, TypeScript, Perl,

16:55are all using curly braces to sort of indicate blocks.

17:00And so Python is the odd one out.

17:04- So it's a radical idea.

17:06Do you still, as a radical renegade revolutionary,

17:10do you still stand behind this idea

17:12of indentation versus braces?

17:15Like, what, can you dig into it a little bit more,

17:19why you still stand behind indentation?

17:22- Because context is not the whole story.

17:25History, in a sense, provides more context.

17:29So for Python, there's no chance that we can switch.

17:34Python is using curly braces for something else,

17:39dictionaries mostly.

17:41We would get in trouble if we wanted to switch.

17:44Just like you couldn't redefine C to use indentation,

17:49even if you agree that indentation

17:53sort of in a greenfield environment would be better,

17:57you can't change that kind of thing in a language.

18:02It's hard enough to reach agreement

18:05over much more minor details.

18:08Maybe, I mean, in the past in Python,

18:10we did have a big debate about tabs versus spaces

18:13and four spaces versus fewer or more.

18:17And we sort of came up with a recommended standard

18:21and sort of options for people who want to be different.

18:25- But yes, I guess the thought experiment

18:30I'd like you to consider is if you could travel back

18:33through time when the compatibility is not an issue

18:38and you started Python all over again,

18:40can you make the case for indentation still?

18:46- Well, it frees up a pair of matched brackets

18:49of which there are never enough in the world

18:52for other purposes.

18:55It really makes the language slightly

18:57sort of easier to grasp for people who don't already know

19:04another programming language.

19:07Because the sort of one of the things,

19:11and I mostly got this from my mentors

19:14who taught me programming language design

19:18in the earlier 80s.

19:20When you're teaching programming,

19:22for the total newbie who has not coded before,

19:28in not in any other language,

19:32a whole bunch of concepts in programming are very alien

19:38or sort of new and maybe very interesting,

19:44but also distracting and confusing.

19:46And there are many different things you have to learn.

19:48You have to sort of,

19:50in a typical 13 week programming course,

19:55you have to, if it's like really learning to program

20:00from scratch, you have to cover algorithms,

20:03you have to cover data structures,

20:05you have to cover syntax, you have to cover variables,

20:09loops, functions, recursion, classes.

20:13Expressions, operators.

20:16There are so many concepts.

20:18If you can spend a little less time

20:23having to worry about the syntax.

20:27The classic example was often,

20:30oh, the compiler complains every time I put a semicolon

20:36in the wrong place, or I forget to put a semicolon.

20:42Python doesn't have semicolons in that sense.

20:45So you can't forget them.

20:47And you are also not sort of misled

20:51into putting them where they don't belong

20:53because you don't learn about them in the first place.

20:56- The flip side of that is forcing the strictness

21:00onto the beginning programmer to teach them

21:03that programming values attention to details.

21:08You don't get to just write the way you write

§03Transcript · 21:10–31:54

21:10in English paper. - Plenty of other details

21:11that they have to pay attention to.

21:13So I think they'll still get the message

21:16about paying attention to details.

21:19- The interesting design choice,

21:21I still program quite a bit in PHP,

21:24and I'm sure there's other languages like this,

21:26but the dollar sign before a variable,

21:29that was always an annoying thing for me.

21:33It didn't quite fit into my understanding

21:36of why this is good for a programming language.

21:38I'm not sure if you ever thought about that one.

21:41- That is a historical thing.

21:44There is a whole lineage of programming languages.

21:47PHP is one, Perl was one,

21:52and the Unix shell is one of the oldest

21:56or all the different shells.

21:58The dollar was invented for that purpose

22:03because the very earliest shells had a notion of scripting,

22:07but they did not have a notion

22:09of parameterizing the scripting.

22:11And so a script is just a few lines of text

22:17where each line of text is a command

22:19that is read by a very primitive command processor

22:23that then sort of takes the first word on the line

22:27as the name of a program and passes all the rest

22:31of the line as text into the program

22:35for the program to figure out what to do with as arguments.

22:39And so by the time scripting was slightly more mature

22:44than the very first script,

22:46there was a convention that just like the first word

22:51of the line is the name of the program,

22:55the following words could be names of files.

23:00Input.text, output.html, things like that.

23:05The next thing that happens is,

23:08oh, it would actually be really nice

23:11if we could have variables

23:12and especially parameters for scripts.

23:15Parameters are usually what starts this process.

23:18But now you have a problem

23:21because you can't just say the parameters are X, Y, and Z.

23:27And so now we call, say, let's say X is the input file

23:31and Y is the output file, and let's forget about Z for now.

23:35I have my program and I write program X, Y.

23:39Well, that already has a meaning

23:41because that presumably means X itself is the file.

23:46It's a file name.

23:48It's not a variable name.

23:50And so the inventors of things like the Unix shell

23:57and I'm sure job command language at IBM before that

24:01had to use something that made it clear

24:07to the script processor,

24:09here is an X that is not actually the name of a file

24:14which you just pass through to the program you're running.

24:19Here is an X that is the name of a variable.

24:23And when you're writing a script processor,

24:27you try to keep it as simple as possible

24:30because certainly in the '50s and '60s,

24:34the thing that interprets the script

24:37was itself had to be a very small program

24:41because it had to fit in a very small part of memory.

24:44And so saying, oh, just look at each character

24:48and if you see a dollar sign,

24:51you jump to another section of the code

24:53and then you gobble up characters

24:54or say until the next space or something

24:57and you say, that's the variable name.

24:59And so it was sort of invented as a clever way

25:05to make parsing of things that contain both variable

25:12and fixed parts very easy in a very simple script processor.

25:18- It also helps, even then, it also helps the human author

25:23and the human reader of the script to quickly see,

25:28oh, 20 lines down in the script, I see a reference to XYZ.

25:34Oh, it has a dollar in front of it.

25:35So now we know that XYZ must be

25:37one of the parameters of the script.

25:39- Well, this is fascinating.

25:41Several things to say, which is the leftovers

25:44from the simple script processor languages

25:47are now in code bases like behind Facebook

25:51or behind most of the backend.

25:52I think PHP is probably still runs

25:54most of the backend of the internet.

25:56- Oh yeah, yeah, I think there's a lot of it

25:57in Wikipedia too, for example.

26:00- It's funny that those decisions, or not funny,

26:02it's fascinating that those decisions permeate through time.

26:07- Just like biological systems, right?

26:10I mean, the sort of, the inner workings of DNA

26:13have been stable for, well, I don't know how long it was,

26:17like 300 million years, half a billion years.

26:21- Yeah.

26:22- And there are all sorts of weird quirks there

26:26that don't make a lot of sense if you were to design

26:29a system like self-replicating molecules from scratch.

26:33- Well, that system has a lot of interesting resilience.

26:36It has redundancy that results,

26:40like it messes up in interesting ways

26:42that still is resilient when you look

26:45at the system level of the organism.

26:47Code doesn't necessarily have that,

26:50a computer programming code.

26:52- You'd be surprised how much resilience modern code has.

26:57I mean, if you look at the number of bugs per line of code,

27:02even in very well-tested code

27:08that in practice works just fine,

27:10there are actually lots of things that don't work fine.

27:16And there are error-correcting

27:18or self-correcting mechanisms at many levels.

27:22- Including probably the user of the code?

27:25- Well, in the end, the user who sort of is told,

27:28well, you got to reboot your PC, is part of that system.

27:33And a slightly less drastic thing is reload the page,

27:38which we all know how to do without thinking about it

27:43when something weird happens.

27:45You try to reload a few times before you say,

27:48oh, there's something really weird.

27:50- Okay, or try to click the button again

27:51if the first time didn't work.

27:53(both laughing)

27:54- Well, yeah, we should all have learned not to do that

27:57because that's probably just gonna turn the light back off.

28:01- Yeah, true, so do it three times.

28:03That's the right lesson.

28:05And I wonder how many people actually like the dollar sign.

28:11Like you said, it is documentation.

28:14So to me, it's whatever the opposite of syntactic sugar is,

28:18syntactic poison.

28:20To me, it is such a pain in the ass

28:23that I have to type in a dollar sign.

28:24Also super error-prone.

28:27So it's not self-documenting.

28:28It's like a bug-generating thing.

28:31It is a kind of documentation, that's the pro,

28:34and the con is it's a source of a lot of bugs.

28:37But actually, I have to ask you,

28:39this is a really interesting idea of bugs per line of code.

28:43If you look at all the computer systems out there,

28:46from the code that runs nuclear weapons

28:49to the code that runs all the amazing companies

28:52that you've been involved with and not,

28:55the code that runs Twitter and Facebook and Dropbox

28:58and Google and Microsoft, Windows, and so on,

29:02and we like laid out,

29:03wouldn't that be a cool table, bugs per line of code?

29:09And let's put actual companies aside.

29:13Do you think we'd be surprised by the number we see there

29:16for all these companies?

29:17- That depends on whether you've ever read about research

29:23that's been done in this area before.

29:26And I don't know, the last time I saw some research like that

29:31that was probably in the '90s,

29:35and the research might have been done in the '80s,

29:38but the conclusion was across a wide variety of companies

29:43a wide range of different software, different languages,

29:48different companies, different development styles.

29:52The number of bugs is always,

29:56I think it's in the order of about one bug per thousand lines

30:00in sort of mature software that is considered

30:05- Interesting. - as good as it gets.

30:08- Can I give you some facts here?

30:09There's a lot of good papers. - Oh yeah.

30:11- So you said mature software, right?

30:13So here's a report from a programming analytics company.

30:18Now this is from a developer perspective.

30:24Let me just say what it says

30:26'cause this is very weird and surprising.

30:28On average, a developer creates 70 bugs

30:31per 1,000 lines of code.

30:3315 bugs per 1,000 lines of code

30:36find their way to the customers.

30:38This is in software they've analyzed.

30:41- Oh, I was wrong by an order of magnitude there.

30:44- Fixing a bug takes 30 times longer

30:47than writing a line of code.

30:49That I can believe. - Yeah, totally.

30:51- 75% of a developer's time is spent on debugging.

30:54That's for an average developer.

30:57They analyze this 1,500 hours a year.

31:02In US alone, $113 billion is spent annually

31:07on identifying and fixing bugs.

31:10And I imagine this is marketing literature

31:13for someone who claims to have a golden bullet

31:15or a silver bullet that makes all that investment

31:19in fixing bugs go away.

31:21But that is usually not going to,

31:25that's not gonna happen.

31:27- Well, they're, I mean, they're referencing

31:29a lot of stuff, of course, but it is a page

31:31that is, you know, there's a contact us button

31:34at the bottom.

31:36Presumably, if you just spend a little bit less

31:39than $100 billion, we're willing to solve

31:41the problem for you.

31:42Right, and there's also a report on Stack Exchange,

31:46Stack Overflow, on the exact same topic,

31:48but when I open it up at the moment,

31:50the page says Stack Overflow is currently offline

31:52for maintenance.

31:54- Oh, that is ironic. - Yes.

§04Transcript · 31:56–42:07

31:56By the way, their error page is awesome.

31:58Anyway, I mean, can you believe that number of bugs?

32:02- Oh, absolutely.

32:04- Isn't that scary that 70 bugs per 1,000 lines of code,

32:07so even 10 bugs per 1,000 lines of code?

32:09- Well, that's about one bug every 15 lines,

32:13and that's when you're first typing it in.

32:15- Yeah, from a developer, but like,

32:18how many bugs are gonna be found if you're typing it in?

32:22- Well, the development process is extremely iterative.

32:26Typically, you don't make a plan for what software

32:30you're going to release a year from now,

32:32and work out all the details,

32:35because actually all the details themselves consist,

32:40they sort of compose a program,

32:42and that being a program,

32:47all your plans will have bugs in them too,

32:49and inaccuracies,

32:51but what you actually do is,

32:54you do a bunch of typing,

32:58and I'm actually really, I'm a really bad typist,

33:04I've never learned to type with 10 fingers.

33:06- How many do you use?

33:08- Well, I use all 10 of them, but not very well,

33:12but I never took a typing class,

33:15and I never sort of corrected that,

33:17so the first time I seriously learned,

33:20I had to learn the layout of a QWERTY keyboard,

33:24was actually in college, in my first programming classes,

33:28where we used punch cards,

33:31and so with my two fingers,

33:34I sort of pecked out my code.

33:37Watch anyone give you a little coding demonstration,

33:43they'll have to produce like four lines of code,

33:47and now see how many times they use the backspace key,

33:52yeah, because they made a mistake,

33:54and some people, especially when someone else is looking,

34:00will backspace over 20, 30, 40 characters

34:05to fix a typo earlier in a line,

34:08if you're slightly more experienced,

34:12of course you use your arrow buttons to go,

34:15or your mouse to, but the mouse is usually slower

34:17than the arrows, but a lot of people,

34:22when they type a 20 character word,

34:24which is not unusual,

34:27and they realize they made a mistake

34:29at the start of the word,

34:30they backspace over the whole thing,

34:33and then retype it,

34:34and sometimes it takes three, four times to get it right,

34:37so I don't know what your definition of bug is,

34:41arguably mistyping a word,

34:44and then correcting it immediately is not a bug,

34:47on the other hand, you already do sort of lose time,

34:52and every once in a while,

34:54there's sort of a typo that you don't get in that process,

34:59and now you've typed like 10 lines of code,

35:02and somewhere in the middle of it,

35:05you don't know where yet is a typo,

35:07or maybe a thinko where you forgot

35:10that you had to initialize a variable or something.

35:14- But those are two different things,

35:15and I would say yes,

35:16you have to actually run the code to discover that typo,

35:20but forgetting to initialize a variable

35:22is a fundamentally different thing,

35:25because that thing can go undiscovered.

35:27- That depends on the language,

35:29in Python it will not.

35:30And sort of modern compilers are usually pretty good

35:33at catching that, even for C.

35:36- So for that specific thing,

35:38but actually deeper,

35:40there might be another variable that is initialized,

35:45but logically speaking,

35:47the one you meant-- - Related, yep.

35:51- It's like name the same, but it's a different thing,

35:53and you forgot to initialize whatever,

35:55some counter or some basic variable

35:58that you're using for-- - I can tell

35:59that you've coded.

36:00- By the way, I should mention

36:02that I use a Kinesis keyboard,

36:05which has the backspace under the thumb,

36:08and one of the biggest reasons I use that keyboard

36:12is because you realize in order to use the backspace

36:15on a usual keyboard, you have to stretch your pinky out.

36:20And like, for most normal keyboards,

36:24the backspace is under the pinky,

36:26and so I don't know if people realize

36:29the pain they go through in their life

36:31because of the backspace key being so far away.

36:35So with the Kinesis, it's right under the thumb,

36:37so you don't have to actually move your hands,

36:39the backspace and the delete--

36:40- What do you do if you're ever not with your own keyboard

36:45and you have to use someone else's PC keyboard

36:48that has that standard layout?

36:50- So first of all, it turns out

36:52that you can actually go your whole life

36:54always having the keyboard with you.

36:56So this-- - Well, except for that

36:59little tablet that you're using

37:00for note-taking right now, right?

37:02- Yeah, so it's very inefficient note-taking,

37:05but I'm not, I'm just looking stuff up.

37:07But in most cases, I would be actually using

37:10the keyboard here right now.

37:13I just don't anticipate, you have to calculate

37:14how much typing do you anticipate.

37:17If I anticipate quite a bit, then I'll just,

37:19I have a keyboard with me. - You pull it out.

37:21- And same with, I mean, the embarrassing,

37:25I've accepted being the weirdo that I am,

37:28but when I go on an airplane

37:31and I anticipate to do programming or a lot of typing,

37:35I will have a laptop that will pull out a Kinesis keyboard

37:39in addition to the laptop, and it's just who I am.

37:43You have to accept who you are.

37:45But also, it's, for a lot of people,

37:49for me certainly, there's a comfort space

37:52where there's a certain kind of setups

37:54that are maximized productivity.

37:57And it's like some people have a warm blanket

38:01that they like when they watch a movie.

38:04I like the Kinesis keyboard.

38:05It takes me to a place of focus.

38:07And I still mostly, I'm trying to make sure

38:12I use the state-of-the-art IDEs for everything,

38:14but my comfort place, just like the Kinesis keyboard,

38:18is still Emacs.

38:19So I still use, I still, I mean,

38:25that's one of some of the debates I have with myself

38:28about everything from a technology perspective

38:31is how much to hold on to the tools you're comfortable with

38:36versus how much to invest in using modern tools.

38:40And the signal that the communities provide you with

38:43is the noisy one, because a lot of people year to year

38:46get excited about new tools.

38:48And you have to make a prediction.

38:50Are these tools defining a new generation

38:53or something that will transform programming?

38:55Or is this just a fad that will pass?

38:58Certainly with JavaScript frameworks

39:00and front-end and back-end of the web,

39:04there's a lot of different styles that came and went.

39:06I remember learning, what was it called, ActionScript?

39:11I remember for Flash,

39:14learning how to program in Flash,

39:16learning how to design, do graphic animation,

39:19all that kind of stuff in Flash.

39:21Same with Java applets.

39:22I remember creating quite a lot of Java applets,

39:25thinking that this potentially defines the future of the web.

39:28And it did not.

39:29- Well, you know, in most cases like that,

39:32the particular technology eventually gets replaced,

39:37but many of the concepts that the technology introduced

39:44or made accessible first are preserved, of course,

39:49because yeah, we're not using Java applets anymore,

39:54but the notion of reactive webpages

39:57that sort of contain little bits of code

40:01that respond directly to something you do,

40:05like pressing a button or a link or hovering even,

40:09it has certainly not gone away.

40:12And that those animations that were made painfully

40:17complicated with Flash,

40:20I mean, Flash was an innovation when it first came up.

40:25And when it was replaced by JavaScript equivalence stuff,

40:30it was a somewhat better way to do animations,

40:35but those animations are still there.

40:37Not all of them, but sort of,

40:42again, there is an evolution.

40:43And so often with technology,

40:47that the sort of the technology

40:49that was eventually thrown away or replaced

40:52was still essential to sort of get started.

40:57There wouldn't be jet planes without propeller planes.

41:01I bet you.

41:03- But from a user perspective, yes.

41:06From the feature set, yes.

41:07But from a programmer perspective,

41:11it feels like all the time I've spent with ActionScript,

41:16all the time I've spent with Java on the Applet side

41:20for the GUI development,

41:22well, no, Java I have to push back.

41:24That was useful, 'cause it transfers.

41:26But the Flash doesn't transfer.

41:28So some things you learn and invest time in.

41:31- Yeah, what you learned,

41:34the skill you picked up learning ActionScript,

41:38was sort of, it was perhaps a super valuable skill

41:43at the time you picked it up,

41:46if you learned ActionScript early enough.

41:50But that skill is no longer in demand.

41:57- Well, that's the calculation you have to make

41:59when you're learning new things.

42:00Like today people start learning programming.

42:02Today I'm trying to see what are the new languages to try?

42:07What are the new systems to try?

§05Transcript · 42:10–51:54

42:10What are the new IDs to try to keep improving?

42:14- That's why we start when we're young, right?

42:16But that seems very true to me,

42:21that when you're young,

42:22you have your whole life ahead of you

42:24and you're allowed to make mistakes.

42:27In fact, you should feel encouraged

42:30to do a bit of stupid stuff.

42:33Try not to get yourself killed or seriously maimed,

42:36but try stuff that deviates

42:40from what everybody else is doing.

42:43And like nine out of 10 times,

42:47you'll just learn why everybody else is not doing that,

42:50or why everybody else is doing it some other way.

42:53And one out of 10 times,

42:55you discover something that's better or that somehow works.

43:01I mean, there are all sorts of crazy things

43:03that were invented by accident,

43:07by people trying stuff together.

43:11- That's great advice to try random stuff,

43:13make a lot of mistakes.

43:14- Once you're married with kids,

43:16you're probably going to be a little more risk averse

43:19because now there's more at stake

43:21and you've already hopefully had some time

43:24where you were experimenting with crazy shit.

43:27- I like how marriage and kids

43:29solidifies your choice of programming language.

43:31How does that, the Robert Frost poem

43:33with the road less taken,

43:36which I think is misinterpreted by most people.

43:38But anyway, I feel like the choices you make early on,

43:42especially if you go all in,

43:44they're going to define the rest of your life's trajectory

43:47in a way that, like you basically are picking a camp.

43:51So, you know, there's, if you invest a lot in PHP,

43:55if you invest a lot in .NET,

43:57if you invest a lot in JavaScript,

44:00you're going to stick there.

44:03That's your life journey.

44:07It's very hard to tell. - Well, only as far

44:09as that technology remains relevant.

44:13- Yes, yes.

44:14- I mean, if at age 16, you learn coding in C

44:19and by the time you're 26, C is like a dead language,

44:28then there's still time to switch.

44:31There's probably some kind of survivor bias

44:34or whatever it's called in sort of your observation

44:38that you pick a camp because there are many

44:42different camps to pick.

44:43And if you pick .NET,

44:45then you can coast for the rest of your life

44:49because that technology is now so ubiquitous, of course,

44:53that it's, even if it's bound to die,

44:56it's going to take a very long time.

44:59- Well, for me personally, I had a very difficult

45:04and in my own head, brave leap that I had to take

45:07relevant to our discussion,

45:09which is most of my life I programmed in C and C++.

45:12And so having that hammer, everything looked like a nail.

45:17So I would literally even do scripting in C++.

45:21Like I would create programs that do script like things.

45:25And when I first came to Google and before then,

45:29it became already, before TensorFlow, before all of that,

45:32there was a growing realization that C++

45:35is not the right tool for machine learning.

45:38We could talk about why that is.

45:40It's unclear why that is.

45:41A lot of things has to do with community and culture

45:45and how it emerges and stuff like that.

45:46But for me to decide to take the leap to Python,

45:50like all out, basically switch completely from C++

45:54except for a highly performant robotics applications.

45:58There was still a culture of C++ in the space of robotics.

46:03That was a big leap.

46:05Like I had to, you know, like people have like

46:09existential crises or midlife crises or whatever.

46:13You have to realize almost like walking away

46:15from a person you love.

46:17'Cause I was sure that C++ would have to be

46:21a lifelong companion.

46:23For a lot of problems I would wanna solve,

46:24C++ would be there.

46:26And it was a question to say,

46:27well, that might not be the case.

46:29'Cause C++ is still one of the most popular languages

46:32in the world, one of the most used,

46:33one of the most dependent on.

46:35- It's also still evolving quite a bit.

46:38I mean, that is not a sort of a fossilizing community.

46:43- Yes.

46:47- They are doing great innovative work actually.

46:49- A lot.

46:50- But that sort of their innovations are hard to follow

46:53if you're not already a hardcore C++ user.

46:56- Well, this was the thing.

46:57It pulls you in, it's a rabbit hole.

46:59I was a hardcore.

47:00The old meta programming, template programming.

47:03Like I would start using the modern C++ as it developed.

47:07Right, not just the shared pointer

47:10and the garbage collection.

47:12That makes it easier for you to work with some of the flaws.

47:15But the detail, like the meta programming,

47:17the crazy stuff that's coming out there.

47:20But then you have to just empirically look and step back

47:24and say, what language am I more productive in?

47:28Sorry to say, what language do I enjoy my life with more?

47:34And readability and able to think through

47:37and all that kind of stuff.

47:39Those questions are harder to ask

47:41when you already have a loved one,

47:44which in my case was C++.

47:46And then there's Python, like that meme.

47:49Is the grass is greener on the other side.

47:52Am I just infatuated with a new fad, new cool thing?

47:56Or is this actually going to make my life better?

47:59And I think a lot of people face that kind of decision.

48:01It was a difficult decision for me when I made it.

48:06At this time, it's an obvious switch

48:08if you're into machine learning.

48:09But at that time, it wasn't quite yet so obvious.

48:13So it was a risk.

48:14And you have the same kind of stuff

48:16with I still, because of my connection to WordPress,

48:20I still do a lot of backend programming in PHP.

48:24And the question is, you know, Node.js, Python,

48:29do you switch backend to any of those programmings?

48:34There's the case for Node.js for me.

48:36Well, more and more and more of the front end,

48:39it runs in JavaScript.

48:40And fascinating cool stuff is done in JavaScript.

48:45Maybe use the same programming language

48:46for the backend as well.

48:48The case for Python for the backend is,

48:51well, you're doing so much programming

48:54outside of the web in Python.

48:56So maybe use Python for the backend.

48:58And then the case for PHP,

49:00well, most of the web still runs in PHP.

49:04You have a lot of experience with PHP.

49:06Why fix something that's not broken?

49:10Those are my own personal struggles,

49:12but I think they reflect the struggles of a lot of people

49:14with different programming languages,

49:16with different problems they're trying to solve.

49:18It's a weird one.

49:19- And there's not a single answer, right?

49:21Because depending on how much time

49:24you have to learn new stuff,

49:27where you are in your life,

49:28what you're currently working on,

49:31who you want to work with, what communities you like,

49:35there's not one right choice.

49:37Maybe if you sort of, if you can look back 20 years,

49:42you can say, well, that whole detour through ActionScript

49:45was a waste of time, but nobody could know that.

49:50So you can't beat yourself up over that.

49:54You just need to accept that not every choice you make

50:00is going to be perfect.

50:02Maybe sort of keep a plan B in the back of your mind,

50:07but don't overthink it.

50:11Don't try to sort of,

50:13don't create a spreadsheet with like,

50:17where you're trying to estimate,

50:19well, if I learn this language,

50:22I expect to make X million dollars in a lifetime.

50:26And if I learn that language,

50:28I expect to make Y million dollars in a lifetime.

50:31And which is higher and which has more risk

50:35and where's the chance that,

50:37it's like picking a stock.

50:40- Kind of, kind of, but I think with stocks,

50:45you can do, diversifying your investment is good.

50:51With productivity in life,

50:54boy, that spreadsheet is possible to construct.

50:57Like if you actually carefully analyze

51:01what your interests in life are,

51:02where you think you can maximally impact the world,

51:06there really is better and worse choices

51:09for a programming language.

51:10They're not just about the syntax,

51:12but about the community,

51:14about where you predict the community's headed,

51:16what large systems are programmed in that.

51:19- But can you create that spreadsheet?

51:21Because that's sort of,

51:23you're mentioning a whole bunch of inputs

51:25that go into that spreadsheet

51:27where you have to estimate things

51:28that are very hard to measure and even harder.

51:32I mean, they're hard to measure retroactively

51:36and they're even harder to predict.

51:37Like, what is the better community?

51:41Well, better is one of those incredibly difficult words.

51:46What's better for you is not better for someone else.

51:49- No, but we're not doing a public speech

51:50about what's better.

51:51We're doing a personal spiritual journey.

51:54I can determine a circle of friends,

§06Transcript · 51:57–1:01:50

51:57circle one and circle two,

51:59and I can have a bunch of parties with one

52:01and a bunch of parties with two,

52:03and then write down or take a mental note

52:06of what made me happier, right?

52:09And that, you know, you have,

52:11if you're a machine learning person,

52:12you wanna say, okay, I want to build a large company

52:15that is grounded in machine learning,

52:19but also has a sexy interface

52:21that has a large impact on the world.

52:23What languages do I use?

52:25You look at what Facebook is using,

52:26you look at what Twitter is using.

52:28Then you look at performant, more newer languages like Rust,

52:32or you look at languages that have taken,

52:35that most of the community uses

52:37in machine learning space, that's Python.

52:39And you can like think through,

52:40you can hang out and think through it.

52:42And it's always a invest,

52:44and the level of activity of the community

52:47is also really interesting, like you said,

52:48C++ and Python are super active

52:51in terms of the development of the language itself.

52:54- But do you think that you can make

52:57objective choices there?

52:59- No, no. - No.

53:00- But there's a gut you build up.

53:02Like, don't you believe in that gut feeling about--

53:05- No, everything is very subjective,

53:07and yes, you most certainly can have a gut feeling,

53:10and your gut can also be wrong.

53:11That's why there are billions of people,

53:14because they're not all right.

53:16I mean, clearly there are more people

53:18living in the Bay Area who have plans

53:21to sort of create a Google-sized company

53:25than there's room in the world for Google-sized companies.

53:28And they're gonna have to duke it out in the market space.

53:33And there's many more choices

53:35than just the programming language.

53:37Speaking of which, let's go back to the boat

53:40with the fisherman who's tuned out long ago.

53:42(laughing)

53:43Let's talk to the programmer.

53:44Let's jump around and go back to CPython

53:47that we tried to define as the reference implementation.

53:50And one of the big things that's coming out in 3.11,

53:53what's the right way to--

53:54- We tend to say 3.11, because it really was like,

53:58we went 3.8, 3.9, 3.10, 3.11,

54:01and we're planning to go up to 3.99.

54:05- 99?

54:06What happens after 99?

54:07- Probably just 3.100, if I make it there.

54:10- Okay.

54:11And go all the way to 420.

54:13I got it.

54:14Forever Python v3.

54:15We'll talk about 4, but more for fun.

54:18So, 3.11's coming out.

54:22One of the big, sexy things in it

54:24is it'll be much faster.

54:25So how did you, beyond hiring a great team

54:29or working with a great team, make it faster?

54:32What are some ideas that makes it faster?

54:36- It has to do with simplicity of software versus performance.

54:42And so, even though C is known to be a low-level language,

54:47which is great for writing

54:50sort of a high-performance language interpreter,

54:55when I originally started Python or CPython,

55:00I didn't expect there would be

55:03great success and fame in my future.

55:08So I tried to get something working

55:14and useful in about three months.

55:20And so I sort of, I cut corners.

55:25I borrowed ideas left and right

55:28when it comes to language design, as well as implementation.

55:32I also wrote much of the code as simple as it could be.

55:37And there are many things that you can code

55:43more efficiently by adding more code.

55:49It's a bit of a sort of a time-space trade-off

55:54where you can compute a certain thing

55:58from a small number of inputs.

56:01And every time you get presented with a new input,

56:05you do the whole computation from the top.

56:09That can be simple-looking code.

56:12It's easy to understand.

56:13It's easy to reason about that.

56:15You can tell quickly that it's correct,

56:19at least in the sort of mathematical sense of correct.

56:22Because it's implemented in C,

56:26maybe it performs relatively well.

56:29But over time, as sort of,

56:33as the requirements for that code

56:37and the need for performance go up,

56:42you might be able to rewrite that same algorithm

56:46using more memory, maybe remember previous results

56:51so you don't have to recompute everything from scratch.

56:54Like the classic example is computing prime numbers.

56:59Like, is 10 a prime number?

57:03Well, you sort of, is it divisible by two?

57:06Is it divisible by three?

57:07Is it divisible by four?

57:09And we go all the way to, is it divisible by nine?

57:13And it is not.

57:14Well, actually 10 is divisible by two,

57:17so there we stop, but say 11.

57:19Is it divisible by 10?

57:20The answer is no, 10 times in a row.

57:23So now we know 11 is a prime number.

57:25On the other hand, if we already know

57:28that two, three, five, and seven are prime numbers,

57:32and you know a little bit about the mathematics

57:34of how prime numbers work,

57:37you know that if you have a rough estimate

57:39for the square root of 11,

57:42you don't actually have to check is it divisible by four

57:46or is it divisible by five?

57:47All you have to check in the case of 11

57:50is is it divisible by two?

57:51Is it divisible by three?

57:52Because take 12.

57:54If it's divisible by four,

57:58well, 12 divided by four is three,

58:00so you should have come across the question,

58:02is it divisible by three first?

58:04So if you know basically nothing about prime numbers

58:09except the definition,

58:10maybe you go for x from two through n minus one

58:15is n divisible by x.

58:19And then at the end,

58:20if you got all nos for every single one of those questions,

58:25you know, oh, it must be a prime number.

58:29Well, the first thing is you can stop iterating

58:32when you find a yes answer.

58:35And the second is you can also stop iterating

58:37when you have reached the square root of n,

58:42because you know that if it has a divisor

58:45larger than the square root,

58:47it must also have a divisor smaller than the square root.

58:50Then you say, oh, except for two,

58:54we don't need to bother with checking for even numbers

58:56because all even numbers are divisible by two.

58:59So if it's divisible by four,

59:02we would already have come across the question,

59:04is it divisible by two?

59:06And so now you go special case,

59:08check is it divisible by two?

59:09And then you just check three, five, seven, 11.

59:12And so now you've sort of reduced your search space

59:17by 50% again, by skipping all the even numbers

59:20except for two.

59:22If you think a bit more about it,

59:24or you just read in your book about the history of math,

59:29one of the first algorithms ever written down,

59:33all you have to do is check,

59:34is it divisible by any of the previous prime numbers

59:38that are smaller than the square root?

59:41And before you get to a better algorithm than that,

59:45you have to have several PhDs in discrete math.

59:51So that's as much as I know.

59:54- So of course that same story applies

59:56to a lot of other algorithms.

59:57String matching is a good example

60:00of how to come up with an efficient algorithm.

60:03And sometimes the more efficient algorithm

60:05is not so much more complex than the inefficient one.

60:08But that's an art, and it's not always the case.

60:12In the general cases, the more performant the algorithm,

60:16the more complex it's gonna be.

60:18There's a kind of trade-off.

60:20- The simpler algorithms are also the ones

60:23that people invent first.

60:26Because when you're looking for a solution,

60:29you look at the simplest way to get there first.

60:33And so if there is a simple solution,

60:37even if it's not the best solution,

60:39not the fastest or the most memory efficient or whatever,

60:43a simple solution, and simple is fairly subjective,

60:49but mathematicians have also thought about

60:52sort of what is a good definition for simple

60:55in the case of algorithms.

60:58But the simpler solutions tend to be easier to follow

61:03for other programmers who haven't made a study

61:08of a particular field.

61:09And when I started with Python,

61:11I was a good programmer in general.

61:14I knew sort of basic data structures.

61:16I knew the C language pretty well.

61:19But there were many areas where I was only

61:25somewhat familiar with the state of the art.

61:28And so I picked in many cases,

61:34the simplest way I could solve a particular sub-problem.

61:37Because when you're designing and implementing a language,

61:40you have to like,

61:42you have many hundreds of little problems to solve.

61:45And you have to have solutions for every one of them

61:50before you can sort of say,

§07Transcript · 1:01:52–1:12:05

61:52I've invented a programming language.

61:55- First of all, so CPython,

61:58what kind of things does it do?

62:00It's an interpreter.

62:02It takes in this readable language that we talked about,

62:05that is Python.

62:06What is it supposed to do?

62:08- The interpreter basically,

62:09it's sort of a recipe for understanding recipes.

62:14So instead of a recipe that says, bake me a cake,

62:21we have a recipe for,

62:23well, given the text of a program,

62:27how do we run that program?

62:30And that is sort of the recipe for building a computer.

62:34- The recipe for the baker and the chef.

62:36- Yeah.

62:37- What are the algorithmically tricky things

62:41that happen to be low-hanging fruit

62:44that could be improved on?

62:45Maybe throw out the history of Python,

62:47but also now, how is it possible that 3.11 in year 2022,

62:52it's possible to get such a big performance improvement?

62:55- We focused on a few areas

63:02where we still felt there was low-hanging fruit.

63:06The biggest one is actually the interpreter itself.

63:11And this has to do with details of how Python is defined.

63:16So I didn't know if the fisherman

63:18is going to follow this story.

63:20- He already jumped off the boat.

63:22He's-

63:23- He's bored.

63:25- Yeah.

63:26- Stupid.

63:27- Python is actually,

63:28even though it's always called an interpreted language,

63:31there's also a compiler in there.

63:34It just doesn't compile to machine code.

63:36It compiles to bytecode,

63:38which is sort of code for an imaginary computer

63:43that is called the Python interpreter.

63:45- So it's compiling code that is more easily digestible

63:49by the interpreter or is digestible at all.

63:51- It is the code that is digested by the interpreter.

63:54That's the compiler.

63:55We tweaked very minor bits of the compiler.

63:57Almost all the work was done in the interpreter

64:00because when you have a program,

64:05you compile it once

64:07and then you run the code a whole bunch of times.

64:10Or maybe there's one function in the code

64:13that gets run many times.

64:15Now I know that sort of people

64:19who know this field are expecting me to,

64:22at some point, say,

64:24we built a just-in-time compiler.

64:26Actually, we didn't.

64:27We just made the interpreter a little more efficient.

64:31- What's a just-in-time compiler?

64:34- That is a thing from the Java world,

64:37although it's now applied to almost all programming languages,

64:42especially interpreted ones.

64:44- So you see the compiler inside Python

64:46not like a just-in-time compiler,

64:49but it's a compiler that creates bytecode

64:51that is then fed to the interpreter.

64:54And the compiler,

64:56was there something interesting to say about the compiler?

64:58It's interesting that you haven't changed that,

65:00tweaked that at all, or much.

65:01- We changed some parts of the bytecode,

65:06but not very much.

65:08And so we only had to change the parts of the compiler

65:11where we decided that the breakdown of a Python program

65:15in bytecode instructions had to be slightly different.

65:19But that didn't gain us the performance improvements.

65:24The performance improvements were

65:30like making the interpreter faster in part

65:33by sort of removing the fat

65:38from some internal data structures used by the interpreter.

65:41But the key idea is an adaptive specializing interface

65:46for an adaptive specializing interpreter.

65:49- Let's go.

65:50What is adaptive about it?

65:52What is specialized about it?

65:53- Well, let me first talk about the specializing part

65:56because the adaptive part is the sort of

65:59the second order effect, but they're both important.

66:03So bytecode is a bunch of machine instructions,

66:08but it's an imaginary machine.

66:10But the machine can do things like call a function,

66:14add two numbers, print a value.

66:18Those are sort of typical instructions in Python.

66:21And if we take the example of adding two numbers,

66:28actually in Python, the language,

66:31there's no such thing as adding two numbers.

66:33There's just, the compiler doesn't know

66:38that you're adding two numbers.

66:39You might as well be adding two strings or two lists

66:44or two instances of some user defined class

66:47that happened to implement this operator called add.

66:52That's a very interesting

66:54and fairly powerful mathematical concept.

66:57It's mostly a user interface trick

66:59because it means that a certain category of functions

67:04can be written using a single symbol, the plus sign,

67:10and sort of a bunch of other functions can be written

67:13using another single symbol, the multiply sign.

67:16So if we take addition, the way traditionally in Python,

67:23the add bytecode was executed is pointers,

67:26pointers, and more pointers.

67:31So first we have two objects.

67:34An object is basically a pointer to a bunch of memory

67:37that contains more pointers.

67:39- Pointers all the way down.

67:41- Well, not quite, but there are a lot of them.

67:43So to simplify a bit, we look up in one of the objects,

67:48what is the type of that object?

67:53And does that object type define an add operation?

67:58And so you can imagine that there is a sort of

68:02a type integer that knows how to add itself

68:05to another integer.

68:07And there is a type floating point number

68:09that knows how to add itself

68:11to another floating point number.

68:14And the integers and floating point numbers

68:18are sort of important, I think, mostly historically,

68:22because in the first computers,

68:23you used the sort of, the same bit pattern

68:29when interpreted as a floating point number

68:31had a very different value

68:32than when interpreted as an integer.

68:34- Can I ask a dumb question here?

68:36- Please do.

68:37- If you take the basics of int and float and add,

68:39who carries the knowledge of how to add two integers?

68:44Is it the integer?

68:45It's the type integer versus?

68:47- It's the type integer and the type float.

68:50- What about the operator?

68:51Does the operator just exist as a platonic form

68:56possessed by the integer?

68:59- The operator is more like,

69:04it's an index in a list of functions

69:08that the integer type defines.

69:12And so the integer type

69:13is really a collection of functions.

69:18And there is an add function

69:20and there's a multiply function

69:21and there are like 30 other functions for other operations.

69:25There's a power function, for example.

69:28And you can imagine that in memory,

69:32there is a distinct slot for the add operations.

69:37Let's say the add operation is the first operation of a type

69:40and the multiply is the second operation of a type.

69:44So now we take the integer type

69:46and we take the floating point type.

69:47In both cases, the add operation is the first slot

69:54and multiply is the second slot.

69:56But each slot contains a function

70:00and the functions are different

70:02because the add to integers function

70:07interprets the bit patterns as integers.

70:09The add to float function

70:13interprets the same bit pattern

70:16as a floating point number.

70:19And then there is the string data type,

70:22which again, interprets the bit pattern

70:26as the address of a sequence of characters.

70:31There are lots of lies in that story,

70:33but that's sort of a basic idea.

70:37- I can tell the fake news

70:39and the fabrication going on here at the table.

70:42But where's the optimization?

70:44Is it on the operators?

70:45Is it different inside the integer?

70:47- The optimization is the observation

70:51that in a particular line of code,

70:56so now you write your little Python program

71:01and you write a function

71:02and that function sort of takes a bunch of inputs

71:05and at some point it adds two of the inputs together.

71:09Now I bet you, even if you call your function a thousand times

71:15that all those calls are likely

71:18all going to be about integers

71:21because maybe your program is all about integers

71:24or maybe on that particular line of code

71:28where there's that plus operator,

71:30every time the program hits that line,

71:35the variables A and B that are being added together

71:38happen to be strings.

71:39And so what we do is instead of having this single byte code

71:45that says, here's an add operation

71:48and the implementation of add is fully generic.

71:50It looks at the object from the object,

71:53it looks at the type, then it takes the type

71:56and it looks up the function pointer,

71:59then it calls the function.

72:00Now the function has to look at the other argument

72:04and it has to double check

72:05that the other argument has the right type.

§08Transcript · 1:12:07–1:23:07

72:07And then there's a bunch of error checking

72:10before it can actually just go ahead

72:13and add the two bit patterns in the right way.

72:16What we do is every time we execute

72:21an add instruction like that,

72:25we keep a little note of,

72:28in the end, after we hit the code that did the addition

72:34for a particular type, what type was it?

72:38And then after a few times through that code,

72:44if it's the same type all the time,

72:47we say, oh, so this add operation,

72:54even though it's the generic add operation,

72:57it might as well be the add integer operation.

73:01And add integer operation is much more efficient

73:05because it just says, assume that A and B are integers,

73:10do the addition operation, do it right there in line

73:13and produce the result.

73:16And the big lie here is that in Python,

73:21even if you have great evidence that in the past

73:25it was always two integers that you were adding,

73:28at some point in the future, that same line of code

73:31could still be hit with two floating points or two strings,

73:33or maybe a string and an integer.

73:35- It's not a great lie, that's just the fact of life.

73:39- I didn't account for what should happen in that case

73:43in the way I told the story.

73:45- There is some accounting for that.

73:48And so what we actually have to do is

73:52when we have the add integer operation,

73:55we still have to check,

73:58are the two arguments in fact integers?

74:01We applied some tricks to make those checks efficient.

74:06And we know statistically that the outcome is almost always,

74:11yes, they are both integers.

74:14And so we quickly make that check

74:17and then we proceed with the sort of add integer operation.

74:21And then there is a fallback mechanism where we say,

74:25oops, one of them wasn't an integer.

74:27Now we're gonna pretend that it was just

74:29the fully generic add operation.

74:32We wasted a few cycles,

74:34believing it was going to be two integers

74:38and then we had to back up,

74:40but we didn't waste that much time

74:42and statistically most of the time.

74:47Basically we're sort of hoping that most of the time

74:51we guess right,

74:52because if it turns out that we guessed wrong too often

74:57or we didn't have a good guess at all,

75:00things might actually end up running a little slower.

75:04So someone armed with this knowledge

75:08and a copy of the implementation,

75:10someone could easily construct a counter example

75:13where they say, oh, I have a program

75:16and then now it runs five times as slow in Python 3.11

75:19than it did in Python 3.10.

75:21But that's a very unrealistic program.

75:24That's just like an extreme fluke.

75:28- It's a fun reverse engineering task though.

75:31- Oh yeah.

75:32- So there's a...

75:33People like fun, yes.

75:38So there's some presumably heuristic

75:42of what defines a momentum

75:44of saying, you seem to be working adding two integers,

75:48not two generic types.

75:50So how do you figure out that heuristic?

75:54- I think that the heuristic is actually,

75:57we assume that the weather tomorrow

75:59is gonna be the same as the weather today.

76:01- So you don't need two days of the weather?

76:03- No.

76:03(laughing)

76:05That is already so much better than guessing randomly.

76:10- So how do you find this idea?

76:13Hey, I wonder if instead of adding two generic types,

76:18we start assuming that the weather tomorrow

76:22is the same as the weather today.

76:24Where do you find the idea for that?

76:27Because that ultimately, for you to do that,

76:30you have to kind of understand

76:31how people are using the language, right?

76:34- Python is not the first language

76:36to do a thing like this.

76:38This is a fairly well-known trick,

76:40especially from other interpreted languages

76:43that had reason to be sped up.

76:47We occasionally look at papers about HHVM,

76:49which is Facebook's efficient compiler for PHP.

76:54There are tricks known from the JVM,

77:00and sometimes it just comes from academia.

77:03- And so the trick here is that the type itself doesn't,

77:06the variable doesn't know what type it is.

77:09So this is not a statically typed language

77:12where you can afford to have a shortcut to saying it's ints.

77:17- This is a trick that is especially important

77:20for interpreted languages with dynamic typing,

77:24because if the compiler could read in the source

77:29these X and Y that we're adding are integers,

77:34the compiler can just insert a single add machine code

77:38that hardware machine instruction that exists

77:42on every CPU and ditto for floats.

77:46But because in Python,

77:48you don't generally declare the types of your variables.

77:53You don't even declare the existence of your variables.

77:57They just spring into existence when you first assign them,

78:01which is really cool and sort of helps those beginners

78:05because there is less bookkeeping.

78:06They have to learn how to do

78:08before they can start playing around with code,

78:12but it makes the interpretation of the code less efficient.

78:17And so we're sort of trying to make the interpretation

78:22more efficient without losing

78:27the super dynamic nature of the language.

78:30That's always the challenge.

78:31- 3.5 got the PEP 44 type hints.

78:36What is type hinting and is it used by the interpreter,

78:41the hints, or is it just syntactic sugar?

78:44- So the type hints is an optional mechanism

78:48that people can use.

78:50And it's especially popular with sort of larger companies

78:55that have very large code bases written in Python.

78:58- Do you think of it as almost like documentation

79:00saying these two variables are this type?

79:02- More than documentation.

79:04I mean, so it is a sub-language of Python

79:09where you can express the types of variables.

79:13So here is a variable and it's an integer.

79:16And here's an argument to this function and it's a string.

79:18And here is a function that returns a list of strings.

79:22- But that's not checked when you run the code.

79:24- But exactly.

79:26There is a separate piece of software

79:28called a static type checker that reads all your source code

79:32without executing it and thinks long and hard

79:36about what it looks from just reading the code

79:41that code might be doing and double checks

79:46if that makes sense if you take the types

79:49as annotated into account.

79:51- So this is something you're supposed to run

79:53as you develop.

79:54- It's like a linter, yeah.

79:56That's definitely a development tool,

79:58but the type annotations currently are not used

80:02for speeding up the interpreter.

80:05And there are a number of reasons.

80:08Many people don't use them.

80:11Even when they do use them, they sometimes contain lies

80:16where the static type checker says, everything's fine.

80:22I cannot prove that this integer is ever not an integer,

80:26but at runtime, somehow someone manages

80:29to violate that assumption.

80:32And the interpreter ends up doing just fine.

80:36If we started enforcing type annotations in Python,

80:41many Python programs would no longer work.

80:45And some Python programs wouldn't even be possible

80:47because they're too dynamic.

80:50And so we made a choice of not using the annotations.

80:54There is a possible future where eventually

80:58three, four, five releases in the future,

81:03we could start using those annotations

81:05to sort of provide hints because we can still say,

81:10well, the source code leads us to believe

81:15that these X and Y are both integers.

81:18And so we can generate an add integer instruction,

81:23but we can still have a fallback that says,

81:26oh, if somehow the code at runtime provided something else,

81:31maybe it provided two decimal numbers,

81:35we can still use that generic add operation as a fallback,

81:40but we're not there.

81:41- Is there currently a mechanism

81:43or do you see something like that

81:46where you can almost add like an assert

81:48inside a function that says,

81:51please check that my type hints

81:54are actually mapping to reality?

81:56Sort of like insert manual static typing.

82:00- There are third-party libraries that are in that business.

82:05- Is it possible to do that kind of thing?

82:06Is it possible for a third-party library to take a hint

82:10and enforce it?

82:12It seems like a tricky thing.

82:14- Well, what we actually do is,

82:16I think this is a fairly unique feature in Python.

82:20The type hints can be introspected at runtime.

82:24So while the program is running,

82:27they mean Python is a very introspectable language.

82:32You can look at a variable and ask yourself,

82:34what is the type of this variable?

82:37And if that variable happens to refer to a function,

82:41you can ask, what are the arguments to the function?

82:45And nowadays you can also ask,

82:48what are the type annotations for the function?

82:50- So the type annotations are there inside the variable

82:53as it's at runtime.

82:55- They're mostly associated with the function object,

82:58not with each individual variable,

83:00but you can sort of map from the arguments to the variables.

83:05- And that's what a third-party library can help with.

83:07- Exactly.

§09Transcript · 1:23:08–1:33:57

83:08And the problem with that is that

83:10all that extra runtime type checking

83:12is going to slow your code down instead of speed it up.

83:17- I think to reference this sales pitchy blog post

83:22that says 75% of developers' time is spent on debugging,

83:27I would say that in some cases that might be okay.

83:29It might be okay to pay the cost of performance

83:32for the catching of the type errors.

83:36- And in most cases,

83:38doing it statically before you ship your code to production

83:45is more efficient than doing it at runtime piecemeal.

83:49- Yeah.

83:50Can you tell me about MYPY project?

83:55What is it?

83:57What's the mission?

83:59And in general,

84:00what is the future of static typing in Python?

84:04- Well, so MYPY was started by a Finnish developer,

84:09Jukka Lätusalo.

84:11- So many cool things out of Finland, I gotta say.

84:14- Just that part of the world.

84:15- I guess people have nothing better to do

84:17in those long, cold winters.

84:19I don't know, I think Jukka lived in England

84:22when he invented that stuff, actually.

84:25But MYPY is the original static type checker for Python.

84:30And the type annotations that were introduced

84:34with PEP484 were sort of developed

84:39together with the static type checker.

84:43And in fact, Jukka had first invented a different syntax

84:47that wasn't quite compatible with Python.

84:50And Jukka and I sort of met at a Python conference

84:55in, I think in 2013.

84:58And we sort of came up with a compromise syntax

85:04that would not require any changes to Python.

85:09And that would let MYPY sort of be an add-on

85:13static type checker for Python.

85:15- Just out of curiosity, was it like double colon

85:17or something, what was he proposing that would break Python?

85:21- I think he was using angular brackets for types

85:25like in C++ or Java generics.

85:29- Yeah, you can't use angular brackets in Python.

85:31It would be too tricky for template type stuff.

85:34- Well, the key thing is that we already had

85:38a syntax for annotations.

85:41We just didn't know what to use them for yet.

85:45So type annotations were just the sort of most logical thing

85:50to use that existing dummy syntax for.

85:54So there was no syntax for defining generics

85:59directly syntactically in the language.

86:04MYPY literally meant my version of Python,

86:08where my refers to Yuka.

86:10He had a parser that translated MYPY into Python

86:15by like doing the type checks

86:20and then removing the annotations

86:24and all the angular brackets from the positions

86:27where he was using them.

86:29But a pre-processor model doesn't work very well

86:33with the typical workflow of Python development projects.

86:37- That's funny.

86:38I mean, that could have been another major split

86:41if it became successful.

86:42Like if you watch TypeScript versus JavaScript,

86:46it's like a split in the community over types, right?

86:51That seems to be stabilizing now.

86:53- It's not necessarily a split.

86:54There are certainly plenty of people

86:56who don't use TypeScript,

86:59but just use the original JavaScript notation,

87:04just like there are many people in the Python world

87:07who don't use type annotations

87:08and don't use static type checkers.

87:11- No, I know, but there is a bit of a split

87:12between TypeScript and old school JavaScript,

87:15ES, whatever.

87:17- Well, in the JavaScript world,

87:19transpilers are sort of the standard way of working anyway,

87:23which is why TypeScript being a transpiler itself

87:27is not a big deal.

87:28- And transpilers for people who don't know,

87:30it's exactly the thing you said with MYPY,

87:33it's the code, I guess you call it pre-processing code

87:36that translates from one language to the other.

87:38And that's part of the culture,

87:40part of the workflow of the JavaScript community.

87:43- That's right.

87:44At the same time, an interesting development

87:47in the JavaScript/TypeScript world at the moment

87:51is that there is a proposal under consideration,

87:55it's only a stage one proposal,

87:58that proposes to add a feature to JavaScript

88:01where just like Python,

88:03it will ignore certain syntax

88:07when running the JavaScript code.

88:12And what it ignores is more or less a superset

88:16of the TypeScript annotation syntax.

88:19- Interesting.

88:21- So that would mean that eventually, if you wanted to,

88:25you could take TypeScript

88:27and you could shove it directly

88:31into a JavaScript interpreter without transpilation.

88:36The interesting thing in the JavaScript world,

88:38at least the web browser world,

88:40the web browsers have changed how they deploy

88:43and they sort of update their JavaScript engines

88:48much more quickly than they used to in the early days.

88:53And so there's much less of a need

88:55for transpilation in JavaScript itself,

88:59because most browsers just support

89:02the most recent version of ECMAScript.

89:05- Just on a tangent of a tangent,

89:07do you see, if you were to recommend somebody use a thing,

89:11would you recommend TypeScript or JavaScript?

89:14- I would recommend TypeScript.

89:16- Just because of the strictness of the typing?

89:19- It's an enormously helpful extra tool

89:23that helps you sort of keep your head straight

89:28about what your code is actually doing.

89:31I mean, it helps with editing your code.

89:36It helps with ensuring that your code is not too incorrect.

89:41And it's actually quite compatible with JavaScript,

89:47nevermind this syntactic sort of hack

89:50that is still years in the future.

89:52But any library that is written in pure JavaScript

89:56can still be used from TypeScript programs.

90:00And also the other way around,

90:01you can write a library in TypeScript

90:05and then export it in a form

90:06that is totally consumable by JavaScript.

90:10That sort of compatibility is sort of the key

90:14to the success of TypeScript.

90:17- Yeah, just to look at it,

90:19it's almost like a biological system that's evolving.

90:21It's fascinating to see JavaScript evolve the way it does.

90:24- Well, maybe we should consider that biological systems

90:27are just engineering systems too, right?

90:30- Yes.

90:31- Just very advanced with more history.

90:35- But it's almost like the most visceral

90:38in the JavaScript world

90:39because there's just so much code written in JavaScript

90:44that for its history was messy.

90:48If you're talking about bugs per line of code,

90:50I just feel like JavaScript eats the cake

90:53or whatever the terminology is.

90:55It beats Python by a lot in terms of number of bugs,

90:58meaning like way more bugs in JavaScript.

91:00And then obviously the browsers are developed.

91:05I mean, just there's so much active development.

91:07It feels a lot more like evolution

91:10where a bunch of stuff is born and dies

91:12and there's experimentation and debates

91:15versus Python is more, all that stuff is happening,

91:19but there's just a longer history

91:21of stable working giant software systems written in Python

91:26versus JavaScript is just a giant, beautiful,

91:29I would say, mess of code.

91:31- It's a very different culture.

91:33And to some extent, differences in culture are random,

91:37but to some extent,

91:39the differences have to do with the environment.

91:41And the fact that JavaScript is primarily

91:48the language for developing web applications,

91:53especially the client side,

91:55and the fact that it's basically the only language

91:59for developing web applications

92:02makes that community sort of just have a different nature

92:06than the community of other languages.

92:08- Plus the graphical component

92:12and the fact that they're deploying it

92:16on all kinds of shapes of screens and devices

92:19and all that kind of stuff,

92:20it just creates a beautiful chaos.

92:22Anyway, back to MyPy.

92:24So what, okay, you met,

92:26you talked about a syntax that could work.

92:29Where does it currently stand?

92:31What's the future of static typing in Python?

92:33- It is still controversial,

92:36but it is much more accepted

92:39than when MyPy and PEP484 were young.

92:43- What's the connection between PEP484 type hints and MyPy?

92:48- MyPy was the original static type checker.

92:53So MyPy quickly evolved from Yuka's own variant of Python

92:58to a static type checker for Python

93:02and sort of PEP484, that was it like

93:06a very productive year where like many hundreds of messages

93:12were exchanged debating the merits

93:15of every aspect of that PEP.

93:18And so MyPy is a static type checker for Python.

93:23It is itself written in Python.

93:27Most additional static typing features

93:31that we introduced in the time since 3.6

93:35were also prototyped through MyPy.

93:41MyPy being an open source project

93:44with a very small number of maintainers

93:46was successful enough that people said

93:50this static type checking stuff for Python

93:53is actually worth an investment for our company.

93:57- Nice.

§10Transcript · 1:33:58–1:44:20

93:58- But somehow they chose not to support

94:02making MyPy faster say, or adding new features to MyPy,

94:09but both Google and Facebook and later Microsoft

94:14developed their own static type checker.

94:17I think Facebook was one of the first,

94:20they decided that they wanted to use the same technology

94:25that they had successfully used for HHVM

94:28because they sort of, they had a bunch of compiler writers

94:35and sort of static type checking experts

94:38who had written the HHVM compiler

94:42and it was big success within the company.

94:44And they had done it in a certain way, sort of.

94:47They wrote a big, highly parallel application

94:53in an obscure language named OCaml,

94:56which is apparently mostly very good

94:58for writing static type checkers.

95:01- Interesting.

95:01I have a lot of questions about

95:04how to write a static type checker then.

95:06That's very confusing.

95:07- Facebook wrote their version

95:10and they worked on it in secret for about a year

95:13and then they came clean and went open source.

95:16Google in the meantime was developing

95:20something called PyType, which was mostly interesting

95:23because it, as you may have heard,

95:28they have one gigantic mono repo.

95:31So all the code is checked into a single repository.

95:35Facebook has a different approach.

95:37So Facebook developed Pyre, which was written in OCaml,

95:42which worked well with Facebook's development workflow.

95:46Google developed something they called PyType,

95:51which was actually itself written in Python.

95:53And it was meant to sort of fit well

95:58in their static type checking needs

96:01in Google's gigantic mono repo.

96:05- So Google has one giant, got it.

96:07So just to clarify,

96:10this static type checker philosophically

96:14is a thing that's supposed to exist

96:15outside of the language itself.

96:17And it's just a workflow, like a debugger for the programmers.

96:20- It's a linter.

96:21- For people who don't know, a linter,

96:22maybe you can correct me.

96:24But it's a thing that runs through the code continuously,

96:28pre-processing to find issues based on style, documentation.

96:34I mean, there's all kinds of linters, right?

96:36It can check that, what usual things does a linter do?

96:39Maybe check that you haven't too many characters

96:44in a single line.

96:45- Linters often do static analysis

96:48where they try to point out things that are likely mistakes,

96:52but not incorrect according to the language specification.

96:57Like maybe you have a variable that you never use.

97:01For the compiler, that is valid.

97:04You might be planning to use it

97:07in a future version of the code

97:10and the compiler might just optimize it out,

97:12but the compiler is not gonna tell you,

97:14"Hey, you're never using this variable."

97:16A linter will tell you that variable is not used.

97:20Maybe there's a typo somewhere else

97:22where you meant to use it,

97:24but you accidentally use something else,

97:26or there are a number of sort of common scenarios.

97:29And a linter is often a big collection of little heuristics

97:34where by looking at the combination

97:39of how your code is laid out, maybe how it's indented,

97:42maybe the comment structure,

97:44but also just things like definition of names, use of names,

97:51it'll tell you likely things that are wrong.

97:56And in some cases, linters are really style checkers.

98:00For Python, there are a number of linters

98:03that check things like,

98:06do you use the PEP-8 recommended naming scheme

98:11for your functions and classes and variables?

98:14Because like classes start with an uppercase

98:16and the rest starts with a lowercase

98:18and there's like differences there.

98:21And so the linter can tell you,

98:22"Hey, you have a class that,

98:25"whose first letter is not an uppercase letter."

98:29And that's just, I just find it annoying

98:31if I wanted that to be an uppercase letter,

98:33I would have typed an uppercase letter,

98:36but other people find it very comforting

98:38that if the linter is no longer complaining about their code

98:43that they have followed all the style rules.

98:46- Maybe it's a fast way for a new developer

98:48joining a team to learn the style rules, right?

98:50- Yeah, there's definitely that.

98:51But the best use of a linter is probably

98:55not so much to sort of enforce team uniformity,

99:00but to actually help developers catch bugs

99:05that the compilers for whatever reason don't catch.

99:09And there's lots of that in Python.

99:12And so, but a static type checker

99:15focuses on a particular aspect of the linting,

99:19which, I mean, MyPy doesn't care

99:23how you name your classes and variables,

99:25but it is meticulous about when you say

99:30that there was an integer here

99:32and you're passing a string there,

99:34it will tell you, "Hey, that string is not an integer."

99:37So something's wrong.

99:38Either you were incorrect when you said it was an integer

99:42or you're incorrect when you're passing it a string.

99:45- If this is a race of static type checkers,

99:48is somebody winning?

99:49As you said, it's interesting that the companies

99:51didn't choose to invest in this centralized development

99:56of MyPy.

99:58Is there a future for MyPy?

100:01What do you see as the,

100:03will one of the companies win out

100:05and everybody uses like PyType,

100:09whatever Google's is called?

100:10- Well, Microsoft is hoping that Microsoft's horse

100:15in that race called PyWrite is going to win.

100:18- PyWrite, like R-I-G-H-T?

100:22- Correct.

100:22Yeah, all my word processors tend to typo correct

100:27that as PyWrite, the name of the,

100:30I don't know what it is,

100:31some kind of semi-precious metal.

100:35- Oh, right.

100:36(laughing)

100:37I love it.

100:38Okay, so, okay, that's the Microsoft hope,

100:41but, okay, so let me ask the question a different way.

100:44Is there going to be ever a future

100:46where the static type checker gets integrated

100:48into the language?

100:49- Nobody is currently excited about

100:57doing any work towards that.

100:59That doesn't mean that five or 10 years from now,

101:02the situation isn't different.

101:06At the moment, all the static type checkers

101:14still evolve at a much higher speed

101:18than Python and its annotation syntax evolve.

101:22You get a new release of Python once a year.

101:26Those are the only times that you can introduce

101:29new annotation syntax.

101:32And there are always people who invent new annotation syntax

101:36that they're trying to push.

101:39And worse, once we've all agreed

101:43that we are going to put some new syntax in,

101:46we can never take it back.

101:48At least the sort of deprecating an existing feature

101:51takes many releases,

101:53because you have to assume that people started using it

101:56as soon as we announced it.

101:58And then you can't take it away from them right away.

102:01You have to start telling them,

102:03"Well, this will go away,

102:05"but we're not gonna tell you that it's an error yet."

102:09And then later it's gonna be a warning,

102:11and then eventually three releases in the future,

102:13maybe we remove it.

102:15On the other hand, the typical static type checker

102:19still has a release like

102:22every month, every two months,

102:27certainly many times a year.

102:29Some type checkers also include a bunch of

102:35experimental ideas that aren't official

102:38standard Python syntax yet.

102:41The static type checkers also just get better

102:45at discovering things that sort of are unspecified

102:50by the language, but that sort of could make sense.

102:53And so each static type checker actually has

102:57its sort of strong and weak points.

103:00- So it's cool, it's like a laboratory of experiments.

103:02- Yeah.

103:03- Microsoft, Google, and all, and you get to see.

103:05- And you see that everywhere, right?

103:06Because there's not one single JavaScript engine either.

103:11There is one in Chrome, there is one in Safari,

103:14there is one in Firefox.

103:15- But that said, you said there's not interest,

103:19I think there is a lot of interest in type hinting, right?

103:22In the PEP 484.

103:26Actually, how many people use that?

103:28Do you have a sense?

103:29How many people use, 'cause it's optional, it's a sugar.

103:32- I can't put a number on it,

103:35but from the number of packages

103:38that do interesting things with it at runtime,

103:41and the fact that there are like now three or four

103:46very mature type checkers that each have

103:50their segment of the market,

103:52and oh, and then there is PyCharm,

103:54which has a sort of more heuristic-based type checker

103:57that also supports the same syntax.

104:00My assumption is that many, many people

104:05developing Python software professionally

104:08for some kind of production situation

104:12are using a static type checker,

104:15especially anybody who has a continuous integration cycle

104:20probably has one of the steps in their testing routine

§11Transcript · 1:44:27–1:55:41

104:27that happens for basically every commit

104:30is run a static type checker.

104:34And in most cases, that will be MyPy.

104:37So I think it's pretty popular topic.

104:41- According to this webpage,

104:4420 to 30% of Python 3 codebases are using type hints.

104:50- Wow, I wonder how they measured that.

104:53Did they just scan all of GitHub?

104:55- Yeah, that's what it looks like.

104:57They did a quick, not all of, but like a random sampling.

105:01So you mentioned PyCharm.

105:04Let me ask you the big subjective question.

105:07What's the best IDE for Python?

105:13And you're extremely biased now that you're with Microsoft.

105:16Is it PyCharm, VS Code, Vim, or Emacs?

105:21- Historically, I actually started out with using Vim,

105:26but when it was still called VI.

105:28For a very long time, I think from the early 80s to,

105:34I'd say two years ago, I was Emacs user.

105:41- Nice.

105:42- Between, I'd say 2013 and 2018,

105:48I dabbled with PyCharm,

105:51mostly because it had a couple of features.

105:56I mean, PyCharm is like driving an 18-wheeler truck,

106:01whereas Emacs is more like driving

106:08your comfortable Toyota car

106:11that you've had for 100,000 miles

106:15and you know what every little rattle of the car means.

106:19I was very comfortable in Emacs,

106:21but there were certain things it couldn't do.

106:23It wasn't very good at that sort of,

106:26at least the way I had configured it.

106:29I didn't have very good tooling in Emacs

106:33for finding a definition of a function.

106:35- Got it.

106:37- When I was at Dropbox exploring

106:40a five million line Python code base,

106:44just grabbing all that code for where is there a class,

106:49foobar, well, it turns out that if you grab

106:52all five million lines of code,

106:54there are many classes with the same name.

106:56And so PyCharm sort of, once you fired it up

107:02and once it's indexed, your repository was very helpful.

107:07But as soon as I had to edit code,

107:10I would jump back to Emacs and do all my editing there

107:14because I could type much faster and switch between files

107:18when I knew which file I wanted much quicker.

107:21And I never really got used

107:23to the whole PyCharm user interface.

107:26- Yeah, I feel torn in that same kind of way

107:29'cause I've used PyCharm off and on

107:31exactly in that same way.

107:33And I feel like I'm just being an old grumpy man

107:37for not learning how to quickly switch between files

107:40and all that kind of stuff.

107:41I feel like that has to do with shortcuts,

107:42that has to do with, I mean, you just have to get accustomed

107:45just like with touch typing.

107:46- Yeah, you have to just want to learn that.

107:49I mean, if you don't need it much.

107:51- You don't need touch typing either.

107:53You can type with two fingers just fine in the short term,

107:56but in the long term, your life will become better

107:59psychologically and productivity wise

108:01if you learn how to type with 10 fingers.

108:03- If you do a lot of keyboard input.

108:06- But for everyone, emails and stuff, right?

108:09Like you look at the next 20, 30 years of your life,

108:13you have to anticipate where technology is going.

108:15Do you want to invest in handwriting notes?

108:19Probably not.

108:20More and more people are doing typing

108:22versus handwriting notes.

108:24So you can anticipate that.

108:26So there's no reason to actually practice handwriting.

108:28There's more reason to practice typing.

108:30You can actually estimate, back to the spreadsheet,

108:33the number of paragraphs, sentences, or words you write

108:39for the rest of your life.

108:40(laughing)

108:42You can probably--

108:43- You go again with the spreadsheet of my life, huh?

108:45- Yes.

108:47All of that is not actual, like converted to a spreadsheet,

108:50but it's a gut feeling.

108:51Like I have the same kind of gut feeling about books.

108:54I've almost exclusively switched to Kindle now,

108:57so ebook readers, even though I still love

109:01and probably always will the smell,

109:03the feel of a physical book.

109:05And the reason I switched to Kindle is like,

109:09all right, well, this is really paving,

109:12the future is going to be digital

109:15in terms of consuming books and content of that nature.

109:18So you should let your brain get accustomed

109:21to that experience.

109:23In that same way, it feels like PyCharm or VS Code.

109:27I think PyCharm is the most sort of sophisticated,

109:31featureful Python ID.

109:35It feels like I should probably at some point very soon,

109:38switch entire, like I'm not allowed to use anything else

109:42for Python than this ID or VS Code.

109:45It doesn't matter, but walk away from Emacs

109:47for this particular application.

109:49So I think I'm limiting myself in the same way

109:51that using two fingers for typing is limiting myself.

109:54This is a therapy session.

109:57This is not, I'm not even asking a question.

109:58(laughing)

110:00But I'm sure a lot of people are thinking this way, right?

110:00- I'm not gonna stop you.

110:04- I think that sort of everybody has to decide

110:07for themselves which one they want to invest more time in.

110:12I actually ended up giving VS Code a very tentative try

110:18when I started out at Microsoft and really liking it.

110:23And it sort of, it took me a while

110:27before I realized why that was.

110:30But, and I think that actually the founders

110:33of VS Code may not necessarily agree with me on this.

110:38But to me, VS Code is in a sense,

110:42the spiritual successor of Emacs.

110:45Because as you probably know, as an old Emacs hack,

110:51the key part of Emacs is that it's mostly written in Lisp.

110:57And that sort of new features of Emacs

111:02usually update all the Lisp packages

111:06and add new Lisp packages.

111:08And oh yeah, there's also some very obscure thing

111:13improved in the part that's not in Lisp.

111:16But that's usually not why you would upgrade

111:19to a new version of Emacs.

111:21There's a core implementation that sort of can read a file

111:26and it can put bits on the screen

111:29and it can sort of manage memory and buffers.

111:33And then what makes it an editor full of features

111:37is all the Lisp packages.

111:39And of course the design of how the Lisp packages

111:42interact with each other and with that sort of

111:46that base layer of the core immutable engine.

111:51But almost everything in that core engine in Emacs case

111:55can still be overridden or replaced.

111:59And so VS Code has a similar architecture

112:04where there is like a base engine

112:10that you have no control over.

112:14I mean, it's open source, but nobody except the people

112:18who work on that part changes it much.

112:22And it has a sort of a package manager

112:28and a whole series of interfaces for packages

112:32and an additional series of conventions

112:35for how packages should interact with the lower layers

112:38and with each other.

112:40And powerful primitive operations

112:43that let you move the cursor around

112:47or select pieces of text or delete pieces of text

112:51or interact with the keyboard and the mouse

112:54and whatever peripherals you have.

112:57And so the sort of the extreme extensibility

113:02and the package ecosystem that you see in VS Code

113:08is a mirror of very similar architectural features in Emacs.

113:13- Well, I'll have to give it a serious try

113:16'cause as far as sort of the hype and the excitement

113:20in the general programming community,

113:22VS Code seems to dominate.

113:24The interesting thing about PyCharm and what is it,

113:29PHP Storm, which are these JetBrains specific IDs

113:33that are designed for one programming language.

113:36It's interesting to, when an ID is specialized, right?

113:41- They're usually actually just specializations of IntelliJ

113:45because underneath it's all the same editing engine

113:50with different veneer on top.

113:55Where in VS Code, many things you do

114:00require loading third-party extensions.

114:05In PyCharm, it is possible to have third-party extensions

114:10but it is a struggle to create one.

114:14- Yes, and it's not part of the culture,

114:16all that kind of stuff.

114:17- Yeah, I remember that it might've been five years ago

114:21or so we were trying to get some better MyPy integration

114:26into PyCharm 'cause MyPy is sort of Python tooling

114:30and PyCharm had its own type checking heuristic thing

114:35that we wanted to replace with something based on MyPy

114:42because that was what we were using in the company.

114:44And for the guy who was writing that PyCharm extension,

114:49it was really a struggle to sort of find documentation

114:55and get the development workflow going

114:59and debug his code and all that.

115:02So that was not a pleasant experience.

115:06- Let me talk to you about parallelism.

115:08In your post titled "Reasoning about AsyncIO Semaphore,"

115:13you talk about a fast food restaurant in Silicon Valley

115:16that has only one table.

115:17Is this a real thing?

115:18I just wanted to ask you about that.

115:20Is that just like a metaphor you're using

115:21or is that an actual restaurant in Silicon Valley?

115:25- It was a metaphor, of course.

115:27- I can imagine such a restaurant.

115:29So for people who don't then read the thing, you should.

115:33But it was a idea of a restaurant where there's only

115:38one table and you show up one at a time

115:41and you're prepared.

§12Transcript · 1:55:43–2:05:46

115:43And I actually looked it up and there is restaurants

115:45like this throughout the world.

115:47And it just seems like a fascinating idea.

115:50You stand in line, you show up, there's one table.

115:53They ask you all kinds of questions,

115:56they cook just for you.

115:58That's fascinating.

115:58- It sounds like you'd find places like that in Tokyo.

116:02It sounds like a very Japanese thing.

116:04Or in the Bay Area, there are popular places

116:06that probably more or less work like that.

116:08I've never eaten at such a place.

116:10- The fascinating thing is you propose it's a fast food.

116:12This is all for a burger.

116:14- It was one of my rare sort of more literary

116:19or poetic moments where I thought I'll just open

116:23with a crazy example to catch your attention.

116:26And the rest is very dry stuff about locks and semaphores

116:31and how a semaphore is a generalization of a lock.

116:35- Well, it was very poetic and well delivered.

116:36And it actually made me wonder if it's real or not

116:39because you don't make that explicit.

116:41And it feels like it could be true.

116:43And in fact, I wouldn't be surprised if somebody

116:45like listens to this and knows exactly a restaurant

116:48like this in Silicon Valley.

116:49Anyway, can we step back and can you just talk

116:52about parallelism, concurrency, threading, asynchronous,

116:57all of these different terms?

116:59What is it, sort of a high philosophical level?

117:02The fisherman is back in the boat.

117:04- Well, the idea is if the fisherman has two fishing rods,

117:10since fishing is mostly a matter of waiting

117:13for a fish to nibble, well, it depends

117:15on how you do it actually.

117:16But if you're doing the style of fishing

117:20where you sort of, you throw it out

117:22and then you let it sit for a while

117:25until maybe you see a nibble,

117:27one fisherman can easily run two or three

117:30or four fishing rods.

117:32And so as long as you can afford the equipment,

117:35you can catch four times as many fish

117:37by a small investment in four fishing rods.

117:41And so since your time, you sort of say

117:45you have all Saturday to go fishing,

117:47if you can catch four times as much fish,

117:50you have a much higher productivity.

117:52- And that's actually, I think, how deep sea fishing is done.

117:55You could just have a rod and you put in a hole

117:57so you can have many rods.

117:58What, is there an interesting difference

118:01between parallelism and concurrency and asynchronous?

118:06Is there one subset of the other to you?

118:09Like, how do you think about these terms?

118:10- In the computer world, there is a big difference.

118:14When people are talking about parallelism,

118:18like a parallel computer,

118:20that's usually really several complete CPUs

118:26that are sort of tied together

118:29and share something like memory or an IO bus.

118:35Concurrency can be a much more abstract concept

118:40where you have the illusion

118:45that things happen simultaneously,

118:48but what the computer actually does

118:50is it spends a little time running this program for a while,

118:55and then it spends some time running that program

118:58for a while, and then spending some time

118:59for the third program for a while.

119:02- So parallelism is the reality,

119:05and concurrency is part reality, part illusion.

119:08- Yeah, parallelism typically implies

119:11that there is multiple copies of the hardware.

119:15- You write that implementing synchronization primitives

119:18is hard in that blog post,

119:20and you talk about locks and semaphores.

119:23Why is it hard to implement synchronization primitives?

119:27- Because at the conscious level,

119:29our brains are not trained to sort of keep track

119:34of multiple things at the same time.

119:39Like, obviously you can walk and chew gum at the same time,

119:43because they're both activities

119:45that require only a little bit of your conscious activity,

119:50but try balancing your checkbook

119:53and watching a murder mystery on TV.

119:57You'll mix up the digits,

119:59or you'll miss an essential clue in the TV show.

120:03- So why does it matter that the programmer,

120:05the human, is bad?

120:08- Because the programmer is,

120:10at least with the current state of the art,

120:12is responsible for writing the code correctly,

120:17and it's hard enough to keep track of a recipe

120:22that you just execute one step at a time.

120:27Chop the carrots, then peel the potatoes, mix the icing.

120:32You need your whole brain,

120:35when you're reading a piece of code,

120:38what is going on?

120:40Okay, we're loading the number of mermaids in variable A,

120:45and the number of mermen in variable B,

120:49and now we take the average or whatever.

120:52- I like how we're just jumping

120:54from metaphor to metaphor, I like it.

120:57- You have to keep in your head,

120:58what is in A, what is in B, what is in C?

121:02Hopefully you have better names.

121:04And that is challenging enough.

121:08If you have two different pieces of code

121:12that are sort of being executed simultaneously,

121:17whether it's using the parallel or the concurrent approach,

121:23if like A is the number of fishermen,

121:28and B is the number of programmers,

121:30but in another part of the code,

121:32A is the number of mermaids,

121:34and B is the number of mermen,

121:36and somehow that's the same variable.

121:40If you do it sequentially,

121:41if first you do your mermaid merpeople computation,

121:45and then you do your people in the boat computation,

121:48it doesn't matter that the variables are called A and B,

121:51and that is literally the same variable,

121:53because you're done with one use of that variable.

121:56But when you mix them together,

121:59suddenly the number of merpeople

122:02replaces the number of fishermen,

122:04and your computation goes dramatically wrong.

122:08- And there's all kinds of ordering of operations

122:11that could result in the assignment of those variables,

122:14and so you have to anticipate all possible orderings.

122:17- And you think you're smart,

122:18and you'll put a lock around it.

122:21And in practice, in terms of bugs per line,

122:25per 1,000 lines of code,

122:27this is an area where everything is worse.

122:30- So a lock is a mechanism by which you forbid

122:35only one chef can access the oven at a time.

122:40- Something like that.

122:42- And then semaphores allow you to do what, multiple ovens?

122:46- That's not a bad idea,

122:47because if you're sort of,

122:49if you're baking cakes,

122:52and you have multiple people all baking cakes,

122:55but there's only one oven,

122:56then maybe you can tell that the oven is in use,

122:59but maybe it's preheating.

123:01And so maybe you make a sign that says, "Oven in use,"

123:06and you flip the sign over,

123:08and it says, "Oven is free

123:10"when you're done baking your cake."

123:12That's a lock, that's sort of,

123:15and what do you do when you have two ovens,

123:18or maybe you have 10 ovens?

123:21You can put a separate sign on each oven,

123:23or maybe you can, sort of,

123:25someone who comes in wants to see at a glance,

123:29and maybe there's an electronic sign that says,

123:32"There are still five ovens available."

123:34Or maybe there are already three people waiting for an oven,

123:40so you can, if you see an oven that's not in use,

123:45it's already reserved for someone else

123:47who got in line first.

123:49And that's sort of what the restaurant metaphor

123:51was trying to explain.

123:53- Yeah, and so you're now tasked,

123:55you're sitting as a designer of Python

123:59with a team of brilliant core developers,

124:01and you have to try to figure out

124:03to what degree can any of these ideas be integrated and not.

124:06So maybe this is a good time to ask,

124:08what is AsyncIO,

124:11and how has it evolved since Python 3.4?

124:15- Wow, yeah, so we had this really old library

124:19for doing things concurrently,

124:24especially things that had to do with IO,

124:27and networking IO was especially sort of a popular topic.

124:32And in the Python standard library,

124:38we had a brief period where there was lots of development,

124:45and I think it was late '90s, maybe early 2000s,

124:49and like two little modules were added

124:53that were the state of the art of doing asynchronous IO,

124:56or sort of non-blocking IO,

124:59which means that you can keep

125:00multiple network connections open

125:02and sort of service them all in parallel

125:05like a typical web server does.

125:08- So IO is input and output,

125:09so you're writing either to the network,

125:11or reading from the network connection,

125:13or reading and writing to a hard drive, to storage.

125:16- Also possible.

125:17- And you can do the ideas you could do to multiple

125:21while also doing computation.

125:24So running some code that does some fancy stuff.

125:28- Yeah, like when you're writing a web server,

125:30when a request comes in,

125:32a user sort of needs to see a particular web page,

125:37you have to find that page maybe in the database

125:40and format it properly and send it back to the client,

125:43and there's a lot of waiting,

125:46waiting for the database, waiting for the network,

§13Transcript · 2:05:48–2:16:35

125:48and so you can handle hundreds or thousands

125:51or millions of requests concurrently on one machine.

125:55Anyway, ways of doing that in Python were kind of stagnated,

126:00and I forget, it might've been around 2012, 2014,

126:05when someone for the umpteenth time actually said,

126:12these async chat and async core modules

126:16that you have in a standard library

126:18are not quite enough to solve my particular problem,

126:22can we add one tiny little feature?

126:25And everybody said, no, that stuff is not,

126:29you're not supposed to use that stuff,

126:31write your own using a third-party library,

126:34and then everybody started the debate

126:35about what the right third-party library was.

126:39And somehow I felt that there was actually a cue for,

126:44well, maybe we need a better state-of-the-art module

126:50in the standard library for multiplexing input/output

126:55from different sources.

126:57You could say that it spiraled out of control a little bit,

127:00it was, at the time, it was the largest

127:03Python enhancement proposal that was ever proposed.

127:07- And you were deeply involved with that.

127:09- At the time, I was very much involved with that,

127:11I was like the lead architect.

127:13I ended up talking to people

127:18who had already developed serious third-party libraries

127:23that did similar things,

127:24and sort of taking ideas from them,

127:26and getting their feedback on my design,

127:30and eventually we put it in the standard library,

127:34and after a few years, I got distracted,

127:36I think the big thing that distracted me

127:38was actually type annotations.

127:40But other people kept it alive and kicking,

127:45and it's been quite successful, actually,

127:47in the world of Python web clients.

127:51- So initially, what are some of the design challenges there

127:54in that debate for the PEP,

127:56and what are some things that got rejected,

127:58what are some things that got accepted to stand out to you?

128:01- There are a couple of different ways

128:03you can handle parallel IO,

128:06and this happens sort of at an architectural level

128:09in operating systems as well,

128:11like Windows prefers to do it one way,

128:14and Unix prefers to do it the other way.

128:17You sort of, you have an object

128:20that represents a network endpoint,

128:23say a connection with a web browser that's your client,

128:26and say you're waiting for an incoming request.

128:32Two fundamental approaches are,

128:34okay, I'm waiting for an incoming request,

128:38I'm doing something else, come wake me up,

128:41or of course, sort of come tell me

128:42when something interesting happened,

128:45like a packet came in on that network connection.

128:48And the other paradigm is,

128:52we're on a team of a whole bunch of people

128:56with maybe a little mind,

128:58and we can only manage one web connection at a time,

129:02so I'm just sitting,

129:05looking at this web connection,

129:09and I'm just blocked until something comes in,

129:13and then I'm already waiting for it.

129:17I get the data, I process the data,

129:21and then I go back to the top and say,

129:23no, sort of, I'm waiting for the next packet.

129:27Those are about the two paradigms.

129:29One is a paradigm where there is sort of notionally

129:34a thread of control,

129:35whether it's an actual operating system thread

129:37or more an abstraction in async IO, we call them tasks.

129:41But a task in async IO or a thread in other contexts

129:46is devoted to one thing,

129:49and it has logic for all the stages,

129:52like when it's a web request,

129:54like first wait for the first line of the web request,

129:58parse it, because then you know if it's a get or a post

130:02or a put or whatever, or an error.

130:05Then wait until you have a bunch of lines

130:09until there's a blank line,

130:10then parse that as headers,

130:12and then interpret that,

130:14and then wait for the rest of the data to come in

130:18if there is any more that you expect,

130:21that sort of standard web stuff.

130:24And the other thing is,

130:26and there's always endless debate

130:27about which approach is more efficient

130:30and which approach is more error prone,

130:33where I just have a whole bunch of stacks in front of me,

130:36and whenever a packet comes in,

130:41I sort of look at the number of the packet,

130:43that there's some number on the packet,

130:45and I say, "Oh, that packet goes on this pile,"

130:49and then I can do a little bit,

130:51and then sort of that pile provides my context,

130:54and as soon as I'm done with the processing,

130:57I sort of, I can forget everything about what's going on,

131:02because the next packet will come in

131:03from some random other client,

131:05and it's that pile or it's this pile.

131:07And every time a pile is maybe empty or full

131:11or whatever the criteria is,

131:13I can toss it away or use it for a new space.

131:16But several traditional third-party libraries

131:21for asynchronous I/O processing in Python

131:24chose the model of a callback,

131:27and that's the idea where you have a bunch

131:29of different stacks of paper in front of you,

131:32and every time someone gives you a piece,

131:34gives you a new sheet,

131:36you decide which stack it belongs to.

131:38And that leads to a certain style of spaghetti code

131:44that I find sort of aesthetically not pleasing,

131:50and I was sort of never very successful,

131:54and I had heard many stories about people

131:56who were also sort of complaining

132:00about that style of coding.

132:01It was very prevalent in JavaScript at the time at least,

132:06because it was like how the JavaScript event loop

132:10basically works.

132:11And so I thought, well, the task-based model

132:15where each task has a bunch of logic,

132:19we had mechanisms in the Python language

132:22that we could easily reuse for that.

132:25And I thought, I want to build a whole library

132:29for asynchronous networking I/O,

132:31and all the other things

132:33that may need to be done asynchronously,

132:36based on that paradigm.

132:39And so I just chose a paradigm

132:41and tried to see how far I could get with that.

132:45And it turns out that it's a pretty good paradigm.

132:48- So people enjoy that kind of paradigm programming

132:51for asynchronous I/O, relative to callbacks.

132:55Okay, beautiful.

132:58So how does that all interplay with the infamous GIL,

133:03the Global Interpreter Lock?

133:05Maybe can you say what the GIL is,

133:08and how does it dance beautifully with asyncio?

133:12- The Global Interpreter Lock solves the problem

133:17that Python originally was not written

133:19with either asynchronous or parallelism in mind at all.

133:24There was no concurrency in the language.

133:26There was no parallelism.

133:27There were no threads.

133:30Only a small number of years

133:32into Python's initial development,

133:35all the new cool operating systems

133:38like SunOS and Silicon Graphics,

133:42Irix, and then eventually POSIX and Windows,

133:46all came with threading libraries

133:49that lets you do multiple things in parallel.

133:53And there is a certain sort of principle,

133:57which is the operating system handles the threads for you.

134:01And the program can pretend that there are as many CPUs

134:07as there are threads in the program.

134:13And those CPUs work completely independently.

134:17And if you don't have enough CPUs,

134:20the operating system sort of simulates those extra CPUs.

134:25On the other hand, if you have enough CPUs,

134:28you can get a lot of work done

134:31by deploying those multiple CPUs.

134:34But Python wasn't written to do that.

134:40And so as libraries for multithreading were added to C,

134:45but every operating system vendor

134:52was adding their own version of that.

134:55We thought, and maybe we were wrong,

134:58but at the time we thought,

134:59"Well, we quickly want to be able

135:01"to support these multiple threads."

135:04Because they seemed at the time in the early '90s,

135:07when they were new, at least to me,

135:09they seemed a cool, interesting programming paradigm.

135:13And one of the things that Python,

135:16at least at the time, felt was nice about the language

135:20was that we could give a safe version

135:23of all kinds of cool new operating system toys

135:28to the Python programmer.

135:30Like I remember one or two years before threading,

135:36I had spent some time adding networking sockets to Python.

135:41And they were very literal translation

135:45of the networking sockets

135:46that were in the BSD operating system, so Unix BSD.

135:50But the nice thing was if you were using sockets from Python,

135:55then all the things you can do wrong with sockets in C

135:59would automatically give you a clear error message

136:01instead of just ending up

136:03with a malfunctioning hanging program.

136:06And so we thought,

136:07"Well, we'll do the same thing with threading."

136:10But we didn't really want to rewrite the interpreter

136:15to be thread safe,

136:17because that would be a very complex refactoring

136:22of all the interpreter code and all the runtime code,

136:27because all the objects were written with the assumption

136:30that there's only one thread.

136:32And so we said, "Okay, well, we'll take our losses.

136:35We'll provide something that looks like threads.

§14Transcript · 2:16:39–2:29:08

136:39And as long as you only have a single CPU on your computer,"

136:43which most computers at the time did,

136:45"it feels just like threads."

136:48Because the whole idea of multiple threads in the OS

136:53was that even if your computer only had one CPU,

136:57you could still fire up as many threads as you wanted.

137:01Well, within reason, maybe 10 or 12, not 5,000.

137:04And so we thought we had conquered

137:09the abstraction of threads pretty well,

137:14because multi-core CPUs were not

137:18in most Python programmers' hands anyway.

137:22And then, of course, a couple of more iterations

137:26of Moore's law, and computers getting faster.

137:29And at some point, the chip designers decided

137:34that they couldn't make the CPUs faster,

137:38but they could still make them smaller.

137:40And so they could put multiple CPUs on one chip.

137:43And suddenly there was all this pressure

137:46about do things in parallel.

137:49And that's where the solution we had in Python didn't work.

137:55And that's sort of the moment that the GIL became infamous.

138:00Because the GIL was the solution we used

138:04to sort of take this single interpreter

138:09and share it between all the different operating system

138:12threads that you could create.

138:14And so as long as the hardware physically only had one CPU,

138:19that was all fine.

138:21And then as hardware vendors were suddenly telling us all,

138:25"Oh, you gotta parallelize.

138:27"Everything's gotta be parallelized."

138:30People started saying, "Oh, but we can use multiple threads

138:34"in Python."

138:35And then they discovered, "Oh, but actually all threads

138:39"run on a single core."

138:41- Yeah.

138:42I mean, is there a way, is there ideas in the future

138:46to remove the global interpreter log GIL?

138:49Like maybe multiple sub-interpreters,

138:52some tricky interpreters on top of interpreters

138:56kind of thing?

138:57- Yeah, there are a couple of possible futures there.

139:02The most likely future is that we'll get multiple

139:07sub-interpreters, which each run a completely

139:11independent Python program.

139:14- Nice.

139:15- But there's still some benefit of sort of faster

139:20communication between those programs.

139:25- But it's also managing for you this running

139:28a multiple Python programs.

139:30- Yeah.

139:31- So it's hidden from you, right?

139:33- It's hidden from you, but you have to spend more time

139:36communicating between those programs.

139:39Because the sort of, the attractive thing about the

139:43multi-threaded model is that the threads can share objects.

139:48At the same time, that's also the downfall of the

139:51multi-threaded programming model.

139:53Because when you do share objects, you weren't,

139:58and you didn't necessarily intend to share them,

140:01or there were aspects of those objects that were not

140:06reusable, you get all kinds of concurrency bugs.

140:11And so the reason I wrote that little blog post

140:15about semaphores was that concurrency bugs are just harder.

140:20It would be nice if Python had no global interpreter lock,

140:26and it had the so-called free threading,

140:28but it would also cause a lot more software bugs.

140:34The interesting thing is that there is still a possible

140:39future where we are actually going to, or where we could

140:43experiment at least with that, because there is a guy

140:48working for Facebook who has developed a fork of CPython

140:54that he called the no-gill interpreter, where he removed

141:00the gill and made a whole bunch of optimizations

141:05so that the single-threaded case doesn't run

141:08too much slower, and multi-threaded case will actually

141:13use all the cores that you have.

141:15And so that would be an interesting possibility

141:22if we would be willing as Python core developers

141:27to actually maintain that code indefinitely.

141:34And if we're willing to put up with the additional

141:38complexity of the interpreter and the additional

141:42sort of overhead for the single-threaded case.

141:45And I'm personally not convinced that

141:49there are enough people needing the speed of multiple

141:56threads with their Python programs that it's worth

142:03to sort of take that performance hit and that complexity hit.

142:08And I feel that the gill actually is a pretty nice

142:13Goldilocks point between no threads and all threads

142:18all the time, but not everybody agrees on that.

142:21So that is definitely a possible future.

142:24The sub-interpreters look like a fairly safe bet for 3.12.

142:29So say a year from now.

142:32- A year, so the goal is to do a new version

142:34every year for Python.

142:36Let me ask you perhaps a fun question,

142:39but there's a philosophy to it too.

142:42Will there ever be a Python 4.0?

142:45Now, before you say it's currently a joke and probably not,

142:50we're gonna go to 3.99 or 3.999,

142:55can you imagine possible features that Python 4.0

143:02might have that would necessitate the creation

143:07of the new 4.0 given the amount of pain and joy,

143:12suffering and triumph that was involved in the move

143:16between version two and version three?

143:19- Yeah, well, we, as a community

143:26and as a core development team,

143:28we have a large amount of painful memories

143:33about the Python 3 transition,

143:36which is one reason that sort of everybody is happy

143:43that we've decided there's not going to be a 4.0

143:47at least not anytime soon.

143:50And if there is going to be one,

143:52we'll sort of plan the transition very differently.

143:56Because clearly we underestimated the pain

144:00that transition caused for our users in the Python 3 case.

144:05And had we known we could have sort of designed

144:10Python 3 somewhat differently without making it any worse,

144:16we just thought that we had a good plan,

144:20but we underestimated what sort of the users

144:25were capable of when it comes to that kind of transition.

144:28- By the way, I think we talked way before,

144:32like a year and a half before the Python 2 officially--

144:37- End of life? - End of life.

144:39- Oh, yeah.

144:41- What was that?

144:41What was your memory of the end of life?

144:43Did you shed a tear on January 1st, 2020?

144:47Was there, were you standing alone?

144:49- Everyone on the core team had basically moved

144:51on years before.

144:54- Yeah.

144:54- It was purely, it was a little symbolic moment

144:58to signal to the remaining users

145:03that there was no longer going to be any new releases

145:08or support for Python 2.7.

145:12- Did you shed a single tear

145:15while looking out over the horizon?

145:18(laughing)

145:19- I'm not a very poetic person

145:21and I don't shed tears like that, but no.

145:25(laughing)

145:26- Yeah, we actually had planned a party,

145:29but the party was planned for the Python,

145:32the US Python conference that year,

145:35which would never happened, of course,

145:36because of the pandemic.

145:38- Oh, was it like in March or something?

145:39- Yeah, the conference was going to be,

145:42I think, late April that year.

145:44- Oh.

145:45- So that was a very difficult decision to cancel it,

145:49but they did.

145:51So anyway, if we're going to have a Python 4,

145:54we're going to have to have both a different reason

145:57for having that and a different process

146:02for managing the transition.

146:04- Can you imagine a possible process that,

146:07so I think you're implying that if there is a 4.0,

146:11in some ways it would break back compatibility?

146:14- Well, so here is a concrete thought I've had,

146:20and I'm not unique, but not everyone agrees with this,

146:23so this is definitely a personal opinion.

146:26If we were to try something like that Nogill Python,

146:32my expectation is that it would feel just different enough,

146:40at least for the part of the Python ecosystem

146:49that is heavily based on C extensions,

146:54and that is like the entire machine learning,

146:58data science, scientific Python world

147:02is all based on C extensions for Python.

147:06And so those people would likely feel the pain the most

147:14because even if we don't change anything

147:19about the syntax of the language

147:21and the semantics of the language

147:23when you're writing Python code,

147:25we could even say, suppose that after Python say 3.19,

147:30instead of 3.20, we'll have 4.0.

147:33Suppose that's the time when we flip the switch to 4.0,

147:38we'll not have a GIL.

147:41Imagine it was like that.

147:43So I would probably say that particular year,

147:48the release that we name 4.0 will be syntactically,

147:54it will not have any new syntactical features,

147:58no new modules in the standard library,

148:01no new built-in functions.

148:03Everything will be at the Python level

148:07will be purely compatible with Python 3.19.

148:12However, extension modules will have to make a change.

148:17They will have to be recompiled.

148:21They will not have the same binary interface.

148:26The semantics and APIs for some things

148:34that are frequently accessed by C extensions

148:38will be different.

148:40And so for a pure Python user, 4.0 would be a breeze,

148:45except that there are very few pure Python users left

148:50because everybody who is using Python

148:52for something significant is using third-party extensions.

148:56There are like, I don't know,

148:58several hundreds of thousands of third-party extensions

149:01on the PyPI service.

149:06And I'm not saying they're all good,

149:08but there is a large list of extensions

§15Transcript · 2:29:12–2:41:28

149:12that would have to do work.

149:13And some of those extensions

149:14are currently already low on maintainers

149:19and they're struggling to keep afloat.

149:23- So there you can give a huge heads up to them

149:26if you go to 4.0 to really keep developing it.

149:30- Yeah, we'd probably have to do something like

149:32several years before, who knows, maybe five years earlier,

149:38like 3.15, we would have to say,

149:42and I'm just making the specific numbers up,

149:45but at some point we'd have to say

149:47the Nogail Python could be an option.

149:52It might be a compile time option.

149:55If you want to use Nogail Python,

150:00you have to recompile Python from source for your platform

150:04using your tool set.

150:06All you have to do is change one configuration variable

150:09and then you just run make or configure and make

150:13and it will build it for you.

150:15But now you also have to use

150:18the Nogail compatible versions

150:21of all extension modules you want to use.

150:24And so as long as many extension modules

150:27don't have fully functional sort of variants

150:32that work in the Nogail world,

150:35that's not a very practical thing for Python users,

150:39but it would allow extension developers

150:43to test the waters,

150:46see what they need to syntactically

150:49to be able to compile at all.

150:51Maybe they're using functions

150:54that are defined by the Python 3 runtime

150:56that won't be in the Python 4 runtime.

150:59Those functions will not work.

151:00They'll have to find an alternative,

151:04but they can experiment with that

151:06and sort of write test applications.

151:09And that would be a way to transition.

151:11And that could be a series of releases

151:15where the Python 4 is more and more imminent.

151:20We have supported more and more third-party

151:24extension modules to have solid support

151:28that works for Nogail Python for that new API.

151:33And then sort of Python 4.0 is like the official moment

151:38that the mayor comes out and cuts the ribbon.

151:43And now Python, now the sort of Nogail mode

151:47is the default and maybe the only mode there is.

151:50- The internet wants to know from Reddit.

151:54It's a small and fun question.

151:58There's many fun questions,

151:59but out of the PyPI packages,

152:04PyPI packages, do you have ones you like?

152:09In your opinion, are there must-have PyPI libraries

152:12or ones you use all the time constantly?

152:15- Oh my, I should really have a standard answer

152:19for that question, but like a positive standard answer.

152:23But my current standard answer is that

152:25I'm not a big user of third-party packages.

152:30When I write Python code, I'm usually developing

152:33some tooling around building Python itself.

152:37And the last thing we want is dependencies

152:41on third-party packages.

152:43So I tend to just use the standard library and--

152:46- That's where your focus is, that's where your mind is.

152:50But do you keep an eye of what's out there

152:53to understand where the standard library

152:56could be moving, should be moving?

152:58It's a good kind of landscape of what's missing

153:01from the standard library.

153:02- Well, usually when something's missing

153:04from the standard library, nowadays,

153:07it is a relatively new idea

153:13and there is a third-party implementation

153:17or maybe possibly multiple third-party implementations,

153:22but they evolve at a much higher rate

153:25than they could when they're in the standard library.

153:28So it would be a big reduction in activity

153:33to incorporate things like that in the standard library.

153:38So I like that there is a lively package ecosystem

153:41and that sort of recent trends in the standard library

153:45are actually that we're doing the occasional

153:47spring cleaning where we're just,

153:49we're choosing some modules

153:56that have not had a lot of change in a long time

154:02and that maybe would be better off not existing

154:07at all at this point, because there might be

154:09a better third-party alternative anyway,

154:13and we're sort of slowly removing those.

154:17Often those are things that I sort of,

154:20I spiked somewhere in 1992 or 1993.

154:24If you look through the commit history, it's very sad.

154:29All cosmetic changes, like changes in the indentation style

154:34or the name of this other standard library module

154:38got changed or nothing of any substance.

154:42The API is identical to what it was 20 years ago.

154:47- So speaking of packages, they have a lot of impact

154:52on a lot of people's lives.

154:54Does it make sense to you why Python has become

154:57the primary, the dominant language

154:59for the machine learning community?

155:00So packages like PyTorch, TensorFlow, Scikit-learn,

155:05and even like the lower level stuff like NumPy, SciPy,

155:08Pandas, Matplotlib with visualization.

155:11Can you like, does it make sense to you why it,

155:15permeated the entire data science,

155:18machine learning, AI community?

155:21- Well, part of it is an effect that's as simple

155:25as we're all driving on the right side of the road, right?

155:29It's compatibility.

155:33- Yeah.

155:34- It's, and part of it is not quite as fundamental

155:42as driving on the right side of the road,

155:44which you have to do for safety reasons.

155:46I mean, you have to agree on something.

155:48They could have picked JavaScript or Perl.

155:52There was a time in the early 2000s

155:54that it really looked like Perl was going to dominate

155:58like biosciences, because DNA search was all based

156:02on regular expressions and Perl has the fastest

156:05and most comprehensive regular expression engine, still does.

156:08- I spent quite a long time with Perl.

156:11That was another letting go.

156:14Letting go of this kind of data processing system.

156:19- The reasons why Python became the lingua franca

156:24of scientific code and machine learning in particular

156:29and data science, it really had a lot to do

156:36with anything was better than C or C++.

156:42Recently, a guy who worked

156:44at Lawrence Livermore National Laboratories

156:47in the sort of computing division wrote me his memoirs

156:52and he had his own view of how he helped something

157:00he called computational steering into existence.

157:04And this was the idea that you take libraries

157:10that in his days were written in Fortran

157:12that solved universal mathematical problems.

157:17And those libraries still work,

157:20but the scientists that use the libraries,

157:25use them to solve continuously different

157:30specific applications and answer different questions.

157:34And so those poor scientists were required

157:39to use say Fortran because Fortran was the language

157:44that the library was written in.

157:47And then the scientists would have to write an application

157:51that sort of uses the library to solve a particular equation

157:55or set off of answer a set of questions.

157:59And the same for C++ because there's interoperability.

158:06So the dusty decks are written either in C++ or Fortran.

158:10And so Paul Dubois was one of the people who,

158:16I think in the mid '90s saw that you needed

158:21a higher level language for the scientists

158:26to sort of tie together the fundamental

158:31mathematical algorithms of linear algebra and other stuff.

158:36And so gradually some libraries started appearing

158:42that did very fundamental stuff

158:46with arrays of numbers in Python.

158:49I mean, when I first created Python,

158:52I was not expecting it to be used

158:54for arrays of numbers much.

158:55I thought that was like an outdated data type

158:59and everything was like objects and strings

159:02and like Python was good and fast at string manipulation

159:06and objects obviously, but arrays of numbers

159:09were not very efficient and the multidimensional arrays

159:13didn't even exist in the language at all.

159:15But there were people who realized

159:19that Python had extensibility that was flexible enough

159:25that they could write third party packages

159:30that did support large arrays of numbers

159:33and operations on them very efficiently.

159:35And somehow they got a foothold

159:39through sort of different parts of the scientific community.

159:44I remembered that the Hubble Space Telescope people

159:47in Baltimore were somehow big Python fans in the late '90s.

159:52And at various points, small improvements were made

159:57and more people got in touch with using Python

160:02to derive these libraries of interesting algorithms.

160:07And like once you have a bunch of scientists

160:12who are working on similar problems,

160:14say they're all working on stuff that comes in

160:18from the Hubble Space Telescope,

160:20but they're looking at different things.

160:21Some are looking at stars in this galaxy,

160:24other are looking at galaxies.

160:26The math is completely different,

160:28but the underlying libraries are still the same.

160:33And so they exchange code.

160:36They say, well, I wrote this Python program

160:39or I wrote a Python library to solve this class of problems.

160:43And the other guys either say, oh, I can use that library too

160:48or if you make a few changes, I can use that library too.

160:52Why start from scratch in Perl or JavaScript

160:57where there's not that infrastructure

160:59for arrays of numbers yet, whereas in Python you have it.

161:04And so more and more scientists at different places

161:07doing different work discovered Python

161:12and then people who had an idea

161:16for an important new fundamental library decided,

161:20oh, Python is actually already known to our users.

161:25So let's use Python as the user interface.

161:28I think that's how Tensor, I imagine at least

§16Transcript · 2:41:31–2:51:50

161:31that's how TensorFlow ended up with Python

161:33as the user interface.

161:35- Right, but with TensorFlow,

161:37there's a deeper history of what the community,

161:42so it's not just like what packages it needs.

161:45It's like what the community leans on

161:47for a programming language 'cause TensorFlow

161:50had a prior library that was internal to Google

161:55but there was also competing machine learning frameworks

161:58like Theano, Caffe, they were in Python.

162:02There was some Scala, some other languages

162:06but Python was really dominating it.

162:08And it's interesting because there's other languages

162:13from the engineering space like MATLAB

162:16that a lot of people used but different design choices

162:20by the company, by the core developers

162:23led to it not spreading.

162:26And one of the choices of MATLAB by MathWorks

162:29is to not make it open source, right?

162:31Or not having people pay.

162:34- It was a very expensive product

162:36and so universities especially disliked it

162:40because it was a price per seat.

162:42I remember hearing.

162:45- Yeah, but I think that's not why it failed

162:48or it failed to spread.

162:50I think the universities didn't like it

162:52but they would still pay for it.

162:55The thing is it didn't feed into that GitHub

162:58open source packages culture.

163:02So like, and that's somehow a precondition

163:05for viral spreading, the hacker culture,

163:09like the tinkerer culture.

163:11With Python it feels like you can build a package

163:13from scratch or solve a particular problem

163:16and get excited about sharing that package with others.

163:19And that creates an excitement about a language.

163:22- I tend to like Python's approach to open source

163:25in particular because it's sort of,

163:27it's almost egalitarian.

163:30There's little hierarchy.

163:34There's obviously some because like you all need to decide

163:38whether you drive on the left or the right side

163:40of the road sometimes.

163:42But there is a lot of access for people with little power.

163:47You don't have to work for a big tech company

163:50to make a difference in the Python world.

163:52We have affordable events that really care about community

163:59and support people and sort of the community

164:03is like a big deal at our conferences

164:08and in the PSF.

164:11When the PSF funds events,

164:12it's always about growing the community.

164:17The PSF funds very little development.

164:21They do some, but most of the money that the PSF forks out

164:28is to community fostering things.

164:35- So speaking of egalitarian,

164:37last time we talked four years ago,

164:39it was just after you stepped down from your role

164:43as the benevolent dictator for life, BDFL.

164:47Looking back, what are your insights and lessons

164:51you learned from that experience

164:52about Python developer community, about human nature,

164:56about human civilization, life itself?

165:00- Oh my.

165:04I probably held onto the position too long.

165:07I remember being just extremely stressed for a long time

165:13and it wasn't very clear to me what was leading,

165:21what was causing the stress.

165:23And looking back,

165:30I should have sort of relinquished my central role

165:35as BDFL sooner.

165:39- What were the pros and cons of the BDFL role?

165:42Like what were the, you not relinquishing it,

165:45what are the benefits of that for the community?

165:48And what are the drawbacks?

165:50- Well, the benefits for the community would be things like

165:58clarity of vision and sort of a clear direction

166:03because I had certain ideas in mind when I created Python.

166:10And while I sort of let myself be influenced

166:16by many other ideas as Python evolved

166:19and became more successful and more complex and more used,

166:27I also stuck to certain principles.

166:30And it's still hard to say

166:31what are Python's core principles.

166:34But the fact that I was playing that role

166:40and sort of always very active,

166:43grew the community in a certain way.

166:47It modeled to the community how to think about

166:52how to solve a certain problem.

166:55- Well, that was a source of stress,

166:57but it was also beneficial to the community.

166:58- It was a source of stress for me personally,

167:01but it was beneficial for the community

167:03because people sort of over time

167:08had learned how I was thinking and could predict

167:13but how I would decide about a particular issue

167:18and not always perfectly, of course.

167:20But there wasn't a lot of jerking around

167:24like this year, we're all,

167:26but this year the Democrats are in power

167:29and we're doing these kinds of things.

167:31And now the Republicans are in power

167:33and they roll all that back and do those kinds of things.

167:36There is a clear, fairly straight path ahead.

167:41And so fortunately the successor structure

167:45with the steering council has sort of found a similar way

167:50of leading the community in a fairly steady direction

167:55without stagnating.

167:58And for me personally, it's more fun

168:00because there are things I can just ignore.

168:03Yeah, oh yeah, there's a bug in multi-processing.

168:07Let someone else decide whether that's important

168:10to solve or not.

168:11I'll stick to typing in the async IO

168:16and the faster interpreter.

168:18- Yeah, it allows you to focus a little bit more.

168:20- Yeah.

168:21- What are interesting differences in culture

168:25if you can comment on between Google, Dropbox

168:27and Microsoft from a Python programming perspective,

168:30all places you've been to, the positive.

168:32Is there a difference or is it just about people

168:37and there's great people everywhere

168:40or is there culture differences?

168:41- So Dropbox is much smaller than the other two

168:46in your list.

168:47- Yeah.

168:48- So that is a big difference.

168:52- The set of products they provide is narrower

168:55so they're more focused.

168:57Smaller code base.

168:57- Yeah, and Dropbox sort of,

169:00at least during the time I was there,

169:03had the tendency of sort of making a big plan,

169:08putting the whole company behind that plan for a year

169:12and then evaluate and then suddenly find that

169:17everything was wrong about the plan

169:19and then they had to do something completely different.

169:22So there was like the annual engineering reorg

169:28was sort of an unpleasant tradition at Dropbox

169:31because like, oh, there's a new VP of engineering

169:34and so now all the directors are being reshuffled

169:37and this guy was in charge of infrastructure one year

169:42and the next year he was made in charge of,

169:45I don't know, product development.

169:48It's fascinating 'cause like,

169:49you don't think about these companies internally

169:52but Dropbox to me from the very beginning

169:55was one of my favorite services.

169:57There's certain like programs and online services

169:59that make me happy, make me more efficient

170:03and all that kind of stuff

170:04but one of the powers of those kinds of services,

170:07they disappear.

170:08You're not supposed to think about how it all works

170:10but it's incredible to me

170:12that you can sync stuff effortlessly

170:15across so many machines so quickly

170:19and like don't have to worry about conflicts.

170:21They take care of the,

170:23you know, as a person that comes from a version

170:25of repositories and all that kind of stuff

170:27or merge is super difficult

170:30and just keeping different versions of different files

170:33is very tricky.

170:34The fact that they could take care of that is just,

170:35I don't know.

170:36The engineering behind the scenes must be super difficult

170:40both on the compute infrastructure and the software.

170:43- A lot of internal sort of hand-wringing

170:47about things like that

170:49but the product itself always worked very smoothly.

170:53- Yeah.

170:54Well, there's probably a lot of lessons to that.

170:56You can have a lot of turmoil inside

170:58on the engineering side

170:59but if the product is good, the product is good

171:03and maybe don't mess with that either.

171:05You know, when it's good,

171:06it's like with Google, focus on the search and the ads.

171:10Right?

171:12- The money will come.

171:13- Yeah.

171:14And to make sure that's done extremely well

171:16and don't forget what you do extremely well

171:19in what ways do you provide value and happiness

171:23to the world?

171:23Make sure you do that well.

171:25Is there something else to say about Google and Microsoft?

171:29Microsoft has had a very fascinating shift recently

171:33with a new CEO,

171:35with, you know, recent CEO,

171:37with purchasing GitHub,

171:39embracing open source culture,

171:41embracing the developer culture.

171:43It's pretty interesting to see.

171:44- That's like why I joined Microsoft.

171:47I mean, after retiring and thinking

171:50that I would stay retired for the rest of my life,

§17Transcript · 2:51:53–3:02:33

171:53which of course was a ridiculous thought,

171:56but I was done working for a bit

171:59and then the pandemic made me realize

172:01that work can also provide a source of fulfillment,

172:06keep you out of trouble.

172:11Microsoft is a very interesting company

172:14because it has this incredible,

172:17very long and varied history

172:21and this amazing catalog of products

172:25that many of which also date way back.

172:30I mean, I've been talking to a bunch of Excel people lately

172:35and Excel is like 35 years old

172:39and they can still read spreadsheets

172:42that they might find on an old floppy drive.

172:46- Yeah.

172:49Yeah, there's, man,

172:49there've been so many incredible tools through the years.

172:53Excel, one of the great shames of my life

172:57is that I've never learned how to use Excel well.

173:02I mean, it just always felt like so many features are there.

173:05It's similar with ideas like PyCharm.

173:08It feels like I converge quickly

173:11to the dumbest way to use a thing to get the job done

173:14when clearly there's so much more power at your fingertips.

173:17- Yeah.

173:18- But I do think there's probably expert users of Excel.

173:22- Oh, Excel is a cash cow actually.

173:26- Oh, it actually brings in money.

173:27Oh, that's interesting. - Oh, yeah.

173:28A lot of the engineering,

173:31sort of if you look deep inside Excel,

173:33there's some very good engineering,

173:36very, very impressive stuff.

173:39- Okay, now I need to definitely learn Excel a little better.

173:42I had issues because I'm a keyboard person,

173:45so I had issues coming up with shortcuts.

173:47I mean, Microsoft sometimes, it's changed over the years,

173:51but sometimes they kind of want to make things easier

173:54for you on the surface,

173:55and therefore make it harder for like people

174:00that like to have shortcuts and all that kind of stuff

174:03to optimize their workflow.

174:05Now, Excel's probably, people are probably yelling at me.

174:07It's like, no, Excel probably has a lot of ways

174:10to optimize workflow.

174:11- In fact, I keep discovering

174:13that there are many features in Excel

174:15that only exists at keyboard shortcuts.

174:18- Yeah, that's the sense I have.

174:21And now, like I'm embarrassed that it's just--

174:23- You just have to know what they are.

174:25- Yeah.

174:26- That's like, there's no logic or reason

174:30to the assignment of the keyboard shortcuts

174:32because they go back even longer than 35 years.

174:37- Can you maybe comment about Satya Nadella

174:39and how hard it is for a CEO to sort of pivot a company

174:43towards open source, towards developer culture?

174:45Is there something you could see about like,

174:48what's the role of leadership in such a pivot

174:52and definition of a new vision?

174:54- I've never met him, but I hear he's just a really sharp,

174:59he's just a really sharp thinker,

175:03but he also has an incredible business sense.

175:09He took the organization that had very solid pieces,

175:12but that was also struggling

175:17with all sorts of shameful things,

175:20especially the Steve Ballmer time.

175:23I imagine in part through his personal charm and thinking,

175:27and of course the great trust

175:29that the rest of the leadership has in him,

175:32he managed to really turn the company around

175:36and sort of change it from openly hostile to open source

175:41to actively embracing open source.

175:47And that doesn't mean that suddenly Excel

175:49is going to go open source,

175:51but that means that there's room for a product like VS Code,

175:54which is open source.

175:56- Yeah, that's fascinating.

175:57It gives me faith that large companies

176:01with good leadership can grow, can expand,

176:04can change and pivot and so on, develop,

176:07'cause it gets harder and harder as the company gets large.

176:10You wrote a blog post in response to a person

176:13looking for advice about whether with a CS degree

176:16to choose a nine to five job or to become an entrepreneur.

176:21It's an interesting question.

176:23If you just think from first principles right now,

176:26somebody has took a few years in programming,

176:29has loved software engineering,

176:31in some sense creating Python is an entrepreneurial endeavor.

176:35That's a choice that a lot of people

176:39that are good programmers have to make.

176:40Do I work for a big company or do I create something new?

176:45- Or you can work for a big company

176:50and create something new there.

176:52- Oh, inside the-

176:54- Yeah, I mean, big companies have individuals

176:58who create new stuff that eventually grows big all the time.

177:03- And if you're the person that creates a new thing

177:06and grows big, you'll have a chance

177:08to move up quickly in the company to run that thing.

177:11- If that's your aspiration, what can also happen

177:15is that someone is a brilliant engineer

177:19and sort of builds a great first version of a product

177:25and has no aspirations to then become a manager

177:30and grow the team from five people to 20 people

177:33to 100 people to 1000 people

177:36and be in charge of hiring and meetings.

177:40And they move on to inventing another crazy thing

177:45inside the same company,

177:46or sometimes they found a startup

177:51or they move to a different great large or small company.

177:55There's all sorts of models.

177:58And sometimes people sort of do have this whole trajectory

178:03from engineer buckling down, writing code,

178:07not nine to five, but more like noon till midnight,

178:13seven days a week, and coming up with a product

178:18and sort of staying in charge.

178:22I mean, if you take Drew Houston, Dropbox's founder,

178:27he is still the CEO.

178:28And at least when I was there,

178:32he had not checked out or anything.

178:33He was a good CEO, but he had started out

178:39as the technical inventor or co-inventor.

178:43And so he was someone who, I don't know,

178:47if he always aspired that, I think when he was 16,

178:50he already started a company.

178:52So maybe he did, but he sort of,

178:54it turned out that he did have the personal

179:00sort of skillset needed to grow and stay on top.

179:05And other people sort of are brilliant engineers

179:10and horrible at management.

179:12I count myself at least in the second category.

179:16- So your first love and still your love

179:19is to be the quote unquote individual contributor.

179:22So the programmer.

179:23- Yep.

179:24- Do you have advice for a programming beginner

179:29on how to learn Python the right way?

179:32- Find something you actually want to do with it.

179:41If you say, I want to learn skill X,

179:46that's not enough motivation.

179:48You need to pick something,

179:50and it can be a crazy problem you want to solve.

179:55It can be completely unrealistic.

179:57But something that challenges you

180:03into actually learning coding in some language.

180:11- And there's so many projects out there

180:12you can look for, like that doesn't have to be

180:14some big ambitious thing.

180:15It could be writing a small bot.

180:18If you're into social media,

180:19you can write a Reddit bot or a Twitter bot

180:21or some aspect of automating something

180:26that you do every single day,

180:28processing files, all that kind of stuff.

180:30- Nowadays, you can take machine learning components

180:34and sort of plug those things together.

180:38So you can do cool stuff with them.

180:40- So that's actually a really good example.

180:41So if you're interested in machine learning,

180:43the state of machine learning is such

180:45that a tutorial that takes an hour

180:49can get you to start using pre-trained models

180:53to do something super cool.

180:54And that's a good way to learn Python

180:56'cause you learn just enough to run this model,

180:58and that's a sneaky way to get in there

181:01to figure out how to import stuff,

181:04how to write basic I/O, how to run functions.

181:09I'm not sure if it's the best way

181:11to learn the basics in Python,

181:13but it could be nice to just fall in love first

181:15and then figure out the basics, right?

181:17- Yeah, you can't expect to learn Python

181:21from a one-hour video.

181:23Kind of blanking out on the name of someone

181:26who wrote a very funny blog post

181:31where he said, "I see all these ads for things

181:35like learn Python in 10 days or so."

181:40And he said, "The goal should be learn Python in 10 years."

181:45- That's hilarious, but I completely disagree with that.

181:49I think the criticism behind that is that

181:51the places just like the blog post from earlier,

181:55the places that tell you learn Python

181:57in five minutes or 10 minutes,

181:58they're actually usually really bad tutorials.

182:01So the thing is, I do believe that you can learn a thing

182:05in an hour to get some interesting, quick, it hooks you.

182:11But it just takes a tremendous amount of skill

182:14to be that kind of educator.

182:16Richard Feynman was able to condense a lot of ideas

182:18in physics in a very short amount of time,

182:21but that takes a deep, deep understanding.

182:23And so yes, of course, the actual,

182:25I think the 10 years is about the experience,

182:29the pain along the way, and there's something fundamental.

182:31- Well, you have to practice.

182:33You can memorize the syntax, but, well, I couldn't,

§18Transcript · 3:02:37–3:13:02

182:37but maybe someone else can,

182:39but that doesn't make you a coder.

182:42- Yeah, actually, coding has changed in fascinating ways

182:46'cause so much of coding is copying, pasting

182:49from Stack Overflow and then adjusting,

182:52which is another way of coding.

182:53And I don't wanna talk down to that kind of style of coding

182:56because it's kind of nicely efficient.

182:58But you know where that is going?

183:00- Code generation?

183:03- No, seriously, GitHub Copilot.

183:05- Yeah, Copilot.

183:06- I use it every day and it-

183:08- Really?

183:09- Yeah, it writes a lot of code for me.

183:11And usually it's slightly wrong,

183:13but it still saves me typing

183:16because all I have to do is change one word

183:20in a line of text that otherwise it generated perfectly.

183:23And how many times are you looking for,

183:27oh, what was I doing this morning?

183:29I was looking for an begin marker

183:31and I was looking for an end marker.

183:34And so begin is blah, blah, blah, search for begin.

183:39This is the begin token.

183:43And then the next line I type E

183:46and it completes the whole line with end instead of begin.

183:51That's a very simple example.

183:52Sometimes it sort of, if I name my function right,

183:56it writes a five or 10 line function.

183:58- And you know Python enough

184:03to very quickly then detect the issues.

184:06It becomes a really good dance partner then.

184:09- It doesn't save me a lot of thinking,

184:11but since I'm a poor typist,

184:13I'm very much appreciative of all the typing it does for me.

184:18Much better actually than the previous generation

184:23of suggestions that are also still built in VS Code

184:26where when you hit like a dot,

184:29it tries to guess what the type is of the variable

184:34to the left of the dot.

184:35And then it gives you a list,

184:37a pop down menu of what the attributes of that object are.

184:42But Copilot is much, much smoother than that.

184:44- Well, it's fascinating to hear

184:46that you use GitHub Copilot.

184:49Do you think, do you worry about the future of that?

184:52Did the automatic code generation,

184:56the increasing amount of that kind of capability,

184:59are programmers jobs threatened

185:03or is there still a significant role for humans?

185:05- Are programmers jobs threatened

185:07by the existence of Stack Overflow?

185:09I don't think so.

185:12It helps you take care of the boring stuff

185:14and you shouldn't try to use it to do something

185:18that you have no way of understanding what you're doing yet.

185:23A tool like that is always best

185:26when the question you're asking is,

185:29please remind me of how I do this,

185:32which I could do, I could look up how to do it,

185:37but right now I've forgotten

185:40whether the method is called foo or bar

185:44or what the shape of the API is.

185:47Does it use a builder object or a constructor

185:50or a factory or something else?

185:55And what are the parameters?

185:57It serves that role.

185:59It's like a great assistant,

186:02but the creative work of sort of deciding

186:05what you want the code to do is totally yours.

186:09- What do you think is the future of Python

186:12in the next 10, 20, 50 years, 100 years?

186:15You look forward.

186:16You ever imagine a future of human civilization

186:20or living inside the metaverse on Mars,

186:25humanoid robots everywhere?

186:27What part does Python play in that?

186:29- It'll eventually become sort of a legacy language

186:35that plays an important role,

186:36but that most people have never heard of

186:39and don't need to know about,

186:41just like all kinds of basic structures in biology,

186:46like mitochondria.

186:51- So it permeates all of life, all of digital life,

186:55but people just build on top of it

186:57and they only know the stuff that's on top of it.

186:59- Yeah.

187:01- Because you build layers of abstractions.

187:03I mean, most programmers nowadays

187:06rarely need to do binary arithmetic, right?

187:11- Yeah.

187:12- Yeah, or even think about it or even learn about it,

187:16or they can go quite far without knowing.

187:19- I started building little digital circuits

187:24out of NAND gates that I built myself

187:26with transistors and resistors.

187:29So I'd sort of, I feel very blessed that

187:33with that start when I was a teenager,

187:38I learned some of the basic, at least concepts

187:43that go into building a computer.

187:46And I sort of, every part,

187:49I have some understanding what it's for

187:54and why it's there and how it works.

187:57And I can forget about all that most of the time,

188:00but I sort of, I enjoy knowing, oh, if you go deeper,

188:05at some point you get to NAND gates

188:08and half adders and shift registers.

188:11And when it comes to the point of how do you actually

188:16make a chip out of silicon, I have no idea.

188:18That's just magic to me.

188:20- But you enjoy knowing that you can walk a while

188:23towards the lower and lower layers, but you don't need to.

188:27It's nice.

188:28- The other day as a sort of a mental exercise,

188:32I was trying to figure out if I could build

188:35flip-flop circuits out of relays.

188:42I was just sort of trying to remember,

188:47oh, how does a relay work?

188:49Yeah, there's like this electromagnetic force

188:52that pulls a switch open or shut.

188:55And you can have like, it can open one switch

189:00and shut another, and you can have multiple contacts

189:05that go at once.

189:07And how many relays do I really need to sort of represent

189:10one bit of information?

189:12Can the relay just feed on itself?

189:14And it was, I don't think I got to the final solution,

189:18but it was fun that I could still do a little bit

189:23of problem solving and thinking at that level.

189:26- And it's cool how we build on top of each other.

189:29So there's people that are just,

189:31you stood on the shoulders of giants

189:33and there's others who'll stand on your shoulders,

189:35and it's a giant, beautiful hierarchy.

189:38- Yeah, I feel I sort of covered this middle layer

189:41of the technology stack where it sort of peters out

189:45below the level of NAND gates.

189:50And at the top, I sort of, I lose track

189:54when it gets to machine learning.

189:56- And then eventually the machine learning

189:58will build higher and higher layers

190:00that will help us understand the lowest layer

190:03of the physics, and thereby the universe figures out

190:07how it itself works.

190:10- Maybe, maybe not.

190:12Yeah, I did, I mean, it's possible.

190:14I mean, if you think of human consciousness,

190:17if that's even the right concept,

190:20it's interesting that sort of we have this

190:25super parallel brain that does all these

190:29incredible parallel operations like image recognition.

190:33I recognize your face.

190:35Does huge amount of processing that goes on in parallel.

190:40There's lots of nerves between my eyes and my brain,

190:43and the brain does a whole bunch of stuff all at once,

190:46because it's actually really slow circuits,

190:48but there are many of them that all work together.

190:51On the other hand, when I'm speaking,

190:54everything is completely sequential.

190:57I have to sort of string words together one at a time,

191:03and when I'm thinking about stuff,

191:07when I'm understanding the world,

191:09I'm also thinking of everything like one step at a time.

191:13And so we've sort of, we've got all this incredible

191:19parallel circuitry in our brains,

191:23and eventually we use that to simulate

191:26a single threaded, much, much higher level interpreter.

191:31- That's exactly, I mean, that's the illusion of it.

191:36That's the illusion of it for us,

191:39that it's a single sequential set of thoughts,

191:42and all of that came from a single cell

191:45through the process of embryogenesis,

191:47so DNA is the code.

191:49DNA holds the entirety of the code.

191:53The information and how to use that information

191:56to build up an organism, the entire like,

191:58the arms, the legs. - How is it built?

192:01- Yeah, the brain.

192:03And so you don't buy a computer, you buy like a--

192:06- You buy a seed, a diagram.

192:10- And then you plant the computer,

192:11and it builds itself in almost the same way,

192:15and then does the computation,

192:17and then eventually dies.

192:21It gets stale, but gives birth to young computers

192:25more and more, and gives them lessons,

192:27but they figure stuff out on their own,

192:29and over time it goes on that way.

192:32And those computers, when they go to college,

192:35try to figure out how to program,

192:36and they built their own little computers.

192:38They're increasingly more intelligent,

192:40increasingly higher and higher levels of abstractions.

192:44- Isn't it interesting that you sort of,

192:46you see the same thing appearing at different levels, though,

192:51because you have like,

192:53cells that create new cells,

192:58and eventually that builds a whole organism,

193:02but then the animal, or the plant, or the human,

§19Transcript · 3:13:06–3:15:44

193:06has its own mechanism of replication,

193:11that is sort of connected in a very complicated way

193:16to the mechanism of replication of the cells.

193:19And then if you look inside the cell,

193:22if you see how DNA and proteins are connected,

193:26then there is yet another completely different mechanism

193:29whereby proteins are mass-produced

193:33using enzymes and a little bit of code from DNA.

193:39And of course, viruses break into it at that level.

193:44- And while the mechanisms might be different,

193:46it seems like the nature of the mechanism is the same,

193:51and it carries across natural languages,

193:55and programming languages, humans,

193:59maybe even human civilizations,

194:01or intelligent civilizations,

194:03and then all the way down to the single-cell organisms.

194:07- It is fascinating to see what abstraction levels

194:12are built on top of individual humans,

194:15and how you have whole societies

194:18that sort of have a similar self-preservation,

194:24I don't know what it is, instinct, nature, abstraction,

194:30as the individuals have and the cells have.

194:33- And they self-replicate and breed in different ways.

194:37It's hard for us humans to introspect it,

194:38'cause we were very focused

194:40on our particular layer of abstraction.

194:42But from an alien perspective,

194:45looking on Earth, they'll probably see

194:48the higher-level organism of human civilization

194:51as part of this bigger organism of life on Earth itself.

194:55In fact, that could be an organism just alone,

194:57just life, life, life on Earth.

195:01This has been a wild,

195:03both philosophical and technical conversation.

195:06Guido, you're an amazing human being.

195:08You were gracious enough to talk to me

195:11when I was first doing this podcast,

195:13and one of the earliest first people I've talked to,

195:16somebody I admired for a long time.

195:18It's just a huge honor that you did it at that time,

195:20and you do it again.

195:21You're awesome.

195:22- Thank you, Lex.

195:23- Thanks for listening to this conversation

195:25with Guido Van Rossum.

195:27To support this podcast,

195:28please check out our sponsors in the description.

195:31And now, let me leave you with some words from Oscar Wilde.

195:34Experience is the name that everyone gives

195:37to their mistakes.

195:39Thank you for listening, and hope to see you next time.

195:41(upbeat music)

195:44(upbeat music)

— A LITTLE MORE TO THINK ABOUT. —