Search
Ken Youens-Clark

SE Radio 431: Ken Youens-Clark on Learning Python

Ken Youens-Clark, author of Tiny Python Projects discusses Python. Felienne spoke with Youens-Clark about new features in Python, including optional typing and immutable datatypes. They also discussed  Youens-Clark’s upcoming book on how to teach Python and testing. Should testing be taught to new programmers from the start, and how to do that? Contexts for programming education were also covered, as well as the importance of the Python ecosystem and what tools to use when learning a new programming language.


Show Notes

Related Links

Transcript

Transcript brought to you by IEEE Software

Felienne 00:00:21 Hello everyone. This is software engineering radio with Felienne. today with me on the show is Ken Youens-Clark. He’s a data engineer at the critical bat Institute in Tucson, Arizona working on the rare diseases initiative. Ken has a bachelor’s degree in English literature and started to work as a programmer right after college. First learning visual basic. When those treatment one, after working in several industry jobs can spend 13 years at the flan genomics projects in cold spring Harbor laboratory. In 2014, he joined the docs are Borney Hurwitz at the university of Arizona. He completed a master’s degree in Biosystems engineering in 2019, and Ken has just published his first book. So I need bites and projects in 2020, and Ken’s book is going to be the topic of this show today. Welcome to the show, Ken.

Ken Youens-Clark 00:01:09 Oh, thank you so much, Felienne. And I very much appreciate you having me here.

Felienne 00:01:13 Great. So the first thing of course I’m very curious about is why a book on Python. There are so many programming languages out there. Why do you think is the best choice to learn programming in 2020?

Ken Youens-Clark 00:01:28 Well, it, the book really grew out of trying to teach biologists some basic programming skills at the university of Arizona. And this really goes back to my experience at cold spring Harbor, working with dr. Lincoln Stein. He started a programming course for biologists, and at the time he started at late nineties and early two thousands. He was teaching in Pearl and which was exactly actually why I went to work for him. So it was really about trying to get some sort of a programming language into the hands of biologists so that they could learn how to process the data that they were using. And, uh, Bonnie and I met in the lab of Lincoln Hurwitz, uh, I’m sorry, Bonnie and I met and, uh, doctor dr. Lincoln Stein’s lab. And, and so when we came to the university of Arizona and started, uh, the Hurwitz lab, we also want it to have that same kind of, of a class to teach biologists, uh, how to do some basic programming.

Ken Youens-Clark 00:02:19 And so we started off with Pearl, uh, you know, 2015, and even in 2015, Pearl was really on, on, on the downside as far as its popularity in our field. And Python was really rising, especially with the ascendancy of things like machine learning and num PI and so many great modules. So, uh, after a year or so of teaching Pearl, uh, I convinced, uh, dr. Herwitz that we should switch over to teaching Python just because it’s so, so widely used in scientific computing and, and it has so much to offer for the students. And, and so we just kind of converted our materials, the same kinds of examples over into Python. And then I just kept more and more examples. So in the classroom, I kept trying to find examples that I thought really helped to teach the language. And, and that’s where this material came from. I’m not necessarily convinced that Python is the best language to learn maybe as a beginner. I think it has a lot of advantages. Um, but specifically we were trying to teach some basic programming to, you know, scientific computing skills to undergraduates and graduate students.

Felienne 00:03:27 So to summarize, I think what you said is by film is very popular language, and it also has very good properties because it’s meant for data science, for machine learning, for scientific computing, and it’ll just fight in itself, but the libraries and the ecosystem around it make it very good for data sciency type of applications. Is that

Ken Youens-Clark 00:03:48 Right? I would definitely agree with all of that. Yes.

Felienne 00:03:51 And you also mentioned that Python has some advantages. So I want to dive into that a little bit deeper. What do you think are some of the language features that Python has that makes it so good for novice programmer?

Ken Youens-Clark 00:04:03 Well, you know, they’re making the transition from Pearl say to Python, which I did myself too. Uh, just kind of made myself become a Python programmer and Pearl uses the sigils in front of variables. So, you know, a dollar sign or an ad sign percent sign to, to help identify the different types of variables that you’re working with. And I think a lot of people find that kind of syntax, very confusing. I kind of relate it to like Hungarian notation that I learned in maybe the late nineties where you put like STR in front of a variable name to help you remember that that’s a string or I in front of the, you know, at the beginning, like I numb, uh, to remind you that that’s an integer. And so I think it’s it’s, to me that was useful in Pearl, but I think I, lot of people found it confusing.

Ken Youens-Clark 00:04:51 Some people do like braces to delineate blocks, uh, but Python uses white space. And so, uh, some people find the lack of braces and the forcing of, of indentation to make, uh, Python more readable. Um, I think that’s, uh, it probably is. I still see students produce very, very unreadable code, uh, even with those, those, uh, white space requirements, but more than anything, I, I really think the rebel, uh, the reevaluate print loop that Python offers is, is a fantastic learning tool. So it’s something I really encourage, uh, in class that we’re in, when we’re trying to understand like how to pop an, an element off a list, we open up Python, we just type Python three, and then we have this rebel and then we create a list. And then we’re able to, to look at that list to, to say, well, show me the list.

Ken Youens-Clark 00:05:46 And it shows this visual representation of something that looks like a list, and then we can say, you know, pop a member off. And then we see that the list is now shorter. I think that that kind of a interactive tool is really, really useful for teaching students, um, beyond those things. Uh, there are lots of other tools like the tools that there are for formatting code, like a YPF and black linting tools like flake eight and pilot, which I also cover in the book. I think those can really help a person figure out what’s going wrong with their code, or just find ways to improve it. And really, I think the biggest thing that it’s maybe not a language feature, but there is this huge community around Python and which includes a lot of documentation and just places to go where you can just Google for, uh, you know, like, uh, I just teach the students like, you know, Python add element to a list. I mean, you just Google for that. You’re going to find dozens and dozens of examples and answers from everywhere from Reddit to stack overflow. There’s so many books, it’s those things. I think just the community around Python also make it a very strong language and make it easier to learn because there are places and people to go to when you get stuck. Yeah,

Felienne 00:06:59 I totally agree. I think the community of Python is definitely something that’s not necessarily the language itself, but that makes fights in a really nice language for learners. And also I neither raffle. And, uh, um, the, the fact that blokes are delineated by spaces or tabs instead of brackets. I think also that’s, uh, a nice thing that helps novices learn to like program in a structured way because it forces them to do things in a certain way. So those are some of the things that, that are really nice for beginners. Not all of our audience of course are beginners in Python. So I’m also curious to hear, what do you think are some of the more advanced, very exciting Python language features or, or it doesn’t have to be a language feature. It can also, again, be broader in terms of the environment or the community. What are some of the exciting things for more advanced programmers to get out of?

Ken Youens-Clark 00:07:52 I think the thing that I’ve been most excited about recently, and I think it started in Python three, six was the addition of type hinting. And so I saw, uh, I think it was a C plus plus programmer, you know, had a tweet like the, the feeling of the C plus plus community. It’s like, wouldn’t our code be a lot cleaner if we could get rid of all these type annotations. And then, and then it’s kind of the opposite in the Python community, I think, is this like, wouldn’t our code be a lot cleaner if we could add all these type annotations and not actually really, uh, I become more enamored of, of strictly typed languages over the last couple of years. And, uh, I actually have been really using the type hinting a lot more. I don’t introduce it in type in a tiny Python projects until the very last chapter as kind of a, like, here’s where you could go from here.

Ken Youens-Clark 00:08:42 And here’s some of the things that you would get as benefits to using this new feature, but it’s that combined with things like data classes and these structures called name ticals, that act more like this, uh, the struct in other languages, you can essentially create new types in, in Python. And then instead of passing around, like say a string, you could say I’m passing in a phone number or, you know, a social security number if you’re programming in the United States, maybe, but, and so, uh, it allows you to more accurately describe the things that you’re dealing with. And I think that that has really made my Python code a lot more interesting and, and easier to check with, uh, tools like my PI, which I really find to be quite a good tool. I was really influenced by my, uh, journey through probably about 15, 16 years of being a pro programmer, really enamored inoperative Larry Wall, and his approach to Pearl.

Ken Youens-Clark 00:09:44 He really felt like there should be kind of a baby Pearl that you could learn that would work and that you could be productive in. And then as you got better with the language, you could start using things that were fancier and maybe more powerful. And I think Python really lends itself to that as well. So you don’t need to start programming with, with type annotations, but after you get to that point where you’re like, Oh, you know, I made this mistake in my code. If only there would have been a way for me to have caught that has, you know, without it being a runtime exception, something that blows up when the program’s running. And I think that when you can show someone like, Oh, if we can describe our code this way, and then I, and then like in the book, I say, okay, let me introduce this error.

Ken Youens-Clark 00:10:27 Like I type, I put quotes around true. So it’s actually a string instead of a Boolean type. And if I run this tool, it’ll actually see that I made that mistake and that’s, you know, that’s a pretty easy mistake to make. And so I think that that’s sort of, uh, this, this idea of like gradually typing your code, which is also something that they really brought into the idea of Perl six, which is, I think now called rec who that everything starts off as an any type, but as you need, you can start describing things more, more clearly, like this is an end with this as a string. And so I think that those are things that could really take someone’s maybe intermediate level Python to a whole other level, if you start introducing types and, and really trying to explore tools like my PI and seeing what it can do to improve your, the reliability of your code.

Felienne 00:11:18 Yeah. I think that’s a great addition. People of course, think of Python as a dynamically type language, which it is, but these optional typing features that are new in Python that, that people might not be aware of in need can help you find errors more easily. I’m really interesting. Interested also to hear like a more concrete example, you mentioned something like a social security numbers, but you also said that using types of has made your coding more interesting. So could you give an example of where adding types really added something to the code base?

Ken Youens-Clark 00:11:50 There was, there was actually, it was a module I just released last week. Uh, it’s, it’s an idea of an exploring it’s something I have to do so much is parsing CSV files, parsing, you know, the export from an Excel spreadsheet. And especially in this one project that I just left, there was essentially a value that, you know, some floating point value in each record. And a lot of the data I get is really, really messy. And there maybe that is, uh, in coded as some string to show that the value is missing and, or maybe it’s just, it was encoded in a way that can’t be converted to a floating point value. And so, uh, I kept having to solve the same problem with each different data set and they all look different cause I was getting data from, you know, a dozen different places.

Ken Youens-Clark 00:12:37 And, uh, so I was trying to parse through each record and parse this and, and convert this floating point value. And then, you know, if I was able to, can create this idea of a record, this, this, this, uh, this data point, then I could continue forward with loading that into a database or a, you know, another CSV file. And I came up with a way of describing what a record should look like out of this, out of this, any file. And I describe it with a type that I annotate use it. And so it was a, it is a class that I’m using. And I really, I make a point in the book that I pretty much avoid personally working and teaching object oriented programming style. But in this instance, I am creating a class based on a name Topal, which has this also side effect of giving me this read only, uh, this immutable data structure.

Ken Youens-Clark 00:13:29 And I can describe in the class that, you know, this thing has some sort of a variable name that is a string. And, but it also has a value that is a float. And I’m able to pass this into, uh, this, this module that I created that does the automatic, that does the conversions for me. And if it’s able to create that kind of a record, that kind of a shape, then it returns it to me. And if it’s unable to do that, then they could throw an exception or it could do something else. But, um, it was, it allowed me to describe what I wanted at a higher level and solve a problem at a more abstract level, because I was able to describe it using types rather than writing the same code for every single CSV file that I’m trying to parse. I hope that’s a good example.

Felienne 00:14:19 Yeah. I think there’s a great example. I would like to hear a little bit more detail because you also said that you use names tubals and the dead gave you an immutable data structure. So not everyone in the audience might exactly understand everything that you said there. So could you explain to me in a little bit more depth, what names tuples are in Python and how they give you immutability?

Ken Youens-Clark 00:14:41 This is I find this really fascinating. It’s one of my one, definitely one of my favorite aspects of the language that I’ve been using over the last couple of years. So I’m very much influenced by my experience programming or trying to program at Haskell. I’ll be honest. I’ve never actually been productive in Haskell, but I keep reading about it. And I find it a fascinating language. There was a dialect of Haskell called Elm that I’ve used on a couple projects to create web user interfaces. So essentially it’s, it’s a, uh, a subset of Haskell that, that compiles to JavaScript, which I find just fascinating. And so that’s a purely functional programming language that I’ve been able to really wrap my head around and become familiar with. And in one of the hallmarks of, of languages like that is that you essentially don’t have variables. You have symbols that are attached to, you know, functions or data structures, but you’re not allowed to change these data structures.

Ken Youens-Clark 00:15:38 You have to create new data structures from old data structures. And the, when I first heard this, um, cause I mean, going again, going back, I do not have a computer science background. I, you know, as I become from English, literature and music, so I’m completely self-taught. And so, you know, the idea that a variable is by defin definition, not variable. I was like, well then how do you get anything done in a language like this? You know? And, um, and, and, but then I started to see over and over again, as I was forced into a language where you’re not allowed to mutate any values that you just keep creating new structures. I was like, Oh, I, I see advantages to this kind of a programming approach. And also just where everything is just a function. They’re just, there are no objects, there’s no global state, there’s no global, uh, you know, an integer value that you can increment and stuff like that.

Ken Youens-Clark 00:16:32 And you’re just like all of a sudden forced to encapsulate everything. And, and, uh, there’s a lot of rigor to the language. And at first that’s really, really difficult and very constraining. But then after a while, I started to see how much the compiler was able to help me and, and keep me from making certain kinds of mistakes that I was always making. And so I wanted to kind of cargo cult those ideas into Python. And so in Python, we have lists. So strings, oddly are immutable. You can’t like change a letter in a string. Uh, you have to set the variable equal to an entirely new string value, but lists are not, lists are completely mutable. You can mutate any part of a string, uh, reverse it and all that kind of stuff right there in place. And so a Topal in Python is an immutable list.

Ken Youens-Clark 00:17:21 So it’s essentially a list and you have list access just the way you have, uh, normally, uh, but you can’t say pop an El element out of a topple. You can’t reorder the elements. You can’t change an element in place. And so a named Topal allows you to use that immutable data structure, but assign names to the slots instead of like getting at the zero element, the first element you can say, the zero element is the name and the second element, you know, the person’s age and things like that. So you start getting this, this data access that really looks like an object because it’s going to be like, you know, topal.name without the parentheses. Cause it’s not a method call it’s, it’s a field in, in that, uh, data structure. And then so named couples give you essentially a data structure that looks like an object that has a little bit, I think, nicer syntax for L uh, accessing the elements than a, than a dictionary.

Ken Youens-Clark 00:18:17 But then when you add type hinting on top of that, you get an immutable object, like data structure that you can now pass around. And you, you have this guarantee from Python itself that no part of that object is going to be mutated accidentally by your code. And an example of when I would use that for instance, is I always represent the arguments to my program as an ARG data structure. And the arguments are like, those are set in stone. Those came from the user outrun time. And I don’t want at any point my code to accidentally modify some parameter that was given at runtime. So when I represent that as a name Topal, I get that guarantee in my code. And I just can kind of put that idea to rest. I know that’s not going to happen. That that data is structured, not going to be accidentally mutated anywhere in my code. That’s a lot, but hopefully does that, does that make S I hope I explained that. Well,

Felienne 00:19:15 Yeah, I think so. So if I may summarize what I think you’re saying is that, uh, some of the concepts of object orientation and some of the concepts of functional programming are, are useful and new features in Python allow you to make use of some of these more functional style properties like immutability. And some of the more old, like features like typing to create a language that sort of has it all that has the dynamic feel of parole if you need it, but that also can help you make less mistakes by giving you types and giving you immutability where it makes sense. That’s sort of a summary of what you said.

Ken Youens-Clark 00:19:54 Yeah, I would. Yeah, that’s very good.

Felienne 00:19:57 Thanks then now I want to move on to the topic of the show. I think we convinced everyone now that Python is at gray language. That’s very versatile. So you decided to write a book on teaching people that have no prior programming experience Python. And I was wondering what is the gap you’re feeling? Because there are many books already out there to teach people programming or to teach people Python. What is the specific aim of your book? Why do you think an extra book was still needed?

Ken Youens-Clark 00:20:27 I think from my own experience of learning programming languages and I’ve, I’ve, I’ve, you know, just keep learning them. And, and I, I find this, the field fascinating. Um, one of the things that I stumble with when I’m trying to learn a language is just seeing a large enough example of a program, a full working program. So I’ll be like, like I remember when I was first learning high school and it was just trying to show me like how a function works. And it finally wrapped my head around that and I’m like, okay, great. Now, how would I use this in a larger context? Like, how would I write a program that I can run that, that reads in something like a list, and then does this thing that you were showing me about lists and Pascoe, how can I do that? And I just was stuck.

Ken Youens-Clark 00:21:13 I’m like, well, how do I, how do I write the program? Right. I just, I want more of context. And so that one’s, I think the first thing I just felt like so many programming books show you just a little bit of code. Like, here’s, here’s a list, but like, how do you create a list? And when in, in a program, uh, and so I wanted to show that’s like the second or third, you know, uh, elements in the book is it’s called going on a picnic. And so you get these, you get some command line arguments and there are lists. And if you get one, you’re supposed to show it like this. And if you get to show it like this other thing, and, and so I just felt like showing people more context would be useful for learning Python for learning any language.

Ken Youens-Clark 00:21:55 But really, I think the, the secret thing that I’m trying to sneak in, and it’s maybe not too secret is testing. I think that especially beginners are not taught testing. I think this is, and I know I wasn’t at all. You know, like, like you mentioned in the intro, I learned visual basic back in like 96. And I would say the first five, 10 years of my programming experience, no one ever used test, I worked in a bunch of industry jobs. I worked at, you know, delivering commercial software and there were no tests, insight testing just wasn’t done. And then finally I started coming across testing, you know, it was reading and, and, and I would see when I would compile programs and I would see I’m supposed to run, make test. And then, you know, 10 minutes later, it’s done with its test suite.

Ken Youens-Clark 00:22:41 And finally, I was like, well, what’s going on there with testing? And I started looking into it. I’m like, Oh, if I started testing my software, it would be better. And then when I started teaching, uh, I didn’t have tests at first. I was just kind of doing it the way that I had always been taught. Like here, we’re going to write a program. We’re just going to look at it. And if it looks like it ran, okay, then great thumbs up. You did great job. And then I found that if I introduce testing and I say, okay, now we have this thing over here. That’s going to run your program and tell you precisely, is it right or wrong? And if it’s wrong, it’s good to tell you exactly what’s wrong. I found that actually was really useful. I think that testing seems like it’s often going to be saved until later until you’re some sort of an advanced programmer and then you’ll learn it.

Ken Youens-Clark 00:23:25 Or like maybe when you go to your first job in industry, you’ll learn it. And I think that’s exactly the wrong way to approach it. I think that we, you know, I, I work with kids to help them learn bicycles. You never put a kid on a bicycle without a helmet. I mean, it’s just, I mean, when I was growing up in the seventies, we didn’t have car seats or helmets, but, but we know better now we use helmets. And so there’s no reason why not to teach, uh, someone programming, like from the beginning, Hey, you can test your program and, and, and, and you can make sure that it actually does what you think it does. And I think that that’s probably the biggest reason why I wanted to write this book is to give example, after example of what it means to write a program against a test suite. And when you’re done, you actually know that it works for some idea of some specification.

Felienne 00:24:14 I really liked this bicycle helmet example, even though I live in a country where no one wears it, how much, if they bike, I do get it. So it makes sense to have built in safety. However, testing is also hard and even professional programmers with decades of experience, still struggled to come up with the right tests. And often they think their code is correct, but then once it’s running, it’s entitled that they missed some sort of edge case. So how do you concretely teach people to test if they’re most really advanced programmers? Because some, some part of testing just comes with experience like knowing, Oh, I have to test an empty input. I have to test a really large inputs. These are things that also sort of come from having been in the ass by errors many times. How do you explain the value of testing to novices?

Ken Youens-Clark 00:25:06 The first point is, is exactly true. I, I just left a project that had been around for a year or so, mostly Python written by some pretty experienced, uh, developers, not a test insight, not a single test. And so I was actually brought in to help create tests. And, and one of the first things I did was I would just run a program with no arguments expecting to see like some sort of a usage or something like that. And the test, I mean, the program actually just charged ahead with bad input, just created exceptions and stack traces. And I’m like, yeah, this is a problem you really need to practice. You know, you need to run your program. If it expects a file, you should give it something. That’s not a file and, and make sure that it detects those things. And I, it is difficult to teach people, especially beginners testing.

Ken Youens-Clark 00:25:56 And so, you know, my goal and, and, and I’ve used this, this book in a class a couple of times now that I’ve taught, uh, you know, again, that’s, that’s where this material came from. Mostly what I’m hoping that you’ll get by the end of the book is that test can be written. I try to get the user, I try to get the reader to write unit tests. The integration tests are quite a bit more difficult because you kind of have to understand like the command line a little bit. And that’s what I’m really providing, especially up front are these integration tests. So tests that will, so, you know, just start off, you’re supposed to create hello world and it’s supposed to be called hello dot P Y. And so the first test is that you created a file called hello dot P Y. Right.

Ken Youens-Clark 00:26:40 And then, uh, and then it runs the P the program. And with like, it’s supposed to say, hello, uh, universe instead of hello world. And it verifies that it does that. And I think just example after example, getting the user, getting the reader to run that test suite, to look at the test output. Um, I hope that after seeing what is it like 22 examples of, of that, that they’ll, they’ll kind of see the utility of this. And I really stress that, you know, around chapter five, we start getting into file handling and I say, okay, your program should expect a file that it’s going to read. Just so you know, the test suite is going to give you something that’s just garbage. It’s going to say, it’s going to give you a non-existent file for that value. And so I’m trying to teach you defensive programming in the same way I say, okay, this, this parameter to the program is going to be an integer.

Ken Youens-Clark 00:27:35 By the way, your test suite is going to give you a string for that. And your, your program is going to be responsible for detecting that that’s not an entity value. And, and, you know, and throughout the book, I’ll say, okay, let’s just peek under the hood. What’s going on in this test program. And we start looking at a bit of the code, and I say, do you see here, how I’m creating, this has the name of your program, and this is the name of this parameter. And here I’m passing a good value and here are passing a bad value. And when I pass a bad value, I expect that the program should return. For instance, a non-zero exit value. I’ve tried to teach, you know, the, the idea of a well-behaved program that should properly report its errors to the greater operating system. And so, and, and, you know, even working on this project that I just left, where, you know, again, written by professional software
developers with perhaps decades of experience, trying to introduce the tests.

Ken Youens-Clark 00:28:27 And just like, I literally spent like a month or six weeks just like saying, here’s an example of a test here. Here’s how we test, here’s what we should be doing. And finally tests started to be written at just as I was leaving the project. And so it is an enormously difficult thing to get across, even from the beginner to the experience person. But I think that if you keep showing examples of how this leads to better, more reliable code, it really starts to show us utility, especially with the ideas of refactoring, which is, you know, something I really talk about in the book a lot, because I don’t just find one example, one way to solve something. Uh, there’s one, this, this, uh, silly exercise called apples and bananas as a, as children’s song. And I like to eat, eat, eat apples and bananas.

Ken Youens-Clark 00:29:18 And then you start saying, I like to EIT EIT, EIT, I pull up benign eyes and things like that. And so it’s just teaching children, uh, these kinds of vowel sounds. And so the idea in this is that you’re supposed to replace all of ours with one vowel. So, uh, given any input phrase. And so I show like eight different ways to do that. And the whole point of the test suite is that I can write a simple, uh, solution that works and pass the test suite. And then I can say, okay, I have freedom now to explore and find other ways in the language that I can do the same thing. And I can always come back to the test suite and verify that my program still does what it’s supposed to do. And it’s instantaneous and painless to just say, PI test. And it just runs it. And there’s just no effort at all required because I, as the author have provided the test suite. But I hope that by the end of the, of the, of the book that you realize while there really is a lot more freedom by having this strict, uh, test in place that really verifies that my program does exactly what I think it does.

Felienne 00:30:23 So in summary, what I think you said is you have to show North says lots of examples. Most of example, desk gold. This is how Tesco looks like. So, so they get the hang of it and also show specific situations in which tests really add value. For example, if you’re refactoring, if you’re modifying your code, then you can rely, you can trust your tests to help you understand is the code is still working as intended. So giving examples and giving examples scenarios where tests are really valuable, that’s the way to get even beginners do experience testing. Yes. Then there’s more in your book also because the Swift, I love your book is learn coding and testing with puzzles and games. So I want to ask you many things about all of the individual parts of that. So best thing, I think we’ve heard them coding we’ve covered also, but then there’s still puzzles and games. So what, what, what are puzzles, what type of puzzles does the book over

Ken Youens-Clark 00:31:22 Let’s I want to remember. So, you know, in trying to create a program that you could teach something from there, you know, I was trying to get across maybe three or four, maybe five skills in any one exercise. And I definitely wanted the programs to be a hundred lines or fewer, probably a lot of the programs, especially in the early part are 70 lines or fewer. And, and that’s pretty generous too, because I’m using a, a format or that is, you know, pretty vertical as far as the way it distributes code. So, so I had to choose examples that were really simple enough that I could fit in to that few lines of code. And, and I also just, I wanted the cognitive load to be lower. So I didn’t want to teach something really complex, like the, the goal of the, of the project of the program.

Ken Youens-Clark 00:32:08 And you’re into also the programming thing that we’re the programming concepts that we’re trying to learn are also really complex. So I was trying to keep things really simple. Um, I, for instance, really like ideas of cryptography, uh, and, and chapter four introduces this idea of it’s called jump to five. So given a string, find all the numbers in the string, and then in code the numbers by using this algorithm called jumped to five. So, uh, if you look at a standard keypad on a telephone, the one would jumped the to become a nine and the, the two who jumped the five to become an eight and the five and the zero, then swap places with each other. And so that right there, I feel like there’s a lot of interesting things to piece out, like how, okay, how do you iterate over every character in a string?

Ken Youens-Clark 00:32:54 How do you identify something that is a number given a number? How do you change it to something else, given something that’s not a number? How do you just skip over it? So I think there’s, you know, that’s a, a kind of puzzle and it’s also a kind of encryption and, and a way of encoding text, like a secret kind of. And I feel like that’s kind of interesting. Uh, it also, by the way, comes from like a television show called the wire, which was pretty popular in the United States a few years back. And so it has like, there’s, there’s an interesting backstory, I think, to it. So like that’s a simple little puzzle. I think that makes for an interesting, uh, chapter that I could write, you know, another, one’s not really a puzzle, but it’s like an insult generator, I think. And I really wanted to, to, um, I wanted the book to be playful.

Ken Youens-Clark 00:33:41 In fact, my, my original title was playful Python. I wanted the book to just be interesting and fun. And so there was an insult generator and I’m also targeting really, you know, my oldest is 16 and he won’t read my book, but he might one day. And, uh, I was really, I was hoping maybe even a middle schooler might find it funny and interesting enough, but probably not. I have used this at the, uh, at the, at the university level. And, and I think that these are simple enough to understand the idea of what the program is supposed to do, but still interesting enough to make you want to finish it. So it’s, you know, the, the, the, the, the insult generator uses a bunch of Shakespearian, adjectives, and nouns in it. And, uh, and it teaches you about randomness and setting random seeds and taking random samples and then putting strings together and iterating over things, but doing things a certain number of times.

Ken Youens-Clark 00:34:34 Uh, so there’s a lot of things that you can teach in that silly example that doesn’t do anything useful in the world, but what you end up with is something that you can now sit there and, you know, what whole insults that your sister or something. And, and that’s funny too, you know, to an extent, maybe I think it’s a little funny. Uh, and so I’ve just tried to keep with simple things like, you know, Madlibs, do you have Madlibs in your part of the world? Yeah. Okay. So, you know, um, that is an example where you could talk about regular expressions. And so, and I think, and that’s a really common thing that most people have encountered that idea. And so there’s not a lot to teach there. And then tic TAC toe is where I end. And I know that’s a, not a groundbreaking, uh, to do tic-tac-toe, but I think that I show for instance, a way to test, like if you’re going to create a tic-tac-toe game, how do you ensure that it works correctly? And, and for a game that is actually interactive, where you have two players who are, who are choosing things that, you know, you can’t test the whole game, maybe like that in its interactive state, but you can break it down into units and two functions that can be tested. So, you know, that with this part of the program is run. I know what’s going to run correctly. So those are the kinds of games and puzzles that I was trying to target

Felienne 00:36:20 I think you broadly, already answered my next question. I was going to ask you, what is it about puzzles on what is it about games that make them really good for teaching? And I, I think you answered that by saying that puzzles on games are fun and interesting, and they’re, they are a way to get people interested in coding and also to convey what the things are that coding can do for you. But I’m still also wondering about downside. So are there any downsides about using games as a context?

Ken Youens-Clark 00:36:50 Well, I definitely saw, you know, I follow a lot of things on Reddit and, and somebody was made this exact comment about like, you know, I’m sick of seeing everything about learning Python, being about games. And, you know, I think specifically they were sharing some idea of like a class, um, you know, for teaching object oriented stuff in Python, that was like a player. And, uh, you know, like a player maybe, maybe like some sort of a first person shooter game. And they were like, can we please get away from every example being about games? And I don’t actually play games like that. I’ve never been enamored of computer games and doom and, uh, all those kinds of things. Um, so I guess I was just thinking about like, games that you could just like draw on a piece of paper or that you would just kind of do in the car.

Ken Youens-Clark 00:37:37 And so, yeah, I mean, not everyone’s interested in games. I was in some of my examples that didn’t make it into the book are like, uh, from board games, like a Yahtzee, uh, which is a dice game or Scrabble, uh, which is a tile based game with letters I’m personally interested in those kinds of, of, uh, algorithms, like, you know, given seven tiles and what other tile, what are all the possible words that I could spell. That was my Scrabble game. To me, that’s very interesting. It may not be interesting to someone else. And so, you know, I, I recognize that.

Felienne 00:38:10 Do you think creating those games, so not just trying to game per se, but the process of creating games and puzzles, is that a good representation of what a programming career is about?

Ken Youens-Clark 00:38:21 Oh, certainly not. Yeah. I mean, but honestly, honestly, what I’ve done so much in my career would probably just be very boring to somebody to teach from the beginning. I mean, unfortunately a lot of what I’ve done is like cleaning up input data files. Uh, so I get, again, going back to like a comma separated values, uh, input, you know, or, or an Excel spreadsheet that I get from a researcher, or I download as, you know, the supplement to a paper and I need to incorporate this data into some database I have. And so, you know, like that right there is probably about 50% of my career is building databases and loading them. And that’s fairly advanced. I mean, there’s, there’s an actually, that’s a book that I want to write one day. Uh, but I don’t think that, you know, you can, I don’t, I, I certainly don’t think I could take a teenager and convince them that this is really interesting and that you could make a really cool career out of cleaning data sets, uh, for scientists.

Ken Youens-Clark 00:39:21 But it’s a really important part of the process of, you know, if we’re going to move knowledge forward, we need to have an accurate representation of it and we need to collate it and aggregate it and analyze it. And so, um, no, it means certainly gaming and these kinds of puzzles are not representative of, of really what I’ve done, but there are elements to each program that carry over directly into things that I do every day. And when I was using these examples for my class, I would teach a chapter. We would work over on a chapter on Tuesday and during, on the Thursday class, it will be applying that idea to something in genomics, uh, something in our field. And then we would just spend the whole class on Thursday talking about like that more applied example. And I th I think that the, the step from these simple games to things that you would actually do in the real world, I try to make at the end of the chapter is kind of like a little going further idea. And I, I, I try to make a hint at, at like how you could use this in a larger context, uh, in a more realistic context. And then didn’t always, you know, really convey that as well as I should. But I think that’s my answer.

Felienne 00:40:32 I, I totally think the answer makes sense. Like you want to emphasize the cool bars or programming, any interesting parts of programming and sort of initially step over to things that might be boring or repetitive. I’m not sure we don’t always do that. Right. If you teach your teenager to do some cooking, there are also boring parts. You have to wash your hands. You have to wait for water. Not everything can be exciting all the time. So it probably is some sort of balance where we want to show them some boring parts. I mean, maybe you could also say that focusing on the testing and focusing on the correctness sorta is also somewhat boring. It’s probably less fun than creating something yourself, but there you, you, you, you err on the side of caution and you’re like, this is so important. So we definitely want to show how to Desco. So I just, just like an interesting brainstorm question, how much of the boring stuff do we want to show them to give them a sense of where programming is and how much cool stuff do we want to give to also lure them in? So

Ken Youens-Clark 00:41:36 I think you just have to keep mixing the two together, uh, in layering them, um, you know, spoonful of sugar helps the medicine go down. Right? So, uh, and, and, and, and I bring in the testing in the very, very first example, like, okay, we’re going to write hello world. Here’s the test to make sure that it writes that we actually print hello world, and you can’t miss a single space or comma, any piece of punctuation. It has to be perfect. And, and that push to perfection. Yeah, that’s boring. It’s like, Oh, come on. Didn’t I get it close enough. Well, no. I mean, you know, that’s, it’s closest not good enough most of the time, at least, you know, when we, when we’re writing computer programs and it might be in cooking and I was working actually with my youngest this weekend and the kitchen, I was trying to get him to help him make a cake.

Ken Youens-Clark 00:42:22 And, and I’d set out two sticks of butter and he was going to vote. One was for the icing and one was for the cake. And he was about to throw both of them into the cake. And I was like, wait, stop. As like, you need to read the directions. He’s like, I did read the directions. It says to add the butter, I’m like how much butter? And he’s like, it doesn’t say I’m like, it does say this where it says, add, wants to get butter. And so, yeah, I mean, you know, and so like, after I had, I had admonish them a couple of times, like he was really getting down and my wife was like, Hey, you’re being a little hard on it. You know, he’s just going to leave. I’m like, you’re right. I need to keep him focused on the fact that he’s going to have a chocolate cake at the end of this exercise.

Ken Youens-Clark 00:42:59 And then he did it, he made it, and we got past, you know, a couple of rough things, but, you know, at the end I’m like, okay, you gotta watch those pots. And, and I just laughed, like, you’re the cook like this part of cooking. Um, so yeah, I mean, you, you, you have to teach those, those, I mean, it’s not that hard of a lesson, but, you know, your program should be correct. I mean, it should, and we have ways of verifying that that programs are correct, and that it’s not that burdensome to make sure that we’ve actually wrote written it correctly. And I think specifically working in the field of scientific computing, we have a odd or complete crisis of reproducibility. And I think that what I’ve seen since I came to university of Arizona in 2014 and, uh, and really got to work like really in academic research computing and really working more with graduate students, undergrads and post-docs, and seeing how much of the burden of science falls on the PI has come up with the ideas for the experiments.

Ken Youens-Clark 00:44:03 And then it’s these students jobs, or these young professionals jobs to execute these, these experiments and to analyze these data sets. And often they’re producing datasets that are quite large and extensive, and they need help computing help to analyze them. And the PIs don’t have that. And everyone just seems to assume that people are going to just find out, they’re going to figure out on their own, how do I programs and that these programs are actually going to be reproducible so that they’re released as the supplement or the GitHub repository for, for, for, uh, for paper that other people are going to be able to download and use these programs. And like, most of the time, they’re not, they’re really horribly written and they’ll barely work for the person who wrote them and they’re not going to work at all in a different computing environment.

Ken Youens-Clark 00:44:51 And so, you know, just from a larger standpoint of what I’m trying to do in the world, I want to make computing reproducible. And if you’re going to work in, in a dynamically, uh, somewhat loosely type language like Python, you’re going to have to write tests if you’re going to, if you choose to work in a, in a more in a stricter language testing, maybe less important is still going to be important. Um, you know, especially just like given this input file. If I run my program, do I get this output file? I mean, you need to verify these things. And so those were some of the things that I was trying to do with, like, why is this important? And yes, we’re trying to create cool things, but along the way they have to be. Right.

Felienne 00:45:36 Yeah. And I think this balance is even true for professional programmers. It’s always nice to create things. And then you shorten it, you get excited and you get into the flow of programming. I have to tell yourself, well, wait, wait, I need to add some tests. Or if everything is done, maybe I should be a responsible person. Every factor is gold. So it’s more readable. There’s always this tension between creating things and then cleaning up after yourselves in programming, but also in order area. So I guess some of the tension there is also just some decisions you made for the book.

Ken Youens-Clark 00:46:09 If I could, if I could follow up on that. I think that, you know, obviously I was writing this book and then like putting my name on this. And so I was really trying to internalize these ideas and really trying to explore what is test-driven development. So of course that, that phrase comes from a, I think it’s 2002 book by Kent Beck and that the basic pedagogy is you, right? You, you, you have some feature that your program should do. And so you write a test that verifies that your, that your software does not do that thing. You run this test, you see it fails. That’s the first step. And then you go, right, the function that the, or the, or you implement the feature that fulfills that test, and then you run the test suite, and now you see it does hopefully pass your test suite.

Ken Youens-Clark 00:46:56 It’s kind of the same thing. Like my wife and I joke that like, uh, you know, once we had children, we had to start eating better, right? Like we kinda ate a lot of, you know, store-bought junk and, and, uh, didn’t really focus on a lot of fresh vegetables. And then all of a sudden, you’re this model for these, for these young people, and you want them to grow up eating well and having good habits. So you have to model these things. And so, you know, I started really pushing these ideas on myself, like, okay, I need to write this function. And, and really it has come to dominate the way that I, especially in Python is that I write the test first. I think of the function that I want to exist and our first go, right. You know, test underscore function cause I’m using PI test.

Ken Youens-Clark 00:47:40 So it runs all the functions that, that start with test underscore. And I say, okay, this, this, this putative function is going to take a list and it’s going to return a string. So what happens when I give it an empty list? Okay, well, I would expect to get back an empty string. If I give it a list with one element I expect to get back this string, you know, so I actually write down examples so that I can see if I give it this, I’m going to get back this. And then I go write the function. And I’ve been surprised. I, how many times I misunderstood my own ideas. And it was older by virtue of having written that test, that I realized that I didn’t implement the function correctly. And I’ve been programming for like 24 years. I mean, and, and I’ve done a master’s degree and I’ve learned, you know, a dozen different languages. And so I think I’m a pretty capable programmer and I still make really, really dumb mistakes all the time. And it’s only by virtue of forcing myself and really not even forcing. I really, this is how I think now I, I, I can’t write code without writing tests. And I think that is, uh, is it has been a sea change in my mind. So the idea that I come in later and write the test is completely backwards to me, the tests come first, and then I write the program. That’s that, that satisfies the test.

Felienne 00:49:06 Yeah. That makes a lot of sense. I’m now just curious, like, was this a slow evolution in your thinking, or was there more like this big bang, this horrible one bug sort of like the, the birth of your children that you’re describe? It was like, okay, from now on, I really have to do better. Is there, is there a juicy story here or was it just slowly you realizing that that was the way to do it?

Ken Youens-Clark 00:49:28 It was really slowly realizing it, it was, you know, I try to pride myself on not making the same mistake, the big same mistake twice in life, but I make a lot of the same small mistakes over and over again. And I did those so painful. Like they accrete in my life and finally I’m like, why am I doing this stupid thing? And so, you know, it was really when I started releasing software on C pan and Pearl, the comprehensive per lock network. And I was like, I finally came up with an idea that I wanted to share with the world and I was really, really excited about it. And I’m pretty sure my first released had no tests. And then I started looking around, I’m like, Oh, no, tests are a part of what this community does. Like, that’s kind of an expected step that there should be this testing component to the software.

Ken Youens-Clark 00:50:17 And there was a few different testing harnesses and just sweets and Pearl. And so, you know, I just took the time to learn them. And I started learning about like the, you know, co code coverage. I started thinking, well, can I get a hundred percent code coverage? You know, like in this small module that I’ve written and I just really kept pushing myself, like, what can I do with testing? And then, and then I just, but it was only for stuff that I was releasing. It wasn’t really for stuff that I was writing day to day. And, and I just kept realizing, especially as in, again, modeling this behavior for students and teaching this in the classroom and trying to show the utility of this and then starting to really try to make myself do it more. I realized this is, this is actually really, really good.

Ken Youens-Clark 00:51:00 And, but the other, the other big thing, and, and, and I anticipate you may ask, like, what are the things about Python that make it not so great for teaching? And, and so there, uh, there are a lot of mistakes that you can make in Python that, um, if you’re not really aware of like how a lot of computer science-y stuff works, you’re just going to get a runtime exception. The program’s just going to blow up. And so when I work in stricter languages like, uh, Elm or rust, certain classes of bugs just don’t exist for me because the program won’t even compile, if I, you know, have made, have forgotten to handle some exception case. And in Python, that’s not the case. The, the Python code will just compile. We talked about tie pens, and they’re really, really awesome, but Python itself completely ignores them.

Ken Youens-Clark 00:51:47 You have to use a separate tool to analyze your, your code, to see if you’re using the tie Taipans correctly because of a function says it takes an integer, and then it runtime, it gets a string Python doesn’t care will just keep running and create a runtime exception. And so what I just found was that when I started really adopting test driven, ideally when I’m writing Python code, my Python code is much, much better. And so finally just like, you know, stop fighting it, just do it the right way. And, and your programs just end up working a lot better.

Felienne 00:52:21 So we’ve covered Python now as a language. And I really liked that you already, you’re just thrown in some of the downsides of Python, which in, this was also something I wanted to ask about. So let’s, let’s step away from Python as a language and let’s move on to, how do you actually do Python if you’re a beginner? Because of course, when we were learning to program, there wasn’t something like an IDE, there wasn’t an integrated development environment. You would typically type code in a, in a text editor like thing, and then run it on the command line. But PR program has changed quite a lot. So how do you tell novices to deal with that today? Install an IDE. Do you start with something like an IDE so that it can run tests and then maybe it’s can do refactoring? Is that something you also bring into the toolkit kids of woven verses, or do they first have to learn it sort of like we learned it the old school way in the command line, what is your pick and why?

Ken Youens-Clark 00:53:19 I definitely think that, uh, can be extremely helpful to the beginner. And, and I, I, I do teach the command line in this book and, and for like a windows programmer, it is going to really require installing something like windows subsystem for Linux, which in and of itself is, is a barrier. And, and there’s like, you know, there’s a payoff in that the programs that we create, I think are really stripped down. I think that learning command line programming is real really, in some ways, an ideal way to, to talk about things like a string or a file or a number, and, and inter-religious think about programming concepts, but a barrier to getting a command line environment. And actually, I, I really, you know, uh, uh, our, our, our listeners won’t nervous, but, but you looked at some early texts of the book and you had a lot of really great feedback.

Ken Youens-Clark 00:54:13 And one of which was like, what if a person is on a computer and they can’t install Python and Python is not installed? Like, what are they going to do? Have you looked at something like it, our epl.it, which is a website that provides basically, uh, an IDE in the browser, the, and the command line environment for, for running these programs. And when I looked at it, my mind was blown. I was like, I had no idea this existed, and I can totally see the utility for this because, uh, like one of the things that my wife has done over over the, over the years is like work with a lot of nonprofits, especially libraries. And in this small town, in New Mexico, where we were, the computers at the library were for a lot of people, the only computer that they had in their life.

Ken Youens-Clark 00:54:58 And they would come in to check their email, do their taxes, watch videos, whatever it was. And you know what I’m specifically thinking about those kids that would sit down, had no computer at home, but wouldn’t be able to install Python on those, on the library computers. And so when, when I saw that I was like, this is a total gateway drug to being able to do these sorts of things. And so in, in when I’m teaching in class, I recommend that students install something like vs code, which is a Microsoft tool, uh, integrated development environment, uh, or, um, some of the editors like sublime and pie charm is also an ID, but some like, uh, an editor like sublime or text mate really have a lot of features that are almost like an IDE. So I think there are a lot of tools that would really help a person to write code.

Ken Youens-Clark 00:55:45 Um, I stress a lot about going into the rappel and, and using the help documentation there, but IDs can just right there in context show you, Oh, this is a string in, you know, you type the name of the variable dot and it will start saying, Oh, here are all the methods that belong to that class. And so those are things that could really help a beginner. And so I think that there’s a multitude of tools that a beginner would probably really benefit from using from web based IDE is to, uh, ones that would, that you can install on your own program. I mean, on your own computer, but there really is like just Python itself. If it’s not already installed him. And a lot of times it is, but if it’s not already installed on the computer, that in and of itself is not a beginner task.

Ken Youens-Clark 00:56:32 Uh, so that could be just, that could be a huge barrier. You know, my kids, their first programming experience has been scratch from MIT, the little with the little cat. And so, you know, and, and they’re not really even typing that much, but they’re being introduced to the ideas of variables and loops and things like that. And so I think that there are more things that we could do to make it easier for Pete, for beginners to learn. It’s certainly not easy. And, and the first couple of weeks of class is really just trying to get my students some sort of environment where they can actually write and run code. Uh, I would say it takes about a month before they really start feeling comfortable with what they’re doing.

Felienne 00:57:11 And do you think that changes over time? So with testing, you take a strong stand. You say testing, you should learn it from the beginning because it’s important. So for an IDE, would you also say it’s important to use a very powerful tool from the beginning because it matters, or would you say, as you are advancing as a programmer, your tools should also get more advanced.

Ken Youens-Clark 00:57:35 I think that you should be open to change. Uh, you know, and I say that, although I, I, when I write code day-to-day, I’m still using them, uh, which I learned what in 1997. So, you know, I haven’t changed. I write code exactly the same way that I’ve written it, uh, over my entire career. Um, and I’ve had to use IDE is like when I was, you know, programming a Delphi and things like that, but I always have come back to the command line. When I teaching in class, I use an ID because I show I’m trying again, trying to model what I think my students should be doing. I think that’s, what’s appropriate for them. And, and, and like, for instance, if us code is, is the one that I’ve done, all the videos with right there in the window, it was a command line. So, you know, you, you have your, you have your file browser on the left. You have whatever program you’re working in on the right. And below that, I have a little editor, I mean, a little, uh, terminal, and I can just say, okay, go run the program and run the test suite. And then there are the results right there. And so it, I think it’s a really useful tool when I’m writing code for myself. I usually just have a couple of terminal windows open.

Felienne 00:58:41 I think what you’re saying, but correct me if I’m wrong here is that your take is that IDs are very valuable for beginners. So you use them in teaching and you use them and making videos for the book, but you, yourself still prefer to program on the command line as a more advanced programmer.

Ken Youens-Clark 00:58:59 Yes. Uh, and, and so much of it is muscle memory. If, if for your listeners who don’t know VI, it has all these really cryptic key combinations. Um, but, um, my, my hands like never leave the home keys, right. My, my, I just I’m able to do everything that I want to do without the aid of a mouse and just by typing and, and, and the commands just so deeply embedded in my brain that I’m not sure I could write code as efficiently as I do. Uh, if, if I were forced to use an IDE all day, every day, they’re really useful tools. And I think everyone should do whatever is good for them, whatever works for them. And this is what works for me. And I think I’ll just keep doing it until I die.

Felienne 00:59:44 Oh. As like a final topic in this episode, the Python ecosystem, because all the way in the beginning of the episode, you said, what I really like about is everything. It brings like libraries for data science, for machine learning. So I want to like loop that back to beginning programmers. Do you think teaching just a fun Naila Python is good for beginners, or do you also want to show them from, from the get-go Hey, Python has this super rich, she have modules and I think there’s one library. Oh, yeah. For example, in your book, you do show learners, regular expressions. So Brantley, there are some of these things that you think really add some flavor to Python. What do you think is the best way? Show, show a bit, show nothing, show many things. Does it depend on the audience?

Ken Youens-Clark 01:00:31 I, I CA I think, again, this goes back to, uh, the influence that I had when I went over to say working in Elm. And I think that I just got so focused on, on like, what can I do with the string? What can I do with the list? What can I do with something like a dictionary? And I found that the more I focused on understanding the fundamental data structures that are almost universal to pretty much any language, those kind of three things, you know, strings and then numbers, I guess. And then Lewis dictionaries, I think ruin, fundamentally understanding those basic data structures is key to working in any language I do bring in regular expressions, I guess, because they, they, don’t such a cornerstone of what I have to do, especially when it comes to like cleaning up datasets. There’s so many problems that can be described with a regular expression.

Ken Youens-Clark 01:01:27 And it’s this whole other thing that, um, I got introduced to really, when I minute went into Pearl. And then especially when I went into genomics, because so much of what we do is stream manipulation and looking for patterns and text. Um, and so I really felt like that was something that needed to be introduced. I almost never encounter, certainly not a novice programmer who’s ever heard of regular expressions. And I think that that’s like a power tool that you need to be made aware of really quickly, because you’ll be able to use that so many times. And another module I bring in a CSV for separate for parsing comma-separated files. But, you know, in talking to the editors in creating this book with Manning, they said, you know, there’s only so far, you can take a person. So on a scale of one to 10, you know, like one being a novice and 10 being like an expert, we’re not going to take someone from a one or two to seven in the course of one book, that’s too great of a leap.

Ken Youens-Clark 01:02:23 We, we try to shoot for like a movement of two or three clicks. So, you know, from a beginner to sort of around the cusp of an intermediate, maybe from an intermediate to something more close to an expert. And so I wanted to start this boom basically from the beginning. I know that if somebody never seen a function, never heard of a loop or variable, they would probably not be able to dive straight into my book. But I think especially if you were coming from a language where you already basically knew these things, and you just wanted to know what the, how they were done in Python, like you were moving over from JavaScript or something. I think that I start at a good level, not too, too basic. And I think I moved up quickly enough to where you would be kept interested. And, uh, and so I, I really do just want to focus on PI, you know, we start with Python strings and then we talk about how they’re similar to lists, and then we move into lists and then we move into dictionaries and then we move into file handling.

Ken Youens-Clark 01:03:14 Then we, we talk about, you know, standard and standard out standard error. Then we start talking about regular expressions. Then we start talking about like parsing files and making games and randomness and, you know, and so I think that there’s a lot of things. I, I, I guess I was just biased in what I wanted to cover. There is a huge, huge ecosystem of things that Python can do. And I just really wanted to focus on the language itself. And it definitely, um, one of the early reviewers, he was, uh, he’s a, a respected best-selling author. Um, and he also said, well, you’re writing a vanilla Python book. You know, like why, why would somebody want another vanilla Python book? And, and I just, I guess, you know, the secret thing, the thing that I really want to sneak in under the covers is the testing.

Ken Youens-Clark 01:04:01 Um, so, you know, Python is a, is a cool language. It has a rich ecosystem, but more than anything, I want you to leave the book thinking no matter what language I’m working in, I understand the basics of loops and these basic data structures. And I understand that software needs to be tested. And I understand a lot of the skills that I show in the book. You could write Python tests for a program that you write in any other language. Cause I’m just showing you how to run the program with different inputs and do you get the right outputs? And so I think those are the things that I really hope people will take away is, is how do you write reproducible, documented really kind programs. Like I really stress that it’s our program’s responsibility to show how they are intended to be used. And if you’re using a module in Python, like arc parse, where you describe the arguments to your program, it can do all this data validation for you, and also present the user a usage statement, like here’s how I intended to be used.

Ken Youens-Clark 01:05:05 And I was one of the other projects I was working on this, uh, over the last few months entirely written in R and not a single program, uh, out of dozens and dozens of programs, command line programs, not a single one uses a standard module in our, for parsing command line arguments, every single program did it manually. And so one of the first things I did was I was like, you know, there’s this really nice module over here called opt pars. And you can describe all the inputs to your program and you can validate them. And you can, you know, you really erase a lot of bugs in this code base, if you just simply validated your arguments first and then tried to use them later in the program. And it was, uh, it was no one was really ready to hear that yet. So I hope that I’m teaching by teaching vanilla Python, by teaching testing ideas, I’m teaching more universal ideas that you could apply to any language.

Felienne 01:06:00 Yeah. So what’s your hope is that the things that people take away from the book, if they later, or go on to do our, or drive out or parole or whatever, all their programming language, that’s some of the, like some of the discipline that you show them in testing transfers to other programming languages and other contexts as well. Yes. Great. So I think that’s a great way to close it. Is there anything we missed on the show? Anything you still want to share with the audience?

Ken Youens-Clark 01:06:27 No, I, I, I’m looking over my notes and I guess there was one thing I would say in closing and, and, and I was just having an exit interview with, uh, so to go with my very first day at the critical path Institute. So on Friday I was having an exit interview with one of my PIs principal investigator at the university. And, and I was trying to explain why I think, like, what was the good and bad about using Python? Cause he’s pretty much settled on that for the project that he’s working in. And I said, you know, there’s just this inherent complexity involved in writing software and Python is, is great in one way because it kind of hides a lot of that complexity. It just kind of, you don’t really have to think about how a string or an integer is represented in memory.

Ken Youens-Clark 01:07:16 Um, you just, you just create a variable and if you put it in quotes as a string and Python takes care of all that, and that’s cool. And, but there comes a point at which programs become more and more complex just as they start dealing with more real world, uh, concerns like you, you try to get some data from, uh, from an API, from some sort of web resource and it failed. And the way when it fails can just cause the whole program to just explode. Uh, it can create an exception and the exception isn’t handled, then you get a stack trace and you know, you, you don’t necessarily want your users to see that. And so I was trying to say that, look, there is complexity. It’s just that Python pushes the complexity onto the programmer to handle and other, other languages like say rust force you as you’re writing the code to deal with the complexity then and there, and the program won’t even compile until you’ve taken account.

Ken Youens-Clark 01:08:08 What happens when we try to make this web API call and it fails, what are you going to do? Uh, you’re not allowed to district, well, you are allowed to disregard it if you really want to, but you’re making it explicit in the code. And so I think that we should definitely at some point really stress, especially to beginners that without if you’re going to work in a language like Python, at some point, your programs are become very, very complex, quite long. And without, uh, things like tests in place, you really kind of flying by the seat of your pants. And so you need to understand that their, their instance complexity, you are going to have to deal with it. And, uh, yeah, I guess that’s what I would close with.

Felienne 01:08:50 Great. So we will definitely add a link to your book so that people can check it out if they’re interested. And we’ll also link to replicate the web based browser, browser based IDE for novices. Are there any other things you want to link to? Is there any, anywhere we can read more about the work that you do personally, or to Institute you just started working for?

Ken Youens-Clark 01:09:10 Well, the critical path Institute is a nonprofit that’s, uh, uh, you can find it at C-PAP dot org. I’m really very interested to see what I’m going to be doing. I’m vaguely aware that I’m going to be working in like cleaning data sets and trying to find novel uses for existing drugs and maybe creating new drugs. Uh, and so if you’re interested in that, you can find [email protected]. My website is KYclark.us. But you know, as, as it’s typical, I rarely update it. You know, I tweet every now and then. No, I would say, um, uh, we’ve covered everything. Thank you so much. I really appreciate your time.

Felienne 01:09:44 Hey, thanks for being on the show today again. Thank you.

[End of Audio]

This transcript was automatically generated. To suggest improvements in the text, please contact [email protected].


SE Radio theme: “Broken Reality” by Kevin MacLeod (incompetech.com — Licensed under Creative Commons: By Attribution 3.0)

Join the discussion
1 comment
  • Thanks, Ken for your insights. I can relate my Perl journey with this which I am doing since 2007, actually, a couple of years back I have also started exploring Python for newer projects but so far mainly used in Data science/ML features, I am weighing the advantage/drawbacks/cost Python will bring in migrating my legacy code from Perl? I think your book might be a good place to see how this will work with real examples. Looking forward to having a copy (though there is no Indian reprint of the book) so might have to go for an import version .. a bit costly though 🙂

    Thanks to SE radio and Felienne for this episode.

More from this show