"How to Begin Thinking like a Programmer" by Andy Harris

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
without further ado the indie hero that's what how do you guys do it oh my word give me a break people this is my fourth talk today so let's try this again how are you doing alright sometimes I teach distance ed courses in fact tomorrow morning I'm teaching one to Nicaragua but I just checked this is not a distance ed course we're in the same room so we're going to do like interactive stuff so I'm good and normally we don't allow beer in my classroom so I think this might go better you never know maybe we should change that policy I'm not sure the class would be more popular yeah I'm in class mom seriously so what I want to talk about tonight was what Calvin asked me to talk about so if it's a bad idea it's his fault was a little bit about how Python fits in the space for beginners now I know a lot of you are not beginners especially if you're looking for work maybe it's better not to be a beginner at that point but even if you're not a beginner is there anybody who is who's brave enough to say so you're just learning Python yes you and me dude okay excellent great this is for you the rest of people can hang out but actually this would be useful for all of us too because I don't know about you but as I've not gotten smarter but I've gotten grayer and so people expect me to be able to help them learn how to do things and as you become a senior dev you're always ending up having to teach people am i right most of us are not good at that I'm just saying and you know I love to go on the learning program forums and Reddit and so on and it's comedy gold so what are we going to talk about we'll see how you can think like a programmer even if you're not sure you can and now to teach beginners with Python you like that look at that whoo fun all right so you don't need to know much more about me except here's my favorite thing that Calvin didn't know I used to be a special ed teacher yeah I know it was actually severe disabilities Central High School that was the best best preparation for being a computer science teacher I could have ever had it really was and I'm not being facetious here I mean some of my students are here they're like yeah you're true yeah because I learned how to teach I really learned a lot about teaching and I'm still learning about teaching 20-some years in I'm learning a ton about teaching I actually I think programming is hard do you agree see this was the interactive part yes okay programming is every bit as hard as most people think it is I think teaching is harder I honestly do I think that's the more valuable more difficult more rare skill which is funny because there's a lot of people with the title who don't have the skill so yeah yeah yeah yeah you know all that stuff goofy dude that's the most important one all right so how smart are they oh I didn't do it I didn't do it Nick can you run outside I need a rock huh sure will work I'll use my shoe that's the scariest thing they knew where I was going with it okay who's got a good gaming rig okay yeah what you got tells your sex it doesn't matter excellent that's a good machine good machine okay normally I have a rock but I'll just use the shoe how smarter than you thought I was talking about the students didn't you know I was talking about how smart of the computer there's that gaming computer and there's my shoe which one's smarter it's a tie it's a tie and if you don't get that we're done that's the most important thing about learning how to be a programmer don't you agree now I'm going to have to take the other one off for a walk in circle all right so how smart are they not the people that's never the problem the people who I teach usually are super super they're really really clever and bright and wonderful that's never the problem I've not encountered anybody yet who couldn't learn to program if they wanted to I've met several who don't want to but how smart are they I'm not talking about the people I'm talking about the computer see the hard part about writing a computer program isn't trying to be as smart as the computer it's trying to learn how to be as mind-numbingly stupid as a computer that's the hard part and until you can understand that you'll never really be able to write program so I get an amen yeah yeah all right so learning the program it's hard if you're just doing it now do you agree with me it's hard and in fact I'm still learning the program I've been at this for 30 years I'm still learning I'll let you know when I figure it out I still feel like an idiot all the time am I the only one all the time I like walk out of my office is like why do people pay to read my book people are actually paying to see my class if I can't even get this super thing to work or my wife is like get back in there and get it working she is loving she is awesome learning to program it's hard why well program feels different than other skills doesn't it especially to a beginner yeah I'm good at cars but I don't know that stuff languages are scary right they see cool cold that sounds like it's a mystery you're not supposed to know what it works that work so language is scary there's code you know you think the language is scary the environments are scary we have these IDs and you know I look at modern development and then tell you 25 different steps you have to do before you start opening your first program that's insane there's absolutely insane well first you have to develop your environment especially JavaScript don't get me going on that environment right now with a scariest thing let's be honest sometimes it does yeah because we love to talk in jargon we love to talk about all these things we love all of our really fancy ideas we love to show off what we've learned and that might really freak out a beginner yeah I'll show you specific examples as we go don't you worry most beginners have failed a lot yeah and a lot of these are people who are pretty smart they're not used to failing it's hopeless thank you the people who did good in school and they failed and then they fail again and maybe they've gotten bad advice and they follow that advice and they fail and they feel stupid and why would you go back someplace that makes you feel stupid all the time that's a good that's a good question it's super easy to get bad advice isn't it well do some of that and you know good programmers are often good people but not always good teachers have you found that to be true I've been one of those good programmer not good teacher I've been a bad programmer bad teacher too and so this stuff is hard I love this you know every day I get to find out some bad beginner advice here's things that I see on forums and I've actually said probably all of these so start with a simple game you know you want to learn how to program just start writing a simple simple game like what kind of game Oh something super easy like Tetris oh if you've ever tried to write Tetris it's not Dibble or you know just write tic-tac-toe oh dear or this start with C++ that's what they use in industry I especially love that in the gaming community you know you really need to learn C++ because that's what they write game engines nmuk you are out of your flip in mind I love C++ what are you going to begin with that are you kidding me super bad idea because you know what's going to happen people f up often language you're going to feel stupid the first 15 seconds aren't you if you if you've tried to teach a beginner in it actually C++ starts out okay CNC out how hard can this be yeah let's talk about memory allocation huh yikes if you use Visual Basic you don't have to code until the very end of the project that's one of my favorite you know my visual basic program is all done except for the code I love that one oh dear yeah I used to teach that thank goodness I'm done the best way to start is to pick a problem you want to solve I like this one I like this advice except it's terrible because see you know I'd like to solve world peace is that the first problem I should try you know having goals is good but it's the goals lead to inevitable failure and defeat maybe we should pick a subset of saving the world first you'll stay motivated if you work on a real-world problem until you feel like an idiot and leave because here's the problem with real world the real world is messy isn't it and so I'm not so sure that we always want to be focusing on real world problems to start here's things I wish I'd been taught when I was the beginner and I've only learned this after fully twenty thirty years of teaching it and I'm still learning it programming is not about language it this is the question I hate the most on these Norm's right reddit learn programming I'm there every day to pilot for me what language should I start with and I like I have to stop because if I had quadruple size caps lock I would use it wrong question that stupid question and here's the great thing you're going to get reams of advice about it all of it stupid programming isn't about languages sure you're going to pick one but the language ultimately doesn't matter that much some would make you feel better earlier some will make you feel stupid or earlier public static void main string art but the language doesn't really matter programming was never about languages you know here's my guys in the back right in the first year of our program I teach poor programming languages and you know the funny thing that part's not the hard part that's what they tell me am i lying you know ok good ok good I'll still pay you um yeah they think that's the hard part no the hard part is we keep changing paradigm the hard part as soon as we know one language I start talking about something deeper that we can learn another one pythons not a good language to teach direct memory management in for example because it does it for us but if you're a computer scientist you better know what direct memory management is that's what we're going to work to in C and C++ like that yeah mmm and free yeah you guys don't know that you're Python people ok good more people think that programming is about memorizing I'll never learn all those codes and I'm like yeah either will I I don't know what you're talking about I don't memorize syntax I couldn't cuz I use too many languages you know on a typical day I'm helping debug code in six seven languages there's no way I could memorize that ok this is a good one most programming isn't about math you know I'll never be a good programmer I always hated back first of all you hit in math class I'm not sure you've met Matt secondly until you get into data science gaming and a few other specific areas you could do fine in programming without using a lot of calculus right who use calculus today that's what I'm saying okay you did you're very smart um and there are places we need it and certainly you know I used linear algebra several times today because I taught a game programming class but I might not need it every day you can get started without math and here's the fun thing when you start programming you're going to realize the kind of thinking you're doing is the kind of thinking that math was trying to teach you in the first place down there you know programming languages I love this one programming languages are simpler than human languages I know this because thirty years ago I tried to learn Japanese and I completely failed until very recently when I trying to learn Finnish and now all the Japanese is coming out what is this Tomodachi time I'm the only words in the world who's fluent it's Stephanie human languages how much vocabulary do they have lot how many words like 100,000 okay how about the syntax rules how complicated are they oh dear Lord yeah um you know my family's all learning Spanish because my daughter's going to school in Nicaragua and and you know there's tenses I've never even heard of you know past future wonderful undescribed pretty pretty Cori sense I don't know what it is but I don't even understand it how about computer languages how many words do they typically have in the vocabulary about a hundred how consistent is the syntax painfully programming languages are actually designed to be much more sensible they're not as flexible poetry and programming languages not quite as successful except Perl of course it has blessed kill and die those are functions in Perl I can tell you my Perl joke right so a thousand monkeys on typewriters eventually one of them would would type Shakespeare the others would alright Perl code there's not many places you can use Perl jokes that's what I'm saying yeah programming really isn't about the things most people think it is here's another one programming you know I can't type fast enough to be a programmer I've heard that one actually probably you should be typing slower right how much the programming is typing oh close to none of it close to none is really that the shoe again it's about explaining things to the idiot computer appropriately did we think about it that way it's actually not quite no frightening code isn't about language here's what I'm beginning to learn after teaching this for many many years because I've taught beginning programming pick a language Perl yes I taught beginning programming at Perl and basic and Pascal and logo remember logo no some of you don't um and it's crash give me a language C C++ Java I've taught them all its beginning languages and they start to rub together I realized there are some common themes it turns out when I'm teaching a beginner how to go from not a programmer to a programmer there's really about seven or eight concepts depending on how you look at them you get those and you're done and those concepts are universal across languages that's pretty beautiful isn't it yeah true if you know multiple languages you know this to be true right if first language is hard your second language is harder isn't it because you thought you knew the truth your third language it's like this I'm seeing similarities here by four or five you know you're doing you're doing that was it was it oh yeah you were saying they asked me to do a project implies so give me a weekend yeah it gets that point doesn't it because we see these these consistencies coating is only about eight main concepts I'll show you my favorite few how's that they work in the same way in every language when we're trying to teach people how to code don't teach them code teach them English or kiss them in English the secret isn't code the secret is algorithms and data that's really what we're here to teach and of course let's pick a language that makes it easy I nominate Python if it chooses to run it's going to win we write out the contest first and then we convert to code later this is so key when my students come in to me and they're like I'm so messed up the first thing they do is sit down they open up their computer what do I do I shut it on their fingers why is your loss encoding is probably because you shouldn't be coding yet it's almost always the case you write out the concepts first and convert to code in fact I will grade your paper if you were in a beautiful algorithm and not a line of code you'll still probably pad doesn't happen often because if they write the algorithm well the code come if you turn in beautiful code that runs great without any comments in it I give it that that's how important is it after midterm mainly so most beginners this is so amazing when you when you if you are a beginner and I still am you get to this point where you think you don't understand how to write the code I can't tell you how many times people say I know what I'm doing I just don't know which code to write and no no almost every time somebody says I just don't know how to write it no that's not the problem the real problem is they don't understand the problem they're trying to solve they're jumping straight to coding without understanding algorithm and I get that good coding cool right you look like a hacker I showed my son hacker typer you know that site hacker typer calm oh you need it hacker typer calm all you have to do is bang on the keyboard furiously and it looks like you're writing C code and if you hit the right control sequence it says like you're in NATO or whatever yeah it's awesome because that's what all of the students think they're going to learn how to do anyway yeah and now you're all going there I love it the real problem is that beginners don't always understand the problem in trying to solve they try to figure out how to do it before they try to figure out what to do and really experience people like us we do that too don't we every day every day all right here's one of my favorite ideas and then we'll actually dig in and do some some good comment or code lit all right so we all know what comments are for comments are there to explain code to other programmers you agree sure sure which explains why we never write them doesn't it because it's a commenter there first of all it's their own dang fault if they can't understand my code secondly I don't want to explain what it does until I'm sure I know and that may never happen little painful painful little giggles there yeah because this is true right we're all here and you know I had a hit this thing delivered man it's deadline I'll do my best to get the comments in at the last step but I got to get it working before I can worry about that yeah so comments are there to explain the code to other programmers or better yet yourself because a week later you're like crud what does this do no no no I finally learned the truth comments are not there to explain the code to programmers code is there to explain the comment to the computer that's profound but that is that's all I got good night I'll see ya code is there to explain comments to the computer at least for beginners but again I still consider myself a beginner if writes your algorithms first you got that algorithm first working is beautiful and then how do you know it's done it's like a turkey right the little thing pops out no how do you know that an algorithm is done you look at every line and at this point maybe you even decided what language you're going to use and you say I can do that I could do that I can do that a little better look that one up break it up into smaller things I could do it I could do it I could do it I can do it at that point now we can start thinking about code that sounds really mean doesn't it my students think so too until they do well and they all learn more than me so now they don't take it so bad this is important idea all right so let's go into I said there were only seven or eight main concepts let's do our favor first four how's that no okay then nice seeing you again um here's the way I like to think about it because really algorithms you can say that and people like Han huh but let me show you exactly how we like to think about these I actually have one chart that I'll make and it was uglier than the slide show so you know if you want it I'll give it to you but I have one chart I say you understand this it's an HTML table it's that ugly you understand this you've got programming oh you want to do it in chocolate one second change it all okay great I change one column so I just rebuild that table for every language we teach it but here's the ideas how the first idea is about variables right they're able to write data so those of you who are really beginners today's our moment if you're not the beginning regard no that's right but someday you're going to teach it to someone okay and and the real issue is it just a variable okay it's a place the memory to hold data great we know that but here's the interesting thing about this approach to learning as I say first thing you need to know is there is such a concept is make a new variable and when I'm running an algorithm this is one of the things I can pick what am I going to do I'm going to make a variable so that's on your drop-down list of things you can do make this there's only about eight or nine of you really but when you say that as soon as you say I'm going to make a new variable some questions should pop in your mind oh dear hey there's some HTML code what does that stuff die alright so some questions should pop into your mind where it doesn't matter what language you're in know same question any time we make a variable I guarantee you're going to need to know what's its name well it's it's type what sort of data does it hold those of us who've been programming for a while know that computers are a little fussy about that you know we have integers that don't have decimal points often we have floating-point numbers that have that and then we have strings which is the much cooler way to say text and then we got other stuff too and it depends on which language how fussy you are about that sort of thing right if this was a Java group they'd be like you of frigerator choice baby we're Python we're like man that's all the same what the size like here well does this doesn't matter what type something is even if maybe our language isn't too fussy about it we shall see initial value what's its starting value so would you agree whenever you make a variable in any language you think of these things there might be some others like scope but I'm going to save that for function scope doesn't mean much if you don't have functions yet so whenever I make a variable that's what I think you agree ok here's where you say yeah yeah please go home ok good good thank you so how do you write an out an algorithm this is the part I'm proud of ok that's not the part I'm proud of when it works it's the part little scroll how do you write another and here's the beautiful thing you must write in English no coding allowed unless the course English isn't your favorite language and Swahili whatever cool awesome create oli whatever it is I don't here but your sentence has to answer those questions it has to answer the question what's its name what's the starting value and what's its type that's your everything does that make sense so when we're teaching a beginner to make a variable the first thing they need to know is I need to make a variable and then the second thing they need to know is what question should I always answer when I make a variable that make sense and then when we do that honestly that's all they need but see if I could get away with it I wouldn't even teach the language yet but they don't believe it's real coding unless they're typing somewhere so fine we'll do it that's how we write this in Python name gets an it Val type huh you're on your own but that's how we do it in Python so I can live with that can you live with that yeah sure because we're partners so that's good so that's one of our concepts here's another concept I mean it seems trivial doesn't it what it isn't it isn't output right what's another thing I can do well I can tell the users stop I'm going to start here with a command line console because life is easier there isn't it we're in charge I mean in the GUI the users in charge and who put them in charge not me but output is pretty easy there's only one thing to worry about what message do I want to send the user and of course output usually text isn't it yeah I'll put text so that's pretty easy and we could write an algorithm for an output line - couldn't we don't worry there's a quiz coming I'll put the text message okay that's really easy yeah in your code yay for Python free yeah [Applause] system that adds up really no no console.writeline no it's easy it's free except I always BFD I'll think perfect what's the pushup I don't know you know I still mess up the parentheses for sometimes because I you did two seven for a long time wrote a whole book in two so the parentheses sometimes throw me but I could do this now how much are we worried about the Python syntax have you seen how much we've stressed about that why not because you all know it but why because that's the part we can look up how do I do it in this language that part Google will help us with water if you turn to Google how what problem am I trying to solve you're going to get this very scary result but if you know what you're trying to do you know I'm trying to output text you can say how do I put text in Python 3 and the chances are you'll get something pretty close to this yeah so the coding part is the easy part in algorithm part is the hard part all right so we're getting to the point where we have enough of these tools we can start to put together a real program there's you know input now input I like talking about input because this is the first one that really starts to talk about the real complexity of coding isn't it because see all of the other things were atomic they could kind of stand on their own but input is really mean input has like dependencies doesn't it why don't you think about it when I when I input something here um tell me the answer that we the answer come on 42 that's a good one I like that yeah I'm coveting that t-shirt it's not fair for me to ask you the answer if I didn't ask a question is it never stopped me as a teacher but if I am asking for an answer I should really give you a question so an input applies that there was some question after the user it may be in that statement as it is in Python it may be another line it doesn't matter much but somehow we're going to ask the user a question well okay now throw me the ball throw me the ball come on you guys can help throw me the ball please yeah you have a ball throw you know what I should have done I should have put up my mitt you shouldn't ask for somebody to throw something if I'm not ready to catch it yeah input you have to have a variable to answer to hold the answer you have to have a question that you ask them so the crazy thing about input is it should never be the first line of your algorithm you see I'm saying it doesn't make sense because there's there's like prerequisite so you need to either in the input statement itself or in another statement you need to ask a question and you already need to have a variable in place that can catch the answer well that makes a lot of sense doesn't it and what does that have to do with Python syntax nothing that's a different problem and an easier one isn't it that's an easier problem okay so how would we do an algorithm again any one you want any line of algorithm as long as it answers those questions makes me happy ask the user a message and store the answer in variable beautiful we good with that you want to code you've seen the code but it's easy variable gets input message yeah but you see the point I'm trying to make when we understand the concepts the code itself becomes actually at some point and this is why we don't always write comments right at some point this is more clear than that but not for a beginner not for a beginner so a beginner has to do this part for a while before they can jump straight to the code does that make sense because we've forgotten that some time and to the beginners that we're trying to help this looks like arrogant it's not it's forgetfulness but we can see there's not a cleaner way to say that I really can't think of an easier way to say that in any of the languages I used thank you we don't but we forget that it's not obvious to beginners okay that's enough we can write a program can't we sure we could with just that and I'm not going to actually make you write it because I want to get to some other stuff but here's the program we would write now for real life I would stop right here no more we've learned plenty you can't make me teach you another line of code because we would stop we get out paper and pencil and we would write some algorithms together in groups not by yourself if you're really confused find somebody who is feeling very comfortable and makes them uncomfortable and we write this out and if you turn on the computer I will slap the slap it shut on your fingers because I don't want computers right now I want brains those are much better computers anyway right and so we write this no code that's really hard for those of us who think in code isn't it yes I sometimes do dream in code terrifying especially with my dreams involve memory leaks it's a bad bad thing honey just turn on the valve Brian she's like what's a valgrind never mind never mind algorithm only I'll go ahead and do it for it there's my first try you see what I did here no code create an integer variable for X created and your variable for Y create an integer variable for some do I answer those question yeah okay ask the user X and put the answer in X asking user Y and put the answer in Y put X plus y and some tell the user the answer is thumb this is awesome okay some of you know there's a problem and some of you are like seriously I could have just written it right but you're not a beginner anymore if you're a beginner you need to write it this way first now here's the beautiful thing about Pi a Python right we're a half a step away from Python because Python is beautiful except for a few words come on name equals main that's pretty stupid I love Python but that's its word come on it's still there and the whole self thing oh please if you're going to require self as a parameter then tell me the right number of parameters when there's an error in the function because my beginners are freaking the heck out it says it only has two parameters when there's three basic but there's four okay so first we just write this as plain text paper-and-pencil is better than on code whiteboard is my favorite lipstick on Tamir cool blood on the wall don't do that but we come up with a plan then we take the plan and now we convert it to comment now you could put it in your text editor which one I do not care if you're spending a lot of time stressing about it wrong one I'm actually still a vim guy I'm that nerdy I know I love me some damn but I'm not going to impose that on okay second class I do but but in the first class no no I'm not going to make you do that but I want your editor out of the way I'm not a huge fan of syntax highlighting that doesn't solve the real problems does it or code completion and all that stuff that doesn't solve the real problems it solves the easy one the real problem is how do you think well and the cleaner your editor is the easier we get there this is a pretty good answer isn't it is it code well technically we could put it in an editor and it wouldn't crash um it's a great algorithm okay we sit up good algorithm would you agree no now I'm sad okay I like it now the next step okay now we can put in code and so every line and this again is something that we love to teach our beginners or I do everybody else hates it and and that is okay now that you've got those comments one line at a time you look for that comment you tell me how to write it in code go crazy with Google if you want do it of course I taught this to China and they said what Google okay Baidu good luck yes Court is about that man yes teaching Java in China please teach a village Java in English you've got one month I got there and realized they didn't know basic Java or English and that was the translator yeah it was crazy so now each of these things I can say dude I can write that I can make that and in fact this is the first time that it even matters what language were in you know maybe I'll go to the Java users group I'll just change this line the other except you know I can't make the comment about public static void main string guard which is huh oh yeah it's coming yeah I'll show it to you yeah I've got a yell yeah don't you anyway so we can take each one of these things and we can convert it to code in that beautiful it's not beautiful yes that's beautiful well yeah and then of course we can test it and again I'm not too fussy if you don't have a copy of Python on your own machine right now that's not a big barrier I love some of the online environment Python anywhere love that one in fact I've got it running on there so you don't have to install on your own machine if you don't want to no good reason not to come on you're using a bunch a right you've already got it here I happen to have it running I think enter wound up PI au courant so there's that same thing I just copied and pasted should we run it oh I am all atwitter here we go okay come on give me some code yes I don't know what that is but I think it's funny okay x3 y5 spits look going swimmingly 35 oh dear really should've tested this didn't know I knew what was going to happen see look at my next slide stop it stop it stop it stop it okay this is where we all go wrong this is where we all go wrong first of all the first thing we do failure is a wonderful thing if you don't like failure you're in the wrong business because how often do we have miserable crashes a day I'm in it I mean it happens all the time right if you can't be big about that then you're in the wrong job I don't know what job is good for you but this one is it because it's going to crash a lot but our failures are opportunities for us to grow and we have to have a good attitude about that and you know what we should teach debugging the very first moment because there is no programming that isn't debugging isn't it I mean how much the programming is debugging and how much of it is actual programming it's pretty much all debugging isn't it begin debugging now now here's where everybody gets in trouble one thing we all like to do especially those experienced people as we jump right at what the answer is right we start solving this sucker and often because we have a lot of experience we do it very well it really puts us the students off when I do that I don't even see it we're walking in the hallway and I can tell them what lines wrong and I'm usually right that really pisses them off except at least their coats working because I've given this assignment for a few times that I know exactly why it's acting stupid but did you tell us what to do incorrectly that's what most beginners think I must have typed the wrong code because they still think that programming is about writing code that's what they always assumed or did you tell it to do the wrong thing okay we can think about this example did we tell it how to do it wrong or did we tell it to do the wrong thing yeah one of those we don't know that's a beautiful answer we don't know I don't know is the best answer any programmer could give me because if you do know and it's not right you don't know this is what I hate I just have one simple problem professor then why are you in my office if it was simple you would have solved it you've done something boneheaded I know and I'll help you but don't pretend it's simple so often we think that we just did it wrong but what happened is we did the wrong thing maybe with a good conscience but beginners almost always assume it's an implementation problem when it's almost always an algorithm problem is that the case here almost it's an understanding problem and that's ok that's ok that's wonderful that's going to happen every day and you know what I could have prevented that I could have taught you how to convert to an ant first right I don't want to because the beautiful thing is embracing those isn't it embracing the fact that when we learn how to code we fail all the time and boy do you wish you learn this slide a hundred years ago I still don't know how but I've been here a debuggers are good I like debuggers although you can depend on them okay this is my mr. miyagi ISM of the day best ladybug code not have fun and as although it's facetious is it true yeah the best way to debug your code is to write code defensively sub bugs don't creep in that's very hard to do it takes a lot of experience there's other things you can do though bad implementation if I just did it wrong I could Google that if Google's not getting you the right answer you probably don't have bad implementation you probably have that algorithm or a bad understanding of the problem space those are much harder to find in Google aren't they that algorithms you can't look those up there's probably something you're not understanding does that make sense something's not acting like it like it's supposed to and that's when I debugger the idle debugger is good again I'm still a PDB kind of guy I'm just that old school because man the command-line dude I can do a lot but there's something I'm not understanding going super slow-mo look at that thing print stuff out so you can find out some things that you're trying to do is not doing what you think it is you know are there some tools that I can look at to help me of course the debugger is good in this case you know we could we could start looking at hey isn't there command to find out what type something is in Python as its called type but here's the thing I makes me crazy because I do it every time alright here's what here's what you need to do right we start solving problems we don't understand how often have you done that today we are constantly solving problems we don't understand and how often do we make a better how often do we make them worse and so don't start with a solution unless you're using it then just okay make it a new branch and then go ahead but don't start with a solution because you're going to mess yourself up aren't you and I have people come to me all the time they just swear swear python is broken because it's not working and it should okay there's something you're not understanding and there's nothing wrong with that but there's something you're not understanding and your assumptions are probably a big part of the reason you're not understanding things you're assuming things that aren't true do some detective work sherlock let's figure out what's going on let's get in there and find out what's happening there's lots of tools for that you got to start by understanding the problem a lot of times I'll turn off the computer I'll be like that turn off that computer here's the whiteboard marker when they move my office they were going to take away my whiteboard and my bookshelf and I said you can have my computer true the true story and they were like you're not okay we'll give you the whiteboard because we you scare it a little so what did happen here okay now you can say it's easy to assume the plus sign is broken saying it this thing doesn't even know how to add that's a normal assumption though isn't it how stupid is it now that's not really the problem those of us who are experienced see we're feeling superior because we already know because we've already felt like idiots long ago when we forgot it or we're just kind of a little younger huh it we've all made this one haven't we the plus sign is not really the problem what's really the problem try this you know Python method interactive mode I love that right if I try to do Python plus meetup what's it going to say paws I meet up there we go wait a minute wait a cotton-picking minute you can't add Python and meetup can you okay be careful here because you know I'm about to slap you because somebody wants to say well operator overloading as a form of polymorphism and it's actually concatenated rather than that adding because it's automatically detecting that these are strings and not integer yeah sloppy with a wet fish for that when you're around beginner all right when you're around beginners this is the worst thing we can say because they're like yet you just wished in a serbo-croatian or something they felt stupid before now this feels work so yes is it is all that stuff true yes it is it wonderful when you understand it yeah but do you have to understand that the first day no no no I think it's enough to say hey it's the plus sign is so smart that it does different things when it sees text and when it sees numbers and apparently it thinks that five and three is text I wonder if that's the problem can I test that right and then we Google again is there a way to find out what type of data something is is there yeah is it type or type of I get JavaScript and Python computes every time I always gets wrong the first one its type okay so we can apparently add text yes concatenation and wonderful things two and three are text we look up a tool the time function tells us what we want to know okay now we add a new tool to our toolbox you see what I'm saying now we add a new tool to our toolbox which oh I need a new algorithm piece convert to integer so real good up figure out what you have to do looks like we have an old in a variable and int variable and convert old variable to integer store an int variable oh look there's code for it that's all fun isn't it now we have a new tool and that's how we continue growing is as we encounter a problem we develop a new algorithmic tool to get there does that make sense so this is this is pretty kind of fun isn't it it is really in a geeky way alright I know now we can try again with a new tool notice what I did I killed my code I can't believe it took me hours to write that now we pin it it took you about 30 seconds to write it it took you hours to understand it and you understood it wrong really hard to get people to throw away code isn't it my god right okay fine put it in a subdirectory but start fresh get again man I love get but start fresh because if it was worth keeping it would have worked and you didn't lose the thought process you just got yourself in a bad place so I'm going to rewrite my algorithm now and I'll tell you the truth I wrote this wrong the first time I put it in the wrong order but before I wrote any code I was like dude that's in the wrong order it's not going to work you see this I'm thinking about programming before I write code because it's often easier to see the order of things see I converted to work but now I look at that I'm like that makes sense I could do that on a whiteboard I can be the computer and now we'll put some code in will it work yeah we could prove it I can run it but it works there's branching there's four loops I want to talk a little bit about while it's still and then we'll be done you good with that I don't know how long we're supposed to go but you know it could be the next election cycle before I'm done it's an endless loop that's the problem yeah let's just skip this one okay so you know for loops people sometimes get mad Python people when they see the way that I teach for loops because I say the for loop has lots of parts it has a century it has a start it has a finish it has a change and you're like that is such a C++ for loop what does it matter with you and yeah and I teach for loops in Python you can see my code for Iron Range start finished change oh that is so unhype onic yes it is yes it is because sometimes I want to teach Python and sometimes I want to teach programming and when I'm teaching beginners I'll do this if Python uses chicken or third language we'll do it with iterator but this traditional structure lines up better with other languages but much more important it's much better for learning to debug properly because when you have a loop what are the three things you always think about in a loop well four things really first is this century what is this variable that controls the whole thing right and then what are three things about the century you need to know sing-alongs people you notice how does it start to finish how does it change which seems so simple right but how many loops have you had that have gone terribly wrong what's the most likely basic code structure to go wrong a loop especially if you see a boolean operator in that son-of-a-gun death two boolean operators yes yep or the falkland you gave me that one that was too easy we're going to come back to that pot real quick anyway a while loop so what are the four things you need to know about a while what's the century how does it start how's it end how does it change but no that's not true Andy the while loop has only one parameter that's the problem with wildest the while loop implies a lot that it doesn't require and that's why a while loops go wrong so often don't they because if you're going to make a while loop you were also have a holy obligation to it to think about what the century is even though the while it doesn't require you you have to initialize this entry before you got there which means you have to plan ahead which means why are you writing code you should be doing algorithm and then somewhere inside the loop we don't know where you have to change the century and you have to change it in a way that guarantees that at one point you'll figure the condition oh yeah we use a condition but you never forget that one you will sometimes make a condition that's impossible to satisfy that won't you marriage seminar some but no so these are the same things that are required in a while oh but that's why I teach them first in the for loop because how easy is it to mess that up now you don't do it alright here we go here's the example basic password loop we've all done this one right it exits for the positive recite result if the user chooses the right password but if they get it wrong it's Washington so if you get it wrong through time sorry about your luck sending the missile all right we could all do this how you're going to code it okay really how are you going to cut it all right we'll use the compound condition right with a boolean now I love boolean variables don't get me wrong it's boolean operators that bug me because here's why because what condition do we need on this thing let's see tries is greater than equal to 3 and guess is not equal to correct yeah that's it or is it because now guess is a negative and demorgans log it's as a boolean variable okay take a picture because it's going so correct the Gimli pie tries to 0 keep going it through while keep going you know what I love about boolean variable there's just a not not a lot that can go wrong it's about the cleanest variable type you got right I love boolean variable I don't love boolean operators as much unless I'm working on just boolean variables with them but well keep going if this thing is true and is it it better be well I'll keep going the truth do whatever code I want yes I deliberately did not do the format thing because I don't want to freak out beginners it's really cool but not today now take a look if gas is equal to correct then we'll say that's great here's the treasure and then look at this beautiful thing that's where that's where the break statement goes doesn't it now we should never write break should we I not switch statement thank you for not including those you know yeah keep going it's false that means the next time I evaluate this loop we're out how clean is that and what do I really mean by this line I don't want to keep going I like that do you like that pretty much easy to fault also surprises I didn't really do Elif Elif is like a dwarf but it's taller and then the years.if tries is greater than or equal to 3 then we're going to print hey too many wrong tries launching the missiles once again we're not directly exiting the loop but we're telling it the next time you evaluate I don't want to keep going anymore you know what's funny is I don't the last time I wrote a while loop that didn't just say while keep going because once you get used to this man it's beautiful it is just beautiful and I read a lot of games you know game code gets messy doesn't it oh oh could just mess your the game code and partially because we don't design for maintenance in gaming you know it's going to be out of date and night in a year so in gaming you don't design it to be maintained you designed to be fat until you're actually junk okay eventually we'll teach all these things at their time but not today you good with that yeah no let's just start with it so Wi-Fi right I mean I've taken a lot of time to tell you tonight that the language doesn't matter yet it's a Python code and I do love Python so if the language doesn't matter why did we choose Python well I'll show you okay you recognize this right what language are we in old school see man that's the way God intended pointers everywhere no string those strings are for wusses okay there's some seat and there's kind of you know hello world is too simple to really get the feel of a language isn't it so I say really we need to do hello user that is it ask the user's name and then it does something with it that's the smallest program I think we can really get the sense of a flavor of a language would you agree and would it be possible for me to take that little chart we just did and show you how to do all those things in C absolutely absolutely there C but don't worry hey Buuren how you doing buddy see all these people in the open source world they have the best names don't they you know Vito and Bjorn and stuff like that yeah I figure that's the only reason I'm not at the top of the open-source world is my name is too obvious I was going to go with one of the sub-saharan languages with clicking and stuff my name is Davey Harris either that or just switch to skip the human language is all together go to Dolphin I'm sorry all right so c-plus what Wow at this level people have what looks like a dream doesn't it no more participant C++ must be easy yeah if you've done some yeah it's and fne one yep yep okay C++ is pretty nice at this level but it gets hard fast all right here's my favorite right public static void main street hard have you ever tried to teach Java to beginning you've ever been to a beginner Java class I mean every Java teacher in the world who have to teach beginners and this was me that's what they wanted in Nicaragua please teach this in Java I'm like okay great please wave a dead chicken over your shoulder turn around three times it's a ritual throw salt type this line and then like we do not have a chicken nevermind I don't really mean that it's just a ritual because I don't want to teach you what a static method is yet that doesn't make sense if we haven't done objects and we shouldn't be doing objects yet you're just trying to make a variable so this makes me crazy now I love me some Java I do love Java and I love Java for more advanced programmers because it doesn't let you do some stupid things that we like to do anyway right dual inherited now I look at my kids I think multiple inheritance is a good idea there so there's Java yeah it makes sense doesn't it could we again like all these languages could I take that char to make it work for Java sure I've done it so why Python that's why if you want to teach a beginner to program which of these languages is easiest to translate from the algorithm to code that actually works that's what I love about Python because since I don't care about the language how about we pick one that gets out of the way it gives them sixth I wanted to succeed I wanted to feel proud I want them to fail because that's going to happen but I want them to overcome that failure the language that helps us do that that makes me happy that makes me happy and I like successful students and here's the other thing they are going to want to make game fine we can do that somebody's going to want to write a database equal lights built-in good now they all want to do GUI okay fine TK yeah TK but hey it's built in what do you want to do sure we can do it get it out of here says you want do web apps I thought that tonight I showed them they were still this is their first Python class I showed them bottle because there's no insulation because I don't want to deal with the selling flap coming yeah computer and how cool is that isn't it fun so that's really where I am I love to teach beginners because I love the process of learning and I always learn far more than them so thank you for your time I'll be around to answer any questions you guys been awesome a lot of fun [Applause] you
Info
Channel: Six Feet Up Corp
Views: 31,257
Rating: 4.9439254 out of 5
Keywords: sixfeetup, Six Feet Up, python, IndyPy, Coding, Tech, scripting, programming, programmer, learning, education
Id: YWwBhjQN-Qw
Channel Id: undefined
Length: 61min 1sec (3661 seconds)
Published: Wed Mar 29 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.