WEBVTT

0:00:16.028 --> 0:00:20.972
<v A>Programming Throwdown Episode 66: Code Reviews. Take it away, Jason! Hey.

0:00:21.816 --> 0:02:20.220
<v B>Everyone, this is our double for this month because of my illness last month. And one thing I did last month, even though I was quite sick, I was able to assemble a 3D printer, which was actually super fun. I went on GearBest, which is some Chinese distributor, and I ordered a 3D printer kit. It was literally just bags of screws and wires and rods and like this thing that had been cut out of acrylic, like a bunch of little acrylic pieces, and some stepper motors that you could have got just right off the shelf at Fry's or something. But you know, it came with the whole kit. And it was very daunting. I mean, the thing that scared me the most was at one point I pulled out of the box like a 120-volt plug that would plug into the wall, and the other end was just three bare wires. Don't stick them to your tongue, yeah? And I just thought, I mean, I'm not one of the people that like put paper clips in the sockets when I was younger or something. And so that whole like you know everything related to electrical work, I just have no familiarity with. But I just dove in. I knew that there were going to be a lot of good resources, and there are just an incredible amount of resources on how to do it. There's tons of videos from different angles, different people doing it, and I built it, and actually worked. It was a little bit scary the first time I turned it on; smoke started pouring out. Oh no! And basically, I had some of the copper strands of the 120-volt had touched each other and completed a circuit and like melted part of the thing. But it was okay. The part it melted wasn't a big deal. That doesn't sound okay? Yeah, it was. It was.

0:02:20.220 --> 0:04:10.844
<v B>Super scary. I was pretty sure I destroyed it. I got extremely lucky. Part of it too is as soon as I saw a bit of smoke, I unplugged it. And yeah, so that was the first issue. The second issue was the way it works. If you've never seen a 3D printer, you have two stepper motors, and you have these two cables that make one makes the platform go towards you and away from you, and one makes the printer head go to the left and to the right. But the part that makes the printer head go up and down needs to be very accurate, and so you can't have just a plastic cable for that. Also, you know, gravity is constantly putting tension on it. So for that they have these two wires, these two metal rods that are threaded kind of like a screw, but you know, you're not screwing it into anything. It's just two cylinders that have a thread, and they plug into two stepper motors, and they both turn kind of in sync. And so the idea is when you turn both of these screws together, it kind of makes this whole kind of platform rise up, and when you turn them the other way, it makes it rise down. And I guess those rods needed some WD-40 or some grease or something. So I didn't do that, and you know like there's just like the friction was causing everything to get messed up. It wasn't, you know, the left and the right side weren't rising up the same. So there's basically long story short, there were several times where I felt like I was out the 220, and I felt like it was just like, you know, I tried it, it's ruined. You know whatever. I kind of felt kind of bad about it because I wasted the money. But then in the end, I finally got it to work. It was just super satisfying. So.

0:04:11.704 --> 0:04:12.379
<v A>What have you?

0:04:13.139 --> 0:05:36.197
<v B>Been making? Yeah. So I printed a couple of things just to make just like some functional things, like I printed something to hold my watch, like on the dresser and things like that. I also had this crazy idea that I've had for a while, and I finally got to implement it. I went on Thingiverse and I found models of lions and bears and other animals, and at first, I 3D printed them, and my son got to play with them, and he thought it was super cool. And then I actually went in Blender, which is a 3D editing software, and I sort of detached the head. I decapitated all of these animals, and then I made the head screw and the body like a thread, and so you can actually screw off the lion head and screw it onto a bear body. I did it kind of haphazardly, so when you screw the head on, it doesn't screw on straight, so all the animals look like they're kind of turning their head, wonder like they're all looking over their shoulder, but it's still really fun. And my son and I, we got a huge kick out of it. That's pretty funny. Yeah, it was great. I highly recommend doing it, especially if you're in high school or college, or if you don't have a lot of experience with electrical stuff. This is a great way to get started. It was something that actually worked, which is for me and mechanical things—that was a rarity. Well, except.

0:05:36.619 --> 0:05:45.968
<v A>For that part where you almost burned your house down? That's true. Yeah, yeah, yeah. Be really careful of AC mains voltage out of your wall. It's no joke.

0:05:46.859 --> 0:06:08.500
<v B>Yeah, yeah, that's true. I mean, I was pretty sure that I was going to destroy something like fundamental in my house, and I was pretty close to doing that. All right, don't do this without supervision. If you're in high school or something, have your dad help you or your mom help you, or have a friend over—someone who could put it out with a fire extinguisher or something.

0:06:09.036 --> 0:07:25.969
<v A>Words of endorsement from Jason. All right. Well, time for the news. My first link is The Competitive Programmer's Handbook. This is a PDF compiled by someone named Auntie, or yeah, I guess Auntie—and I won't attempt the last name—who compiled a whole bunch of tips and tricks and algorithms for the kinds of things you would need to be able to do if you wanted to do competitive programming. Now, you may say, well, competitive programming is starting a company and competing against all the other people starting a company in order to do better. But competitive programming, I think in this context refers to programming competitions where a bunch of programmers gather together and get assigned puzzles and problems and a time limit in which to solve them, and the sort of fastest to be able to solve—roughly to solve the problems is the winner. And there's a sort of points sometimes based on the difficulty of the problems. The exact structure of the competition can vary, but sometimes I think I did a couple of these when I did my Computer Science stuff in high school, I think like my senior year maybe. But I think most people get experience with this in college. The ACM, the Association for Computing Machinery, runs a really big programming competition each year, and yeah, I mean.

0:07:27.032 --> 0:08:05.929
<v B>The thing to keep in mind is that there's sort of this family of people who compete and then grow up and like grow older and become judges and then become problem writers. And so you know it means that there's like a specific niche of Computer Science that's gonna cover like 90% of the problems that you see in competitive programming, and so even if you might be a super strong CS student, but you also have to study the competitive programming world because it dives really deep into a handful of areas and doesn't cover other ones. So.

0:08:06.840 --> 0:08:21.522
<v A>Right. So sometimes the problems can be quite tricky. The sort of most obvious solution will definitely not work, and you need to understand sort of why it won't work and figure out what the trick is to it, and in that way it becomes a.

0:08:22.416 --> 0:09:14.020
<v B>Puzzle. Yeah, yeah, absolutely. I also did a bunch of these programming competitions in college. I think it's great. It's great experience. But as I said, there's sort of this hidden gnosis around it, and so it's very really important to study something. This is actually a great resource because it really covers it in a lot of detail, and it's a great way to kind of get familiar. A lot of the interview questions that companies know kind of are modeled after competitive programming assignments because mostly because of the time limit—you know like you have maybe an hour to solve a problem in a competitive situation, and you have an hour or even half an hour to solve a problem in an interview—and so they kind of end up converging a little bit there. So this would also help your interview skills.

0:09:14.290 --> 0:09:22.373
<v A>Yeah, and I think also just becoming comfortable with a lot of the algorithms that are necessary for the programming competitions are really helpful for the interviews as well. Yeah.

0:09:23.470 --> 0:09:24.027
<v B>Yeah, totally.

0:09:25.022 --> 0:09:54.165
<v A>Like for the reasons you said, the kind of depth you get into is about the same between the two because you just don't have much time to write well-architected code per se. It's mostly about sort of getting to the coding, the algorithm. But I will say most of the things in this book, especially the later half, are things like it would be awesome to understand and to do well in programming competitions are probably needed, but you would be unlikely to encounter these on a programming interview unless it was a really tough interviewer. Yeah, yeah.

0:09:54.537 --> 0:10:06.417
<v B>Exactly. I mean, a lot of—I would actually be surprised to even find any dynamic programming and things like that in an interview. But yeah, I mean these are like super advanced things, but definitely.

0:10:06.754 --> 0:10:31.004
<v A>A great resource. And if you're interested in or are currently doing programming competitions, check it out. Also, we do recommend—oh, I forget the name of the other one, but TopCoder is a website that has programming competitions. And there's also HackerRank, which is another one. And so those are also good resources to gain practice, apply the knowledge you learn from this book, that kind of stuff, but also to prepare for programming interviews. We get that question a lot from listeners, so yeah.

0:10:31.409 --> 0:12:07.917
<v B>I actually—I helped someone about a month or two ago and you know he asked me for help interviewing at a company I used to work at. And I told him, I said let's just, you know, open up HackerRank and start solving problems. I still think that's the best way to go about it. And if you don't have a lot of experience with competitive programming, then chances are even if you're really good at CS, you're gonna have a hard time with something like HackerRank, which is kind of the point. Like it's good to see what sort of knowledge gaps there are. And there's great documentation most of these sites give you the answer along with an editorial and things like that. So cool. So I'm going to talk about C++17, and so I'll give a link to it. A lot of new features, a lot of cool stuff coming out. It's amazing because I remember C++11 being just super, super delayed and having to rely heavily on Boost like if you wanted even just threading, you had to use Boost. And I think C++11 was originally supposed to be C++08, if I remember correctly. We could probably find out from our old episode. It took till 11 to get it out the door, but now here we are with a 14 and a 17. And it's actually almost you know getting to the point where unless you're really heavy in C++, you can start to lose track of the latest features. But yeah, there's some really cool stuff here, and we've provided a link so you can kind of check it out like the latest and the greatest C++ stuff.

0:12:08.980 --> 0:12:16.360
<v A>Feel like we should enter into a segment where we discuss our favorite feature from the new. No, I'm just kidding. All right. I mean the

0:12:16.360 --> 0:12:28.167
<v B>One I use the most. I mean, this is covering all of the extensions is the totally—I totally forgot. I think it's called the range operator. Basically, it's where this

0:12:28.167 --> 0:12:29.027
<v A>comprehension is that?

0:12:29.980 --> 0:12:39.355
<v B>What it is? It's where you do like for x colon vector and—and then it saves you from having to write the whole for loop. I call it this comprehension, but

0:12:39.355 --> 0:12:41.363
<v A>I don't know if that's.

0:12:41.363 --> 0:12:43.540
<v B>I think I know it's that call that.

0:12:43.540 --> 0:12:44.164
<v A>in other languages.

0:12:44.519 --> 0:13:01.240
<v B>Yeah, that and the threading, like going from Boost Threading to just the C++ threading, it's literally just changing—it's a regex, right? But I had a bunch of code and still have. Now I'm producing a bunch of code that uses threads, and it's good that that's just baked into the language because you know it's so important.

0:13:01.240 --> 0:14:58.480
<v A>The other thing from C++17 is that's nice. They're continuing to support sort of extra features in the const expressions. So if you write a lot of const expressions which can be compiled-time evaluated—before it was very strict what could be in them—and now there's increasing things that are added to the list of what can be in them, which is good. Cool. Yeah, doing more like type inferencing. So my next news article is called Simple Chess AI. This is an article that was posted on I guess somebody's Medium platform, FreeCodeCamp anyways. We'll have a link in the show notes. And I came across this, but it was really interesting because a lot of people—well, you know, of course Artificial Intelligence is in the news a lot, and it means lots of different things to lots of different people. So I don't think there's any neural networks or there are no neural networks in this example, but they basically take a kind of minimal JavaScript implementation of playing chess and have it already set up for you to kind of plug and play your sort of move evaluator, the opposing player, the computer player. And I thought it was really cool because I've always, you know, thought to myself like, oh, I should make a, you know, chess bot or something that plays chess, but then it's always like setting up a representation for the board and having a visualizer—it's a lot of work to get to the thing you're trying to do. And so I thought this was a particularly compact setup. I probably could have gone and found, you know, something at some point if I had been serious about it, but it comes along with the tutorial where they take you first amount, you know, simply being able to make valid moves, then being able to talk about what the tree of possible moves would look like and how to evaluate that and then how to prune that tree so that you can go farther down the tree, which means in this case farther down the tree is further into the future of potential moves. And that way the more you can trim as these paths aren't good, then the farther down you can go.

0:14:58.480 --> 0:15:32.644
<v A>The farther in the future can look and the more sort of predictive your engine becomes and being able to be a little more strategic than just tactical. And then, you know, sort of how do you have heuristics for the relative point values of the pieces or what about different pieces are more or less important depending on where they are on the board? And how do you sort of encode that? It goes through a lot of it actually. I mean, I'm not a great chess player, so I'm pretty sure that AI that ends up by the end could probably beat me pretty handily. But I thought this is a very kind of interesting introduction to how to do sort of game.

0:15:33.032 --> 0:15:44.609
<v B>AI? Yeah, totally. I mean, even just a player like a simple heuristic like this with an eight-move look ahead will make an expert player that would be almost everyone who's not a competitive player. Yeah, chess is hard.

0:15:46.161 --> 0:15:47.916
<v A>Yeah, just a hard game to play.

0:15:50.025 --> 0:15:55.965
<v A>But Go is harder, so that's right. I guess we should really be upping the limit here in writing simple Go AIs.

0:15:55.965 --> 0:16:17.312
<v B>That's—that's hard to do. Yeah, the thing about chess is you can, you know, even eight moves ahead or six moves ahead, you can exhaust all the possible actions with this pruning in mind. But with Go, I mean, you know, at every board state you have hundreds of actions. Yeah, the branching factor is much higher. Yeah, exactly right. Anyway, so we'll put that

0:16:17.802 --> 0:16:20.654
<v A>in the show notes, so I'd check it out if it sounds.

0:16:20.772 --> 0:16:36.482
<v B>Interesting. Yeah, this looks awesome. I mean, it's as Patrick said, step by step, so there's nothing stopping you from coding this up yourself and reading just by following this tutorial and having some understanding of like Python or C++ or something like.

0:16:36.820 --> 0:16:44.582
<v A>That I know another classic example people do are make the worst possible chess AI. So make an AI that loses as fast as

0:16:45.561 --> 0:18:15.994
<v B>possible? Oh really? Did you see the Worst Overwatch Player article? No. So basically, I mean, it's a little bit of a tangent, but Overwatch had a formula—it's probably some variant of Elo or something—to decide people's rank. Um, but it's a it's a formula; it's not like the top 10 people, top 10 percent of people are Rank One, so on and so forth, right? It's not like that. And so there's the worst—I think the worst rank is Rank One. So I think one is is the lowest. And there's a person who he made it his personal mission to get to Rank One. Um, and people had thought it wasn't even possible. And he basically, you know, he actually like walks through, like in the beginning he's playing with pretty competitive people because I guess originally, like initially he was really good and the people were like pretty mature and nice, and you know, he was losing all these games. Um, and then he got to like the middle, and when he got to about a little worse than average, the people became trolls. So basically, like all the trolls are the people who are like slightly worse than average—that's like where most of the trolls are. And then when you get even worse, it's a lot of bots; it's people who have just written scripts to play the game or not even play and participate in the game so that they can get the loot afterwards. And he had to like lose the bots, which is really hard to do. So he spent a ton of time like trying to force himself to lose, and he did eventually get to Rank One, but it's it's a really cool.

0:18:15.994 --> 0:18:51.533
<v A>Story, but isn't that sort of a—that described that hierarchy? That's I guess I've been on the bad end of that, which is coming into a game not when it first comes out, but you know after a little while and people have been talking about it, and I sort of say, 'I'll check this out.' But of course, you come into it as sort of a worse than average player, hopefully. And yeah, then what happens is you start playing and you're sort of playing with the people like you said who are the trolls who just go from game to game or whatever, and like being the worst. And there may really be a good community above that, but you never really get to experience it because you can easily get turned off of the game by the kind of bad experience at the low level.

0:18:51.904 --> 0:19:12.880
<v B>I mean that's a real problem. It's just hard to know how to solve that, but yeah, that's I mean maybe you know, maybe the way to solve it is to have some kind of hybrid game where you could have a mix of good and bad players, and the bad players don't ruin the game for the good ones, but that's I mean that's you'd have to design the whole.

0:19:13.892 --> 0:19:15.175
<v A>Game around that. Yeah.

0:19:15.614 --> 0:21:06.980
<v B>Interesting. Yeah, but in the meantime, you can tell if you're really in a slump in a game because people start trolling you, becoming really rude when people become really rude to me in Rocket League. I know that I'm on a big losing streak. So my article is actually so a security enthusiast found the kill switch for the WannaCry ransomware, and I'll kind of cover all of this. And I don't have all the details, actually. Patrick, you probably know a lot more than me on this, but WannaCry is this it's some kind of Trojan or virus, but basically it takes over your computer, and then you have to pay, you know, Bitcoin like anonymous money to an anonymous source to get your computer back. And it spreads through some way that I haven't looked into. I'm assuming it's some kind of maybe over email or Facebook or something. And the thing about it is, I guess when the person was testing it, or maybe just as a kill switch for themselves, there's a certain domain name, and it's like it's a nonsensical name www.and then a bunch of characters.com, and they he would send a request to that domain name, a web request, and if it came back with a certain response, then the virus didn't activate. So even though you had the virus on your computer, it wasn't doing anything. If he sends a request to this domain and he doesn't get anything back, then the virus kicks in, like it locks your computer down. It also tries to spread the virus, so on and so forth. And somebody who was looking at the virus

0:21:06.980 --> 0:21:35.204
<v B>you know decompiling the virus executable found this logic, and so he went ahead and registered that domain, which is by itself surprising. Like if you were a hacker, why wouldn't you register this domain already? Right? But I guess maybe that would incriminate you. But this person registered that domain, and he had it return the appropriate result. He built his own web server that did that, and he basically stopped this virus, which is remarkable. Yeah.

0:21:36.014 --> 0:22:02.035
<v A>It's still unclear why the stuff had that kill switch in it, like why it was doing that. There's like a lot of speculation, but yeah, I guess the person who did it originally wasn't sure what would happen because you know code's complicated, but he did it as an experiment and noticed it, sure enough, it stopped the code from working, like it stopped the virus from installing itself, from encrypting the computer and putting up the ransom message.

0:22:02.423 --> 0:22:36.291
<v B>Yeah, yeah, exactly. I mean, the only thing I could think of is you know, it's very hard to sort of test viruses, that would be my guess because even if you're in some kind of virtual machine, you probably have to log in with some kind of credentials, and especially when you get to testing it on other machines. And it probably brought this as a way to keep from accidentally locking themselves out of their own computer, but yeah, I mean, I guess for whatever reason they chose or maybe just forgot and they didn't take it out, and saved a lot of people a huge headache. I wonder how.

0:22:36.645 --> 0:22:41.033
<v A>Many people have attempted to write ransomware and ransom to their own computer. Yeah, I know.

0:22:43.362 --> 0:22:45.400
<v B>Right. My guess is probably not that many.

0:22:45.707 --> 0:22:49.724
<v A>You have to be pretty skilled so you probably know to be really careful. Yeah.

0:22:50.095 --> 0:23:04.962
<v B>Exactly. I mean, I feel like the virtual machine can emulate things so well that there's not really a reason to do it, but I mean it could be the kind of thing where you know, yeah, if you're careless even once, you're totally hosed, or maybe you just pay yourself a Bitcoin. It doesn't matter. Oh.

0:23:04.962 --> 0:23:38.340
<v A>There you go. That's true until that code's not working, right? And then yeah, I don't know. I always wondered it's like do the worms and viruses, are they pretty well tested or not really? Because like if it's not well tested, you have a problem because it sort of gets out, and then people will patch their systems, and you may not accomplish the goal you want because you have unintended consequences or takes down your server that's supposed to be doing whatever. But then if you test it really, really, really well, like do you really care if 10 of people's computer crash instead of doing what you want? Right? Yeah.

0:23:39.353 --> 0:23:59.991
<v B>I mean, it's at the day it doesn't matter. Well, but then it actually gets back to our chess AI example, like the branching factor becomes really important, and so even if one percent of people don't spread the virus, that ends up having a huge impact. So yeah, my guess is probably they're tested pretty well, but I think it's really like I'm

0:23:59.991 --> 0:24:01.037
<v A>Sorry, go ahead. Oh, go.

0:24:01.645 --> 0:24:02.235
<v B>Ahead. I want

0:24:02.235 --> 0:24:16.427
<v A>to say it's sort of different though. As we—well, I get off on a tangent, but it doesn't matter the order of people being infected per se. Like if you don't spread it to me, but Bob spreads it to me, that's just as bad for me. Like I don't care that it came from you or

0:24:16.849 --> 0:24:26.400
<v B>Bob? Yeah, yeah. I guess the question there is then like what is the density of that graph? Like if I don't spread it to you, what are the chances someone else is going to know you or

0:24:26.400 --> 0:24:27.396
<v A>something like that. But

0:24:27.700 --> 0:24:39.680
<v B>Yeah, I mean actually the real thing I'm curious about is who are these people? I think in general it's usually state-sponsored. Like it's government programs of various countries that are doing this. Well, I

0:24:39.680 --> 0:24:54.261
<v A>think Microsoft came out if I recall because it was, you know, it was on Windows and came out and said that this was a result of—I think one of the WikiLeaks or something that revealed the cache of hacker tools that were used. Oh, the NSA thing? Yeah, we actually talked

0:24:54.261 --> 0:24:55.746
<v B>about that like two shows.

0:24:55.760 --> 0:25:06.968
<v A>Yeah, and they found like that apparently whatever this flaw was found in there, and so people like exploited it to make this or at least that was the accusation. I don't know enough and didn't read enough about it to know if that was sort of

0:25:06.968 --> 0:25:23.877
<v B>proved out or accurate? But gotcha. Yeah, I read something—yeah, I read something along those lines. So yeah, I guess I guess that those leaked tools were legit, maybe not from the NSA or whatever, but at least they were. It's definitely they were powerful tools. There's no doubt about that.

0:25:25.244 --> 0:25:26.712
<v A>Time for a book of the

0:25:27.370 --> 0:26:37.114
<v B>Show! Book of the Show. My Book of the Show is very limited time, so definitely jump on this. Let me see how many days are left. There's probably by the time the show publishes there'll be about a week left, so jump on this quickly. It's the humble bundle for for MakeMake Essentials for Maker Fair. So basically it's just a ton of books about building stuff. So there's books all about getting started with 3D printing that I probably should have read before I burn my house down. There's books about, you know, designing a good workspace, how to make 3D models that you can then print. There's all sorts like electrical, you know, like robotics, like build your own robot kind of thing, microcontrollers, Linux, and you can get a ton of books. You can actually get a ton of books for a dollar total. If you pay eight dollars, you get twice as many, and if you pay 15, you get three times as many books. But yeah, definitely check it out. It's an amazing deal. All of these humble book deals are phenomenal.

0:26:37.519 --> 0:26:44.286
<v A>Just don't have problems. Like I guess ebooks have never really clicked with me. I've read a couple, but I get too distracted.

0:26:45.315 --> 0:27:07.354
<v B>Yeah, I uh, yeah, I'm thinking about it. Like my the fiction ebooks. I've definitely read a bunch of as far as like ebook references. Um, yeah, you're right. You know, I have I have a decent amount of ebook references, but uh um I don't read them and read them too much, but maybe it's just I don't read reference books. No, that's fair. That much unless I'm really

0:27:08.333 --> 0:29:07.600
<v A>Stuck? Well, my book is a massive tome of fiction called The Way of Kings by Brandon Sanderson, and this is Book One of the Stormlight Archive, which is if I've previously recommended the Mistborn series. Um, and it turns out I didn't actually know this at first, but The Way of Kings is apparently in the same literary universe. I don't know how you say that, so it's not sort of the books don't at least as far as I know don't really have anything to do with each other, but they exist in sort of the same ecosystem of stuff that Brandon Sanderson calls the Cosmere Universe. So I don't know. There's sort of magic in the books, and the magic isn't the same as that from Mistborn, but it kind of is similar in a way. Um, there's also another book called Elantris that is apparently also set in this sort of Cosmere mythos. And um that, but all that's to say that it's by Brandon Sanderson, who I've recommended several times, and I think he does a really good job of writing this book. It's very long. Um, I actually I don't know how long it is in pages because I listened to it. Um, but um the listening to it, I believe it was oh, and I should have looked it up right before I did this, but I think it's um like 30 hours, I want to say or something like that. So it's definitely lengthy. Oh no, I was completely wrong. It's 45 hours for almost 46 hours. Well, it's like four times the size of a normal book—46 hours. Yeah. Uh, so it's definitely a big book. Let's see if I can figure out how how big the hardcover is. Um, so it's 46 hours, very long, but I really, really enjoyed it. In fact, I have a bunch of other books and I wanted to go get the second book just because I was so into it, but I was like after I've been burned before, after listening to like 45 hours straight, to go into another 45-hour book, you kind of get a little burnt out by the end. And so it's best to sort of 180 pages. Oh yeah, big. Um, but I definitely recommend it if you're into long-form fiction. At least if you do mostly sort of short stuff, maybe this is not.

0:29:07.600 --> 0:29:56.813
<v A>The best first book because it's quite long, but if you like sort of long, I actually like really long-form science fiction and fantasy. Um, I'm in the middle of another very long book by Neil Stephenson, and uh I'm enjoying it, although this one is starting to drag. So I'm not sure maybe I need to go on to a short book kick, but anyways, The Way of Kings, I know I didn't say anything about what it is because I never know how to talk about stuff without spoiling it. Um, so totally makes sense. Check it out. It's a fantasy book. I guess I mentioned there's some magic that's good. I could read like the back page, but you could just do that for yourself on the internet. But if you like Brian's—if you like Brandon Sanderson or you like fantasy and you have probably already checked it out because the book is like five years old, I think at this point. Um, but if you haven't, I give it my recommendation.

0:29:57.218 --> 0:30:17.147
<v B>Very cool, and you can uh listen to that book on Audible, and Audible is also a sponsor of Programming Throwdown. You can go to audibletrial.com/programmingthrowdown and uh you know sign up. You get a month free, you get a free book, and uh if you use that special URL then uh you help out the podcast, and

0:30:17.260 --> 0:30:21.012
<v A>I will say 46 hours seems to be a good value for

0:30:22.024 --> 0:30:47.050
<v B>me for that Audible credit. Fifteen for 46 hours. Yeah, definitely. Um, I'm actually reading a book. I won't spoil it, but um about a third of the way done, and I actually read some books that Patrick had recommended in the past on Audible since I got my account. I read A Zero to One and a couple other books, and I think it's great. I've actually switched over to that. I can kind of rest my eyes when I'm on the shuttle, and uh so

0:30:48.180 --> 0:30:52.700
<v A>Do you go back and do you go back to the old show notes and look at my recommendations? And then I didn't know you

0:30:52.700 --> 0:30:55.032
<v B>were doing this. I feel complimented exactly what I did.

0:30:55.352 --> 0:30:57.259
<v A>Yeah, have I been a good recommender? You have.

0:30:58.060 --> 0:31:11.063
<v B>Well, you know, I've read some of your recommendations already just on ebook, um but yeah, I picked up some of the ones that you recommended that I hadn't already read and got them on Audible. But yeah, in general, I I like your recommendation. I'm not into sci-fi, so

0:31:11.063 --> 0:31:12.025
<v A>I don't usually.

0:31:12.025 --> 0:31:58.769
<v B>Read the fiction books, but yeah, I feel like your recommendations are solid. It's super interesting. We're also on Patreon, so you can go patreon.com/programmingthrowdown. You can give us a shout out, send us a message. You can also set up a donation, like become a Patreon to Program right now. We really appreciate that. At the end of the year, every year we take any money left over after our server costs and everything else, and we give out free T-shirts to people who are subscribers. And yeah, check it out. We also publish a separate RSS feed there that has a bit more bandwidth, so if you're a subscriber, you can use that RSS feed. Yep, time for Tool of the Show. Okay, so my Tool of the Show has a bit of

0:32:00.372 --> 0:32:08.040
<v B>backstory. While I was buying this 3D printer from China, I also noticed China has a bunch of other stuff for sale that is super cheap. You fell

0:32:08.117 --> 0:32:08.860
<v A>down a rabbit hole.

0:32:09.619 --> 0:34:05.139
<v B>Yes, it is a rabbit hole, and I bought a tablet I've been wanting. This for a long time. I've been wanting a gigantic tablet. I wanted a tablet so big that I could read an eight-and-a-half by eleven research paper, you know, at scale. That was the goal, but I want to spend a lot of money. I could get like an iPad Pro, but I think it's like $1200 or something for the big one, or maybe it's like a thousand dollars, but still a lot of money. So, a Chinese drop shipper was shipping a 12-inch Android tablet. It actually runs Android and Windows. What? It dual boots. Yeah, isn't that wild? When it starts up, it has like use the volume up and volume down button to choose whether you want Windows or Android, whichever you're feeling that day. Yeah, and it's amazing, unfreaking believable, and it was only $200. Oh wow, this huge tablet, this beautiful screen. The only catch is it runs a fork of Android, and if you just put stock Android on it, the touch screen doesn't work. I saw that from reading the internet. So, so I have to leave the version of Android on, and it also has Chinese spyware. So it had this thing called Adups that is that I've read on the internet. I haven't verified, but according to the internet, it like logs your keystrokes, like your keyboard touches. So when I found that out, I was super bummed. I thought I had this paperweight, or at least I was going to have to highly regulate my usage. But then I found this app called this program called Deep Loader. You run this on your desktop with an Android device plugged in, and even the factory level services you can turn them off. You can't uninstall them because you don't have root access, but you can disable them.

0:34:05.139 --> 0:35:48.580
<v B>You can disable their connections to the internet. You can turn them off entirely. And so I ran this Deep Loader and I turned off Adups on my tablet. And the other thing I found out is a lot of these lesser-named brands like the Blue Android phones and some of these other Chinese brands which have sold just millions and millions of devices in the U.S. have this spyware on them. So if you have, you know, if you have one of the major ones, like if you have a Motorola or a Samsung, you're fine. But if you bought, you know, either for yourself or for your family, one of these other brands like Blue or Chewy or one of these Chinese brands, then run this Deep Loader. Or even if you did it, run the Deep Loader. And I think all Verizon phones also have some type of logging system. That it doesn't log keystrokes, like it's not that invasive, but you could disable it with this program. So have you been reading research papers on your gigantic tablet? Yeah, it's actually it's really nice. I have an app called Moon Reader. It's kind of expensive. It's like five bucks for a PDF reader, so you know, it seems kind of like a waste, but it's amazing. It lets you annotate on the PDF pretty easily. It'll actually switch to night mode and it'll invert the colors of the PDF, like even the pictures, the colors will be kind of inverted. And yeah, it makes the pictures kind of strange, but for a research paper where you're really just looking at graphs, it's okay. And it makes it much easier on their eyes and everything. So yeah, it's it's really nice.

0:35:49.720 --> 0:37:07.868
<v A>My Tool of the Show predictably is an iPhone app. I don't actually think—well, I should say an iOS app because I know it's on the iPad as well, but it didn't look like it was available at least not yet for Android devices. And this is Card Thief. This is by the same person/company that created Card Crawl, which I think I've recommended before. If not, it's also a cool game. Check out. I think it's a couple dollars, and Card Thief is a strategic card game. Oh no, it does say it's on Android. Okay, cool. Yep, it's on Android. All right, cool. I feel bad. I didn't want to leave those people out. Anyway, so this is a strategic card game where you are sort of a thief sneaking around buildings trying to avoid lights and guards and trying to get to the exit all by sort of managing your stats so that you can get good scores, pick of loot, all that kind of stuff. And I thought it's just it's sort of fun to see a card game that I have several implementations of real card games that I've played, but it's interesting to see people playing simulating playing a real card game, but in a way where it'd be like this card game would never exist in real life because it'd be too tedious or you know too much bookkeeping that no one would ever really want to play. It's just sort of an interesting genre. And anyways, yeah, check out Card

0:37:08.121 --> 0:37:08.982
<v B>Thief. There's other

0:37:09.420 --> 0:37:37.320
<v A>games as well that I play where I didn't like the idea of it in a real board game where I'd played things similar and just like sort of the tediousness of it made it not interesting to me, but then playing on the iPad you can sort of sit down and it like shuffles for you. It keeps track of all of your statistics and make sure you don't sort of break the rules by accident. So some games that are really fun but sometimes are sort of easy to mess up or make great iPad, or I mean just great app implementations.

0:37:37.652 --> 0:37:43.896
<v B>Yeah, totally. Yeah, especially like Agricola and these games that have just so much going on. So much more fun on the iPad, but

0:37:43.964 --> 0:37:54.274
<v A>It's so fun to move all those bits of wood around in Agricola. I don't know what you're talking about. The app doesn't do it for me. I don't know why. It's just like I love moving the little bits around, but it does make it hard to get to the table.

0:37:54.949 --> 0:38:01.598
<v B>I actually think I think yeah if I just had an app that where I could take a picture of the board at the end

0:38:01.598 --> 0:38:02.577
<v A>and it would

0:38:02.577 --> 0:38:04.585
<v B>score. That's all I really need.

0:38:04.585 --> 0:38:12.800
<v A>Enough. Fair enough. All right. Cool. Well, time to talk about code reviews. This is going to be an exciting and most thrilling topic ever.

0:38:12.800 --> 0:39:02.044
<v B>No, this is I think the interesting thing about this is, you know, if we talk about let's say Python, you're going to learn it in college or maybe even in high school, and you're going to go into your first software engineer job probably already knowing Python. But this is something that like it's a chicken and an egg. Like you can't really know it until you've done it, or until you know someone kind of covers the whole process. And a lot of colleges, you know, we had a we had a college course called Software Architecture, and it was, you know, it really should have covered things like code reviews, but it didn't. So we actually didn't really get a taste for, you know, code reviews and merging and releasing code and these things until we got into industry, and so hopefully Patrick and I are going to change that.

0:39:02.466 --> 0:40:54.837
<v A>Right now? Yeah. I guess I knew it existed, but you know anyways, I didn't really know what it was. And it's actually surprising to me. A lot of people, kind of a lot of companies don't have good code review systems or aren't even practicing code review, which is kind of crazy to me. So I felt like this isn't a good opportunity to talk about. Yeah, there's a bunch of reasons why you wouldn't want to do it, but there's a whole lot more reasons why you would want to do it. And I personally like at this point feel that if I don't get code review, I feel like I'm not done yet. Like I feel like you're not done until you write at least some amount of unit tests and get code review. Yep, totally. Anyways, so I already was talking about implying why you would do code review. So one of them is get someone else to look at your code. I mean, there's a lot of times where I've written things that were sort of bad assumptions and even kind of past unit tests because I also wrote my unit test from the sort of same point of view, and someone else will point out like, 'What in the world are you doing here?' And it's really important to get another pair of eyes for several reasons. One, you just—you can miss stuff. Two, you know, as an engineer, I feel like it's—and I was describing this to someone—is like I feel like good engineers are very, very open about what they do. They don't try to keep secrets. They don't try to keep hidden kind of like methods. They are very open, very sharing. And part of that is that way and this sounds bad, but everyone can share in the blame, which is like when something goes wrong, it's not just the person who wrote the code's fault; it's the process's fault. It's the people who reviewed the code. And that sounds like you're trying to look for ways to blame other people, but it's not. It's about—it really some of the stuff we do is almost too important for just one person to be doing. And so really you need to have more sets of eyes on that. And code review is a is a great way to do that and have an understanding about the process of going from writing code and getting it deployed and shipped.

0:40:55.444 --> 0:41:07.510
<v B>And so yeah, and I mean also people want to do different things. I mean if you keep this, you know, chunk of code to yourself, then you have to be its babysitter for as long as you work at that company.

0:41:07.510 --> 0:41:09.974
<v A>Well, some people see that as an advantage, but I yeah.

0:41:10.615 --> 0:41:11.920
<v B>We're talking about good. Good.

0:41:12.066 --> 0:41:17.297
<v A>Yeah, I don't know. I've been hard-pressed to find a situation where that was truly good. So yeah, I mean,

0:41:17.297 --> 0:41:44.804
<v B>if if uh yeah, I mean there's people who say, 'Oh, you know, it's job security if I'm the only person who knows the code base.' Um it really doesn't work that way. Like it's pretty easy to rewrite stuff from scratch. It might not be easy, you know, for a person to do it, but for a company it's pretty easy. And uh it's much better to, as Patrick said, yeah, be open and write the best possible code rather than try and optimize for job security. Yeah.

0:41:44.939 --> 0:43:44.560
<v A>And and along exactly the same lines is you really want to be able to, you know, it's the, you know, bus insurance. It's like if someone on your team walks out and on the way home and gets hit by a bus, you want to make sure you know what they're doing. And one of the good ways to do that is through code review because other people on the team will be seeing the code that that person is writing and, you know, understanding what they're doing. Uh also sort of prevents people from just kind of not ever paying attention to what you do. Um and so make sure that people sort of have visibility into the work you're doing, you know, good or bad, but hopefully the good work that you're doing, and so they can kind of like, you know, help recommend you when performance reviews come around or whatever. Now it makes sense there are some definite caveats, so things where code review can go wrong. Um So one of them is you can get people on your team who for one reason or another, uh, you know, like to slow things down or they want to land something, you know, they want to check in some code before you get it in, and so they start to try to be kind of a roadblock. And one of the symptoms of this is people who get really, really nitpicky about very, very small things, like, you know, the grammatical structure of your comments or, 'You know, in code review is not the time to decide whether your company is going to use or your team is going to use tabs or spaces.' I mean, those code reviews do not work well for those things. Um Those should be decided—I guess we call it side channel or outside of the code review system. Um Code review is also not a good time for like architectural work at like a big level that should also be communicated in an external way when you go time to have your review, your code review people should already know sort of like the context of your code. Um Now there may still be needs to critique some of the architectural decisions at like a tactical level on your code, but not, you know, people should know why you sat down to write that code for the most part, right? Totally. Um The other thing is, you know, the team has to be diligent about code reviews equally because if some people are really into it and some people aren't.

0:43:44.560 --> 0:44:16.122
<v A>You can end up with a problem of like the very eager person has code out for review but nobody else is eager about it, and so they don't do the reviews in a timely manner. And then that becomes a problem for various reasons. And it's on the same token like on some teams I've been on, it's sort of one or two people are very passionate about sort of code cleanliness and code health, and they end up doing sort of the vast majority of the code reviews or have to be a part of all the code reviews. And there's a bunch of other people who don't do it. Um And I find that to not be good that never ends up working well in the long term.

0:44:16.493 --> 0:44:49.315
<v B>Yeah, that makes sense. I think uh yeah, to have a good code review kind of process, you have to have a good auto formatter because yeah, I've seen so many code reviews devolve into like, 'Oh, add a space here,' 'Put a comma here.' And and you know that ends up wasting like a lot of human time when you could have just written a program and some regexes and and you know or used Clang Format or something. Um So yeah, if you don't have an auto formatter, then then uh that should be your first priority.

0:44:49.315 --> 0:44:50.479
<v A>At least a linter, yeah.

0:44:50.850 --> 0:45:27.030
<v B>That's true. Or at least a linter that won't let you even start the code review without passing all the style checks, and then, yeah, as Patrick said, the code review is really—you know, if you think that the whole architecture needs to be overhauled, that's a separate task. The code review is really, you know, is there a bug that this person didn't see? Or are they did they introduce a bad architecture that's going to sort of spiral out of control? That—you know, just it materialized in that code review, but it's not the place to say, 'Oh, you know, I realized maybe we shouldn't have pointers anymore,' like.

0:45:27.047 --> 0:45:30.962
<v A>That's not the thing you deal with in a code review, definitely.

0:45:31.334 --> 0:46:13.656
<v B>Yeah. So, you know, there are many different ways to do code reviews. At the end of the day, they all involve kind of soliciting feedback and receiving feedback. So it's really parallel sort of the way you communicate. I mean, you could just a simple way is to just zip up your code, email it to someone, and they'll email you back some feedback. You could also go in person, like you could have [someone] over to your desk and just kind of—and I've actually done this even at companies where we had good tools. If I see that there's some kind of back and forth and it's not really going anywhere, then I'll just go to that person and I'll say, 'Hey, can you just come to my desk?' And we'll just in person, we'll step through this.' Yeah. I do.

0:46:14.027 --> 0:46:28.405
<v A>That same reason. Like if I feel not—if something's gonna be contentious per se, but like if I think something is gonna potentially cause a bunch of questions, I'll bring people over in advance and sort of you know walk them through and solicit the suggestions in person. Yep.

0:46:28.759 --> 0:48:24.880
<v B>Yeah, totally. In person is actually really, really useful. Just this is kind of a side note, but if ever, you know, an email thread let's say goes back and forth between the same two people, let's say more than twice, then you need to schedule a meeting. And the same is true for code reviews. Like if you say, 'You know, oh, I think it should be .h,' and the person says, 'No, it should be .hpp,' and you say, 'Oh well, here's a link to Stack Overflow,' or they say it should be .h, like at that point it needs to be done in person because those just don't really end well. And then last, they have a ton of different web tools. They're super powerful. This is the recommended way to do code reviews. I don't have a particular preference. Fabricator is a good one. Garrett is another one. If you're using GitHub—the private GitHub—or if you're doing an open-source project or using GitLab, or Bitbucket, or any of these tools, you know they have often a code review tool built into the whatever source control tool you're using. So that's that's good as well. At a high level, the web tools break down into two categories. One is it's basically just an easy—a better way to do the email version, like you would send someone a link, they could click on the link, they could see sort of a graphical view of your code, they can make comments right there, but it's basically the same as the email. The other way, you know, the GitHub ways, we actually make a merge request, and this sort of combines the code review with the kind of merge itself, all kind of in one step, so someone's approving, you know, the quality of the code and also the fact that this code belongs in this codebase right now. And I think both are equally good.

0:48:24.880 --> 0:48:31.964
<v B>So I think, you know, there's a hundred ways to skin the cat, but the important thing is to do the code reviews. So I will.

0:48:32.385 --> 0:49:09.600
<v A>Say that having some sort of web tool is enormously helpful. I've been in a couple teams—mostly a while ago. I think there's become better support for it recently, but where in-person code review used to be the way to do it and everyone was expected to read the code in advance and sort of come with a set of questions or comments, and just like the sheer amount of bookkeeping and lack of desire to go through the code in advance really makes it a drag. Where I really felt the quality of code reviews was much poorer with that approach. Now, as Jason said, using in-person—yeah, using in-person to supplement—yeah, definitely, but as like the only way? Yeah, I'm not so sure.

0:49:09.600 --> 0:49:53.132
<v B>Yeah, yeah, totally. I think you know 90% of code reviews should be done either via email or with one of these web tools, and the web tools are far faster. Most of them are integrated with your source control, so some of them you literally just type in a command and boom, the code review is done. Like type in a command with a few people's names and it does all the work for you. So, you know, part of this is if you're running your own company or running your own team, you have to kind of set some guidelines for code reviews. You know, one kind of nice guideline is this idea that everything has to be reviewed. I think this.

0:49:54.938 --> 0:50:23.659
<v B>Is this in general a good strategy? I mean, almost everywhere I think literally everywhere I've worked at has had this strategy, you know, that you can't just start making changes. Now you can do like an emergency change if let's say it's 2 a.m. and you're paged and you have to fix something right now, but even then if you do one of these sort of emergency commits that's not reviewed, it should send some kind of email so that someone can review it later. I have been.

0:50:23.659 --> 0:50:43.842
<v A>At places which didn't have this rule, and I think the problem is making lots of little changes. There's sort of a tendency for people to make a bunch of little changes which they claim are not contentious or don't need review, but then over time they build up into something that really ought to have been reviewed and sort of flies under the radar because no change was.

0:50:44.297 --> 0:51:52.557
<v B>Too big. Yeah, that makes sense. Yeah. I think also in addition to just code reviews, it's good to have these architectural reviews and things like that. Those are usually done in person, like if you want to propose kind of a new kind of high-level feature and things like that. Some places have this idea called readability, and so this is where you know you get somebody on your team or someone in your department who's really good at Python, let's say, and he's on the code review but he's not really there to see if your code is doing what you are tasked to do. He's just there to look at the syntax and look at if you're using the language in the right way and things like that. So there's some companies who have that. Another thing is, you know, some policy—some companies say, 'You know, have one person approve.' Some say, 'Have two people approve.' I generally think one person is fine. I don't really see why I have to get two people to approve it, but maybe it depends if some code is really mission-critical, then it's good to have, you know, as you add more pairs of eyes, you're going to catch more and more bugs. Well.

0:51:52.877 --> 0:52:14.545
<v A>I've seen requiring two people in a way like a kind of more like a more senior person working with a more junior person. The more junior person may have more context on that specific thing, but you may want another sort of senior person to approve the change overall, but you still want the feedback from the more junior person because they have some contextual awareness, or vice versa. Oh yeah, that makes

0:52:15.726 --> 0:52:16.384
<v B>sense. That makes

0:52:16.899 --> 0:52:21.899
<v A>sense. So basically some people have more power than other people or a similar way of saying that.

0:52:24.096 --> 0:53:50.580
<v B>Yeah, I think another kind of rule is: you try to keep the code reviews relatively small. So if for example—one thing that's really important, a lot of people know about—is you can often when you're using let's say Git, you can do `git add -p`, and it will let you add part of your changes to a commit. So let's say for example I implemented a new way to get the index of some item, but then I also took this other part of the code and made it 10 times faster because I had to—to support the other thing. Well, those are really two different things; they might be tied together, but functionally they're two different functions. You could have the speed up without having the first thing, and so that's where something like a `git add -p` or the equivalent whatever source control you're using, like in Mercurial—it's `hg split`—is super useful because you could take part of it. You can make that a code review, like, 'Hey Bob, can you review this speed up? I ran all the tests; they all give the same answer, but it's way faster. Can you look at this? Are there any mistakes?' And then and then you could take the other half and you could give that to someone else or give it to Bob too, but at least as a separate code review. That makes it—makes it way better to read and makes it way more likely you'll get your reviews accepted. Yeah.

0:53:51.323 --> 0:54:21.280
<v A>There's nothing worse than having someone work for like a month or however long, like a long period of time, get a giant code review and then you have some like sort of naming, you know, questions or clarifications or style change, and then the person, like the size of the code that they have to go fix when that comment comes in is just preponderous. On top of it, it's just really daunting to sit down and be like, 'I have to go through many thousands lines of code for this review.' It makes it very hard to sit down and do the

0:54:21.280 --> 0:55:38.715
<v B>review. Yeah, exactly. Another thing to mention is I think we've talked about this before, but if you find a bug in a piece of code, there's extremely high chance there's another bug in that same code. It's just—I don't think there's a name for this; it's some phenomena—but basically, you know, it's sort of like if you have the wrong mindset that created a bug somewhere, you created a lot of bugs in that place almost for sure. And so by having the code reviews be kind of atomic, you know, if one code review is having some problems, you can really focus on that and you're not blocking all these other code reviews. So yeah, that's code reviews in a nutshell. It sounds very kind of Dilbert desk right? It sounds like TPS reports from Office Space or whatever, but it's actually—it's super important. Look at it as sort of a way of communicating, a way of sort of telling people what you're doing, getting feedback, giving feedback. I've definitely seen, especially now that they keep coming out with new versions of C++, I definitely see things in the code that I didn't even know were possible, and so it's made me a better programmer, and it's highly recommended. Yeah. I also want to say thank

0:55:39.694 --> 0:55:55.962
<v A>you to all of our listeners and all the people who have been sending us feedback, doing reviews using our Audible trial or donating on Patreon. We've been getting an enormous amount of support, and we just want to say thank you to all of our listeners. Yeah, definitely.

0:55:55.962 --> 0:56:10.609
<v B>Thank you, and keep writing in. We try to answer every email, and I think we're doing a pretty good job. We're mostly—we had a bit of a backlog; we're mostly caught up now. So thank you for all your feedback, and we'll see you next month.

0:56:16.549 --> 0:56:39.040
<v B>the intro music is axo by binar pilot programming throwdown is distributed under a creative commons attribution share alike 2.0 license you're free to share copy distribute transmit the work to remix adapt the work but you must provide attribution uh to uh patrick and i and uh share alike and kind

