Guido van Rossum explains Python programming

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
python 3.11 is coming out very soon init C python claim to be 10 to 60 percent faster how did you pull that off and what's C python C python is the last python implementation standing also the first one that was ever created the original python implementation that I started over 30 years ago so what does it mean that python the programming language is implemented in another programming language called C what kind of audience do you have in mind here people who know programming no there's somebody on a boat that's into fishing and have never heard about programming but also some world-class programmers you're gonna have to speak to both imagine a boat with two people one of them has not heard about programming is really into phishing and the other one is like uh an incredible Silicon Valley programmer that's programmed in everything C C plus plus python rust Java it knows the entire history of programming languages so you're gonna have to speak to both I imagine that boat in the middle of the ocean yes I'm gonna please the guy who knows how to fish first yes please he seems like the most useful in the middle of the ocean you got you gotta make him mad I'm sure he has a cell phone so uh he's probably very suspicious about what goes on in that cell phone but he must have heard that inside his cell phone is a tiny computer and a programming language is computer code that tells the computer what to do it's a very low level language it's zeros and ones and then there's assembly and then oh yeah we don't talk about these really low levels because those just confuse people I mean when we're talking about human language we're not usually talking about vocal tracts and how you position your tongue I was talking yesterday about how when you have a Chinese person and they speak English uh this is this is a bit of a stereotype they often don't know okay they can't can't seem to make the difference well between an l and an r and I have a theory about that and I've never checked this with linguists uh that it probably has to do with the fact that in Chinese there is not really a difference and it could be that there are Regional variations in how China native Chinese speakers pronounce that one sound that sounds to L to some like L to some of them like R to others so it's both the sounds you produce with your mouth throughout the history of your life and what you're used to listening to I mean every language has that Russian has exactly the Slavic languages have sounds like the letters like uh Americans or English speakers don't seem to know the sounds they seem uncomfortable with that sound yeah so I'm sure oh yes okay so we're not we're not going to the shapes of tongues and the sounds that the mouth can make fine words similarly we're not going into the ones and zeros or machine language I would say a programming language is a list of instructions like a cookbook recipe that sort of tells you how to do a certain thing like make a sandwich well acquire a loaf of bread cut it in slices take two slices put mustard on one put the jelly on the other or something then add the meat then add the cheese I've heard that science teachers can actually uh do great stuff with recipes like that and trying to interpret their students instructions incorrectly until the students are completely unambiguous about it with language see that's the difference between natural languages and programming languages I think ambiguity is a feature not a bug in human spoken languages like uh that's the dance of communication between humans well for lawyers ambiguity certainly is a feature uh for plenty of other cases uh the ambiguity is is not much of a feature but we work around it of course well what's more important is context so with context the Precision of the statement becomes more and more concrete right but you know when you say I love you to a person that matters a lot to you the person doesn't try to compile that statement and return an error saying please define love right no but I imagine that my wife and my son uh interpreted very differently yes even though it's the same three words but imprecisely still oh for sure lawyers never had a lot of follow-up questions for you nevertheless the context is already different different in that case yes fair enough so that's that's a programming language is uh ability to unambiguously State a recipe actually let's go back let's go to Pepe you go through and pepe the style guide for python code some ideas of what this language should look like feel like read like and the big idea there is that code readability counts what does that mean to you and how do we achieve it so this recipe should be readable that's a thing between programmers because on the one hand we always explain the concept of programming language as computers need instructions and computers are very dumb and they need very precise instructions because they don't have much context in in fact they have lots of context but their their context is very different but what we've seen emerge during the development of software starting in the probably in the late 40s is that software is a very social activity a software developer is not a mad scientist who sits alone in his lab writing brilliant code software is developed by teams of people uh even the Mad scientists sitting alone in his lab can type fast enough to produce enough code so that by the time he's done with his coding he still remembers what the first few lines he wrote mean so even the mad scientist coding alone in his lab would would be sort of wise to adopt conventions on how to format the instructions that he gives to the computer so that the thing is there is a difference between a cookbook recipe and a computer program The cookbook recipe the the author of The cookbook writes it once and then it's printed in 100 000 copies and then lots of people in their kitchens try to recreate that recipe that that that particular pie or dish from the recipe and so there the the goal of the cookbook author is to make it clear to the human reader of the recipe the human amateur Chef in most cases when you're writing a computer program you have two audiences at once it needs to tell the computer what to do but it also is useful if that program is readable by other programmers because computer software unlike the typical recipe for a cherry pie is so complex that you don't get all of it right at once you end up with the activity of debugging and you end up with the activity of so debugging is trying to figure out why your code doesn't run the way you thought it should run that means brother could be stupid little errors or it could be big logical errors it could be anything spiritual yeah it could be anything from a typo to uh a wrong choice of algorithm to building something that does what you tell it to do but that's not useful yeah it seems to work really well 99 of the time but does weird things one percent of the time on some edge cases that's pretty much all software nowadays all good software right well yeah for for bad software that that 99 goes down a lot so but it's not just about the complexity of the program it's like you said it is a social endeavor in that you're constantly improving that recipe for the cherry pie but you're sort of you're in a group of people improving that recipe or the mad scientist is improving the recipe that he created a year ago and making it better or adding adding something he decides that he wants a I don't know he wants some decoration on his pie or icing or so there's broad philosophical things and there's specific advice on Style so first of all the thing that people first experience when they look up python there is a it is very readable but there's also like a spatial structure to it can you explain the indentation style of python and what is the magic to it space cases are important for readability of any kind of text if you take a cookbook recipe and you remove all the sort of all the bullets and other markup and you just crunch all the text together maybe you leave the spaces between the words but that's all you leave when you're in the kitchen trying to figure out oh what are the ingredients and what are the steps and where does this step end and the next step begin you're going to have a hard time if it's if it's just one solid block of text on the other hand what what a typical cookbook does if the paper is not too expensive each recipe starts on its own page maybe there's a picture next to it the list of ingredients comes first uh there's a standard notation the there's there's shortcuts so that you don't have to sort of write two sentences on how you have to cut the onion because there are only three ways that people ever cut onions in a kitchen small medium and in slices or something like that right none of my examples make any sense to real Cooks of course but yeah we're talking to programmers with a metaphor of cooking I love it um but there is a strictness to the spacing that python defines so there's some a looser thing some stricter things but the four spaces for the for the indentation is really interesting it it really um it really defines what the language looks and feels like because indentation sort of taking a block of text and then having inside that block of text a smaller block of text that is indented further as sort of a group it's it's it's like you have an A bulleted list in a complex business document and inside some of the bullets are other bulleted lists you will indent those too if each bulleted list is indented several inches then at two levels deep there's no no space left on the page to put any of the words of the text so you can't indent too far on the other hand if you don't indent at all you can tell whether something is a top level bullet or a second level bullet or a third level bullet so you have to have some compromise and uh based on Ancient conventions and the sort of the typical width of a computer screen in the 80s uh and all sorts of things sort of we we came up with sort of four spaces as a compromise I mean there there are groups there are large groups of people who code with uh two spaces per indent level for example the Google style guide uh all the Google python code and I think also all the Google C plus plus code is indented with only two spaces per block if you're not used to that it's harder to at a glance understand the code because the the sort of the the high level structure is determined by the indentation on the other hand there are there are other programming languages where the indentation is uh eight spaces or a whole tab stop in in sort of classic Unix and to me that looks weird because you you sort of have to free indent levels you've you've got no room left well there's some languages where the indentation is a recommendation it's a stylistic one the code compiles even without any indentation and then python really indentations a fundamental part of the language right it doesn't have to be four spaces so you you can code python with two spaces per block or or six Paces or 12 if you really want to go wild but sort of everything that belongs to the same block needs to be indented the same way in practice in most other languages people recommend doing that anyway if you look at C or rust or C plus plus all those languages Java don't have a requirement of indentation but except in extreme cases they're just as anal about having their code properly indented so any IDE that the syntax highlighting that works with Java or C plus they will yell at you aggressively if you don't do proper indentation they'd suggests the proper indentation for you like uh in C you type a few words and then you type a curly brace which there is their notion of sort of begin and an indented block uh then you hit return and then it automatically indents four or eight spaces depending on uh your your style preferences or how your editor is configured was there a possible Universe in which you considered having braces in Python absolutely yeah well there's a 60 40 70 30 in your head uh uh what was the trade-off for a long time I was actually convinced that the indentation was just better uh without context I would still claim that indentation is better uh it reduces clutter however as I started to say earlier context is almost everything and in the context of coding most programmers are familiar with multiple languages even if they're only good at one or two and apart from Python and maybe Fortran I don't know how that's written these days anymore but all the other languages Java rust CC plus plus JavaScript typescript Perl are all using curly braces uh to sort of indicate blocks and so python is the odd one out just a radical idea do you still as a radical Renegade revolutionary do you still stand behind this idea of space of uh indentation versus braces like what what can you dig into it a little bit more why you still stand behind indentation because context is not the whole story history in in a sense provides more context so for python there's no chance that we can switch python is using curly braces for something else dictionaries mostly we would get in trouble if we wanted to switch just like you couldn't redefine C to use indentation even if you agree that it that indentation sort of in a Greenfield environment would be better you can't change that kind of thing in a language yeah it's hard enough to reach agreement over over much more Minor Details maybe I mean in the past in Python we did have a big debate about test versus spaces and four spaces versus fewer or more and we sort of came up with a recommended standard and sort of options for people who want to be different but yes I guess the thought experiment I'd like you to consider is if you could travel back through time when the when the compatibility is not an issue and he started python all over again can you make the case for uh indentation still well it frees up a pair of matched brackets of which there are never enough in the world uh for other purposes really makes the language slightly sort of easier to grasp for people who don't already know another programming language because the sort of one of the things and I I mostly got this from my mentors who were taught me programming language design in the earlier 80s when you're teaching programming for for the the total newbie who has not coded before in not in any other language uh a whole bunch of Concepts in programming are very alien or sort of new and and maybe very interesting but also distracting and confusing and there are many different things you have to learn you have to sort of in a typical 13-week programming course you have to if it's like really learning to program from scratch you have to cover algorithms you have to cover data structures you have to cover syntax you have to cover variables Loops functions recursion classes Expressions operators there are so many Concepts if you you sort of if you can spend a little less time having to worry about the syntax the the classic example was often oh the compiler complains every time I put a semicolon in the wrong place or I forget to put a semicolon uh python doesn't have semicolons in that sense so you can't forget them and you're also not sort of misled into putting them where they don't belong because you don't learn about them in the first place the flip side of that is forcing the strictness onto the beginning programmer to teach them that programming is a values attention to details you don't get to just write the way you write in English you have other details that they have to pay attention to so I think they'll they'll still get the message about uh paying attention to detail
Info
Channel: Lex Clips
Views: 198,480
Rating: undefined out of 5
Keywords: ai, ai clips, ai podcast, ai podcast clips, artificial intelligence, artificial intelligence podcast, computer science, consciousness, deep learning, einstein, elon musk, engineering, friedman, guido van rossum, joe rogan, lex ai, lex clips, lex fridman, lex fridman podcast, lex friedman, lex mit, lex podcast, machine learning, math, math podcast, mathematics, mit ai, philosophy, physics, physics podcast, science, tech, tech podcast, technology, turing
Id: 5fN3JXwer2U
Channel Id: undefined
Length: 20min 54sec (1254 seconds)
Published: Mon Nov 28 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.