WEBVTT

0:00:15.758 --> 0:00:20.179
<v A>Programming Throwdown Episode 76: Code Documentation. Take it away, Patrick! I'm so

0:00:21.715 --> 0:00:31.469
<v B>excited to be doing another full episode—again. Or I guess they're all full episodes, but a non-interview episode. I'm trying to get a bunch of topics off the chest that's

0:00:32.228 --> 0:00:55.077
<v A>true. Yeah, we should. There's definitely, you know, some interviews that are kind of in the pipeline. There's nothing immediate, but yeah, we definitely are really getting caught up on, you know, a lot of our like focused episodes—I guess so to speak—are non-interview episodes. And yeah, if people have suggestions, now's a good time to hit us up because you probably won't have an interview next month either, so but

0:00:55.937 --> 0:01:09.032
<v B>also, I feel like people might groan a little and be like, 'Code Documentation? Really? You guys are scraping the bottom of the barrel.' But Jason suggested this, and I thought about—I actually think like, I don't know. I'm kind of excited to talk. We'll see how it turns out, but yeah.

0:01:09.437 --> 0:01:47.693
<v A>I mean, this is one of the most important things because other things, you know, if we talk about specific languages—maybe you're never going to use that language ever—but this affects everybody. And hopefully, yeah, and I think it affects—it affects everyone who's programming pretty profoundly, a lot more than you think. It's one of these sort of, um, like you don't really imagine other people reading your code. Like even just thinking about it, it's kind of weird just thinking about somebody else just like trying to figure out what your code is doing. But that happens all the time. And so even though we might not think about it, um, and so documentation—I feel like we have really a lot of good things to say about it.

0:01:48.975 --> 0:03:03.293
<v B>So, the first thing I want to talk about is system design questions on an interview. And I'll do a little like what that means and why. And then I'll let you go first, Jason. But, um, to me, if you're doing an interview, and lots of people, you know, listen are either looking to get a job in computer programming or graduating college and looking to get a job, or even just—I think I actually think it's good to interview every so often just so you sort of get practice with it. Even though I don't always do it as much as I as much as I should. And it is a lot of work, but it is one of those things I think being prepared to interview is is always sort of good. And a system design question is instead of the expectation at least at many tech companies if you interview for a programming job that you have to do coding on the whiteboard—the infamous whiteboard—or even just on a computer or something, system design is saying, 'You know, hey, let's move this up a level from writing a program that you can do in 30-45 minutes to talking about how you would design something,' and still maybe in 30-45 minutes. Sometimes some companies will do it a little bit longer for this question, but it's sort of a higher-level question with more moving parts and often doesn't involve writing code.' Yep, totally.

0:03:04.626 --> 0:04:19.703
<v A>Makes sense. So we're talking about this a little bit before the show, but, um, you know, I do machine learning, as probably a lot of people know if you watched or listened to our Machine Learning episodes. But, um, we actually have a separate system design that's focused on Machine Learning that deals a lot more with statistics, like how do you sort of design it to be a little bit robust? How do you collect the right statistics things like that? And, um, yeah, as Patrick said, you don't—you're not really expected to write a lot of code. You might whiteboard some diagrams and things like that, but it's really about how you tackle things at a high level. And what most of the time we're looking for, like what I'm looking for is, and it depends on the levels of experience too, but I'm looking for people who've kind of made kind of mistakes in the past and are already kind of preemptively, you know, trying to design the system with those in mind. Or, you know, people who start off trying to figure out the limitations and the scope of the problem and things like that and sort of making sure they don't over-design or under-design, um, and things like that. We'll talk about that a little bit more detail, so it's probably pretty similar to a system design interview just with a different topic, but

0:04:21.120 --> 0:06:18.919
<v B>Yeah, yeah. So maybe an example for me, um, you know, working at a company that has—or I guess any tech company that has a large internet presence, you know, you would expect to get a question has something to do with distributed systems. Um, so an example of that might be, you know, if you take an e-commerce site or whatever. I hate naming names because I don't actually, you know, particularly want to—I don't know anything about the details. But if you just say it as an example like Amazon or something. So, um, Amazon has, you know, people are familiar with kind of the UI, so oh, it has a product page. And on a product page, you know, you go there and it might want to say how many people bought this product in the last day. Um, they don't do that, but maybe they want to—maybe they want to add a feature when you visit a web webpage for um this particular kind of uh salt shaker. Uh, this salt shaker was sold 10,000 times yesterday. Uh, and they think that'll, you know, give you what did they call that? Uh, the social benefit of like seeing that other people are making this decision as well. And so they'll ask you how do you design that? And so, you—they're really it's open-ended. There's lots of ways you can take this. So the first thing is to, you know, make sure you kind of understand the kinds of things they're interested in hearing from you. Uh, if you're a web designer, maybe they're looking for, you know, how you would figure out where on the page to put it or how to style it. Um, if you, you know, are interviewing for an infrastructure job, you might start thinking about, 'Okay, this is Amazon. They get a lot of people coming to the website.' Do when it says yesterday 10,000 people bought that? Is that yesterday in the trailing 24 hours? And then how fresh does that need to be? Or is it in a bucketed the last, you know, sort of midnight to midnight day? Um and how do we compute that? How do you collect it? How would you produce it? How where would you store it? So Amazon

0:06:18.919 --> 0:07:26.104
<v B>has—I don't know how many products, millions of products, and all of them need this value. Is it something you would compute when a person loads up the web page or is it something that you would pre-compute, you know, on sort of a rolling basis and store in a in a database somewhere? Um And if that database does—that database need to be sharded? Um What would the query look like on—sorry, I'm actually not giving answers. They're just giving more questions. But um, you know, these are the kind of directions you would start trying to take it in. And the person, you know, depending on the interview, the person may give you more details or they may not. They may say, 'You know, oh yeah, actually what we have is, you know, we have a in a SQL database and we'd like you to write a SQL query to figure it out.' Okay, well, that's not really I guess system design, so that's bad bad example. Um but they might say, 'Okay, yeah, so it turns out Amazon has a billion products. How would you compute this value for a billion products?' You know, and it should be computed instantaneously because we don't want to compute it for not popular products.' Um But yeah, exactly that's a

0:07:26.340 --> 0:08:28.960
<v A>big that's a big part of it is if someone says oh you know i want to like compute it for every product well you say well look there's so much churn we have our inventory is you know a gazillion products a lot of which are maybe even discontinued or they're technically there but no one looks at them and that you know we don't even have enough resources and even if we did it'd be a huge waste and then you have to see like okay is the candidate going to adapt to that and say you know oh that's a good point i didn't think about that uh let's keep some kind of cash so and and you know have a right through cash or is that the term anyways have some kind of cash where you know when you hit the product the first time of that day you have to do some computation and maybe you put a filler number there or empty or something but you're computing it and so then when the next person goes etc etc if someone just says well that's the thing i thought of and i'm sticking to it even though it's wrong that that's that's probably not a good answer so one thing in general is to be very adaptable especially in the system design interview

0:08:28.960 --> 0:08:47.070
<v B>yeah i think that's right i mean i think it's okay to not know something but as jason pointed out to just like stick to your guns and if someone says you know oh i need it computed in the rolling 24 average hour the rolling 24 hour window uh and i you know you know computed

0:08:48.640 --> 0:09:11.877
<v B>to the last second or something you can't be like well that seems dumb uh i think we should just compute it each night at midnight we'll run a giant batch job and compute it for everything uh that would not be a good yeah i mean i have seen people try to do that or try to force it into their comfort zone um but in reality you really want to make sure you're answering the question the person's asking yeah

0:09:12.872 --> 0:09:24.077
<v A>That's it. That's the thing that's true in general, but especially for design interviews: is the interviewer has a certain path, a journey if you will, that they want to take you on.

0:09:26.018 --> 0:10:23.747
<v A>And if you deviate from that journey, you know, it can really impact your ability to kind of pass the interview. Right? So, if someone says, 'Oh, I've done this before. I've been on the receiving end of this where someone really wanted me to use like a distributed processing system, like MapReduce,' and they said, 'Well, you know, you have to sort these numbers.' And then I was like, 'Oh, you can get a machine now. They have machines with two terabytes of RAM or whatever it was at the time.' I was like, so you could do it? You could just hold on one machine?' And he's like, 'What if it only had a gig of RAM?' And I was like, 'Okay, well, you could have files and then you could still do it on one machine.' And what I—you know, the reality is the person wanted me to go into distributed computation. Right? At some point, I figured it out, but but you know, try to read the cues from the interviewer because they're going to want to sort of steer it in a certain direction where they're going to have a lot of follow-up questions and things like.

0:10:25.131 --> 0:11:57.606
<v B>That, but the one thing that I, you know, for I guess I don't know at least the background I came from—not working a lot with sort of databases and internet services—is the whole comfortableness with the aspects of database that aren't what I would have traditionally considered, like writing SQL queries. I mean, writing SQL queries are important, and I've espoused their value in everyday programming, but I mean, I think that also just understanding the kinds of trade-offs that at a big tech company—or I don't keep, I keep saying tech company, I guess a big cloud computer company or internet company, I don't know people who have a lot of large web presence. There normally isn't only one kind of database; there are actually many kinds of databases. And this is something that I didn't realize and is important to a lot of distributed processing questions. So, as Jason mentioned, like MapReduce, distributed computation—well, if you're going to run distributed computation inevitably, you want to store it. Um, and so how to have data that can be accessed by big MapReduce processes and stored from large MapReduce processes? Things for streaming data, things that need to be strongly consistent versus eventually consistent? What is eventually consistent even mean? You know, how do you—you know, like load balance queries? What parts of the system should be stateful versus stateless? Um, yeah. So.

0:11:57.994 --> 0:13:12.599
<v A>I guess like so, if you want to prepare for one of these interviews, one big thing is is, you know, look at what the company does, right? Because it's almost certainly going to revolve around that. Think about like what are the biggest technical challenges at Company X before you interview. Like if you're interviewing at—I'm just making stuff up, like companies up—but if you're interviewing at Google, you know, to work on their search algorithm, then yeah, you're probably going to deal with handling a lot of data and looking for things in the data and things like that. If you interview at maybe like Tesla to design, you know, a sensor on a car or something, it's gonna be a very different system design. And so most people are going to ask questions that directly relate—I know when I do the ML design interviews, one of the questions is literally, 'You know, here's a piece of our company; how would you start it over if we had to start over from scratch?' And that's—that's basically going to be the essence of almost any system. That there's definitely some like generic system design questions, but even then they're going to revolve around whatever technology or whatever problems, you know, that company is solving. Yeah.

0:13:13.223 --> 0:14:48.060
<v B>That's really good advice. And if I had to give—I don't know, unlike other things that it's something you can just go to a programming competition website and do some example problems—this one's a little different. I think it involves more reading, thinking. Like Jason pointed out, a great starting point is what the company does, but I mean, I think for me the big thing that probably helps in a broad stroke fashion is understanding the kinds of databases currently used and what the differences are. And not like the difference between MySQL and PostgreSQL—like those are probably two kind; they're the same kind of database; they're just two implementations of a similar kind. Um, but what's the difference between like Cassandra, which is eventually consistent, and MySQL? And why would you use one over the other? So that's like one area of research. Also how data is indexed. So Jason mentioned like Google Search. So understanding what a reverse index is and how would you do web crawling? When you do web crawling, how would you store the data in a way that's useful for doing search? Um, how do you do string matching on—you know, someone enters the starts entering a word into Google Search and it tries to guess what you're going to search? Um, and then how does it match that when you misspell something? Like how would that work? How would you do that for very large data sets and do it really fast? Um, those kind of general topics I think cover—I don't know, I want to say cover everything or most, but I don't know of a great set of recommendations that would cover more.

0:14:48.651 --> 0:15:54.666
<v A>Yeah. I mean, in general, you know, almost every company, you know, has—I guess it depends on. Yeah, I would say almost every company has some kind of front end, like maybe you're plugging into some existing system, like you're writing a plug-in for Salesforce, and so you're—you know, you're writing Salesforce, you know, you're writing some schema that's going to be rendered in Salesforce, right? Or some other app. Maybe you're building your own app, like you know mobile app, maybe it's a website, maybe it's all of those things, right? And so you—it's good to know like that company what is their interface, their human interface, right? And and then think about all the way on the other side, what sort of information do they need to store? And then how can you sort of connect those two pieces? Like it's a good way to think about it. So it's a sort of—and as kind of whether you're a top-down or bottom-up kind of thinking person, you can approach it from either end. But yeah, just think you have these that's the two ends of the universe and so you have to design kind of everything in.

0:15:57.484 --> 0:17:03.550
<v A>Between. Right. Yep. Um, yeah. So ML system design is pretty similar. I mean, we'll ask things like, you know, for example, Amazon has the related products. So when you go to a product, it says, 'Oh, you know, maybe customers also viewed this or related to this item.' You know, how would you sort of design that efficiently? Or if someone goes to the home page and you get some recommendations quickly, but Amazon has a catalog of, you know, a zillion items. So how can you choose the three most relevant items, you know, in a quick fashion? And things like that. So it's—it's kind of similar. It just has a bit more of a statistics, like maybe like a stochastic bent to it in a sense that like, you know, if you go to Google and you type 'cat,' you definitely need to see a cat, right? And maybe out of the Wikipedia page for cat—I don't actually know what comes up first—but but in this case, you know, you could be wrong some portion of the time if you don't recommend the best thing. You know, Amazon's not going to crash and burn, but just on average, you want to be doing better and better. And so it's a little bit different for that reason, but actually there's a lot of.

0:17:04.849 --> 0:17:15.970
<v B>Similarities too. Interestingly, 'cat' gives me the stock ticker on Yahoo Finance for Caterpillar Company, but at the knowledge graph card on the right for cat animal. Oh, okay. And then

0:17:16.814 --> 0:17:19.227
<v A>has a link to Wikipedia or something. Yes. Yeah.

0:17:21.606 --> 0:17:22.973
<v B>Second result is Wikipedia. Oh, there.

0:17:23.429 --> 0:17:28.508
<v A>You go cool. So on to news unless you have anything else? No? You were dying to?

0:17:28.540 --> 0:17:32.457
<v B>Know what my now I'm gonna do dog. Hang on. No, I'm just kidding.

0:17:32.457 --> 0:17:39.578
<v A>Are they are they equal? Are Google employees, engineers, cat people or dog people? Let's find out. I'm just

0:17:41.063 --> 0:17:42.075
<v B>Let's move on.

0:17:42.075 --> 0:19:41.179
<v A>All right. So my first news story is kind of related. It's how to crush an interview. This is really good advice if you ever plan on interviewing again, which hopefully is a lot of people unless you're retired. You should definitely check out this video. The thing is, in our case, a lot of our interviews that we give or that we attend are very technical, right? People want to hire people, and people want to hire us to do XYZ, and it's very hard to know the person's competency over the phone. So, a lot of this advice—he even starts off by saying if you're at the on-site interview, they have your resume; they already want to hire you. This is how to make sure they like you. And that's, you know, at least in tech, that's not true. There are a lot of people who we don't know if we want to hire them when they come on site, but still, a lot of the advice is really relevant just to kind of summarize it quickly. I'll add my own flavor here a little bit because even though I watched it today, I was kind of busy; I wasn't giving it full attention. But you know, definitely be positive, be energetic, be open to communication. Also, he mentioned you have a few stories, which I thought was profoundly useful. So, he said beforehand come up with a few life stories that are relevant to whatever job you want. I mean, even if it's not specific to a specific company, but let's say you want to be a banker. Well, maybe you ran—I think the example he gives is you ran a lemonade stand and you collected money from people when you were a child and stuff like that. And maybe even—and he said even have some negative things, like maybe as part of that lemonade stand

0:19:41.179 --> 0:20:29.256
<v A>you couldn't really manage the stand very well, and when people were working other than you, they didn't know what was going on, and the stand collapsed or something, right? But he's like you kind of have that good narrative, and you know, have kind of good stories that revolve around why it's almost like you're destined to be doing this type of job. I'm kind of paraphrasing here. Definitely check out the video. That was one of the tips. But yeah, I thought it was really interesting. It's stuff that I've always believed but couldn't really articulate it this well and turn it into a very concise set of points. And yeah, I definitely would check it out if you're ever going to interview.

0:20:31.787 --> 0:20:35.230
<v B>Getting off of interviewing from the first large—well, did you look

0:20:35.702 --> 0:20:36.520
<v A>up Dog yet?

0:20:36.934 --> 0:20:38.875
<v B>What's Dog? No, I didn't.

0:20:40.832 --> 0:22:36.240
<v B>Here, I'll do right now. Okay, fascinating podcasting—avoid else return early. This was circulating earlier today actually, but it kicked off something in my mind, so I thought it was good to talk about now. Is this an article, a blog, about how from a coding style that a lot of people do this notion of only having one return function or one return statement at sort of the bottom of the function and having big if-else statements for handling everything and then returning at the bottom? And they were saying you know that they used to do this, but they basically have ditched it. And now what they do instead is, you know, if they check something and there's a problem, they'll just return early. And if they go down somewhere else and it makes sense to return, they'll return in the middle, and then you just return wherever it makes sense instead of sort of having these awkward if what they were sort of saying is awkward if-else. And I read a lot of commentary on Reddit and Hacker News about this. People—a lot of other people were saying you know that they also had been taught this, and then I was realizing, you know, I was taught this as well, like that you really want to only have a return statement at the bottom that this leads to the most readable code, that early return statements are problems. And I actually thought about it for a while and tried to figure out what was going on here. And there were some comments to this effect, and what I realized is that I think if you're doing a sort of language like C and doing memory allocations and you return early, or if you're doing multi-threaded programming and you have a lock and you have many return statements, you need to make sure memory doesn't leak. You need to make sure your deallocations are done, your destructions are done, or that your locks are unlocked. And if you return early auditing the code and saying that I know every code path frees its whatever resources it's acquired—that

0:22:36.240 --> 0:23:32.120
<v B>is tougher to do with multiple return statements. So, I think that it has more to do with that. But then realizing C++ with you know RAII (Resource Acquisition Is Initialization) in other languages having sort of scoped locks and these kinds of things make a lot of this sort of go way that as you return that the instances and the variables in this locking you do, you have more constructs which allow you to do these returns from various places safer. And I think that for some reason that it just sort of never caught up that there's still this weird lingering paradigm being taught in school or whatever, I guess, that you should have this return statement at the bottom and that it's somehow more readable when in reality it was probably more readable given if you have to audit for this other stuff. But now that you don't have to, it doesn't. So there wasn't a lot of rebuttal.

0:23:32.991 --> 0:23:38.509
<v A>Saying oh no. So yeah, I think it's like anytime you can avoid having

0:23:40.973 --> 0:23:46.491
<v A>like what's it called? Like having nested brackets, it's always a win, right? Yeah, but

0:23:47.689 --> 0:24:17.929
<v B>I was thinking just the other day though. Like I was in a conundrum like this, like oh man, I have an awkward set of returns early here. I really need to refactor this to get all the returns down to the bottom. And then thinking about it today, like yeah, I'm actually not sure that I do find that code with more nested brackets more readable. In fact, sometimes it's difficult to know if you've kind of elzed your way out of something for a long time, like following tracing that logic through the code is not easier than just doing it and returning.

0:24:19.178 --> 0:25:23.240
<v A>It, yeah. I mean my background is very different, right? Obviously, like I haven't done embedded things other than now I have this robot project, but um and so like from my background, like you know it's more like if you have a recurrence or some kind of recursive equation or any type of induction, you say like your base case. Like am I at my base case? Then just return. So in other words, if I'm doing some kind of Fibonacci sequence or something, it's like okay, am I at the end of the sequence? Okay, just return zero. And then it's like, okay, I'm not at the base case, then do some recursion and return that. And so it's like yeah, I mean if you're doing any type of dynamic programming type stuff or recursive or a lot of AI stuff, it's like you're always thinking in that mode where it's like you have some base case. You're just bailing early; otherwise, you're going to do some other stuff. And so yeah, when I see like that type of code, um yeah, I mean it looks so much better with, you know, all the returns up front, you know clearing out all the cases that you're not interested in.

0:25:23.240 --> 0:25:48.970
<v B>So, I mean maybe there is some good counter-arguments for having the nested if/else. And in some cases, if you do need to audit the code in the way mentioned and there's no other way of like having better constructs, that's probably reasonable. But yeah, I guess I'm currently feeling like maybe I should abandon the vestiges of like having a single return statement at the bottom. Like, yeah, I mean I'm not sure what the reason to cling to.

0:25:49.459 --> 0:26:05.288
<v A>It is. Yeah. I'll again, I don't know too much about low level, but like I feel like creating an object can't possibly use that much memory, like creating a empty class or something, right? And so you can almost always use scopes to do whatever you need to do.

0:26:05.895 --> 0:26:15.025
<v B>There. Well, I've got a story about work I was doing all day today about the minutiae of optimization. I was getting into that would make your skin crawl.

0:26:18.383 --> 0:27:44.614
<v A>Then okay, probably oh man. So um yeah, so my second story is it's just a cute little infographic. It's called 'Idea Instructions,' and basically someone took the visual style and the non-verbal style of IKEA and you know instructions. If you've ever built a chair, a table, or a bed, or anything out of IKEA, you know that there's um you know in the very first kind of page of the instructions they kind of show you like these are all the parts, uh, and this is what you want at the end. And they kind of walk you step by step, but every step is meant to just like show some kind of movement, but there's no words at all, no labels. If anything, there might be like just very minute, like at the top they might have two different types of screws, you know, nine zero zero and this is screw nine zero one. And then later on it might refer to those numbers. Other than that, there's almost no text; it's all just a bunch of pictures. And someone kind of took that sort of style and really treated it like an art style and explained a bunch of computer science algorithms, um like Quicksort and things like that. And it's pretty cute. It'd be a good thing to print out and put like or get laminated—not laminated, but uh um like just put it on your desk as like a cute thing, get it framed or something.

0:27:47.415 --> 0:27:58.283
<v B>You do? I wouldn't say you could learn them this way though. I did try to follow a couple, and for algorithms, I knew I was like, oh okay, yeah, I see what it's doing here, but for algorithms, I didn't. I was like, I'm not sure I followed.

0:27:58.654 --> 0:28:12.559
<v A>This? Yeah. I know no even like uh I'm looking at Quicksort and like yeah, I could kind of get what they're saying, but yeah, this has to be for people who already know what they're doing. And it's just a cute thing. Yeah, don't use this to learn anything. So I we're gonna

0:28:13.977 --> 0:29:05.749
<v B>go for two YouTube videos. I think this is definitely a record for our link section. Nice, but this was sort of something I've oh that uh I'd seen a number of before, but this one was particularly good. It's something I've always been interested in: cryptography. And that is the name of the video is 'Dealing Cards with Cryptography,' with Ron Rivest of the RSA encryption algorithm, and it's on the Number File channel. If you've never watched this, most people probably have; it's a super popular channel. But um Number File has like math videos where mathematicians or other people explain stuff simply, and it's got its own style, and it's nice easy watching. Um but this one has this famous cryptographer guy basically talking about how would you play a game of poker in the mail?

0:29:07.521 --> 0:29:41.423
<v B>using the principles of cryptography? And so he points out like, well, you know if Jason and Patrick want to play poker, you know Patrick has the cards. Patrick can't just shuffle the cards, deal five for Jason and deal five for himself because there's too much incentive for him to cheat. I would just give oh yeah, Jason, you totally all you got was three high terrible hand. Actually, that would actually be good. I only can get three high and not have got pairs. I'm not a very good poker player. Seven high? Yeah, right. Okay, all right, all right. Okay, good seven high. Yeah.

0:29:42.435 --> 0:29:45.625
<v A>If it's uh what is it? Uh Texas Hold'em, right? Uh I mean,

0:29:45.625 --> 0:31:27.938
<v B>I think just like he I think his example is just whatever five card. I'm not a poker person. I think just normal five-card poker, but basically like how does Jason trust that I'm gonna you know shuffle the cards fair? That we can compare fairly? And it turns out yeah, he wouldn't be able to normally, but if you use some of the things that are used for cryptography, and he actually sort of takes cards, puts them, and puts them in envelopes and places actual physical locks on the envelopes. And it's just really like I was watching it and I don't know maybe later I'll be like why did I pick that for the show, but uh I was watching it was just hilarious because this is something I've always heard described but I've never seen someone take actual physical locks, put them on envelopes, and sort of explain the algorithm. That's awesome. And of course he points out this is how computers do it. They do it really fast; they do it all the time. This is in a way kind of how public key cryptography is done. It's just done really fast and without real locks. Um but if you're curious about cryptography or just wanted—I I thought I found it humorous—you can watch this Ron Rivest on Number File doing 'Dealing Cards with Cryptography.' I think he has a number now; I'm trying to remember. I believe he's done other episodes on Number File as well. He's not the host, um but he I think has made guest appearances on there several times, um talking about other kinds of math. And um he explains in the video as well one of the ways that public key cryptography is done, which is exponentiation modulo factor, without going in super details. But if you've if you don't know anything about that, then I would encourage you to check it out. Cool.

0:31:29.018 --> 0:31:30.840
<v A>yeah i will definitely watch this video

0:31:30.840 --> 0:31:40.122
<v B>Right? Yes. This show is done. Yeah. Well, text me and tell me if I am like should delete this portion of the show. And this is totally just that I had a weird quirk in finding.

0:31:40.122 --> 0:31:43.733
<v A>It no. This sounds amazing. This sounds really, really fun. It's not it's not

0:31:43.733 --> 0:31:47.935
<v B>a super long video and it is not going to teach you to get a job in cryptography. So all right.

0:31:48.745 --> 0:31:50.380
<v A>It might teach you not to get a job.

0:31:52.356 --> 0:33:51.400
<v A>Book of the Show. Book of the Show. My book of the show is Hillbilly Elegy, which is um a really interesting book. It was a bestseller. Um I just happened to be crawling the bestseller list and I thought this is something that is totally outside of, you know what I would usually read. And so I give it a shot, and I thought it was great. Um uh it's basically it's one of these things where like the environment. So it's a it's a non-fiction book. It's about a real family, so it's it's anecdotal. Um um and yeah, the environment kind of is the book. So without really spoiling anything, let's just say like um uh basically okay, after you know there's this there's this big Industrial Age. There's there was a lot of manufacturing jobs, right? People working in like steel plants, things like that. Um a lot of those jobs kind of went away. And um this is somebody who I think he grew up—so I think this person is probably in their 40s, I want to say. Um and so they're coming kind of on the tail end of that. Um Or maybe they're younger than that, but anyways, so they're coming on the tail end of when a lot of those manufacturing jobs really went away, and it basically decimated this town. And uh it talks a lot about uh you know a variety of these towns in Appalachia, which is uh people aren't from the U.S or people are don't know. It's it's like Kentucky, kind of Tennessee, Pennsylvania area. Um and just about kind of how they got decimated. Nobody really knows about them. They have a lot of pride as a people. Um but they're also like kind of suffering like immensely. And it really kind of talks about um a lot of specific things like I uh I've driven through, you know, Kentucky and Tennessee and Pennsylvania, but never actually stopped in any of those states, and so I know very little uh about their culture.

0:33:51.400 --> 0:35:04.056
<v A>And so this was like a really interesting insight into um into that culture. And and it really talks a lot about um specifically like why some people um in that area or maybe in the U.S and broadly are struggling. Uh and there's there's a lot of reasons why people are struggling, but if you were to ask me for let's say even 10 of them, I probably wouldn't have even give one from this book because I didn't really think about things in this way. Um so so it really is interesting. I mean, it's not an uplifting book, although it you know it it uh it ends on a high note with some people really sort of making the best out of their situation. Um but it's it's a pretty heart-wrenching book, but super super interesting. Um a great story. It really kept me engaged. It's you know I've i kind of tend to, you know, one day I'll work—I'll you know start reading a book or continue reading a book. Another day I'll do something else. This book, I just blitzed through it because it really captivated me, and I think part of it was that it was so different from what I usually read. Um so yeah, I would highly recommend it. It's it's a bestseller, so it's it's really high quality. And uh yeah, I think it's a fantastic book.

0:35:06.334 --> 0:36:29.258
<v B>It on Audible. Nice. I'm listening to Oathbringer, which is the third book in The Stormlight Archives trilogy by Brandon Sanderson. I think I've had the other two books on here before. I would love—I actually have read a couple other books, but I didn't really care for them, and I dislike giving like mediocre. Uh I have done it a couple times, but I I'd rather talk about something I'm really enjoying. Yeah, even if I have the choice, right? Yeah. And so um this one, I'm nearly done with. So one of the things I want to point out is first of all, this is the third book in a trilogy, and I just looked it up because I'm listening to it. It's 55 hours. This book—this book, uh the third book—um the others are almost as big, and so this is a massive amount of like commitment to get through all of these. And I was reading, so I was curious. It says the hardcover is about 1200 pages long for if that helps you think about like how big 1248. And I was thinking another book I did read in actual book form was Anathema that I thought was like a very big book by Neil Stephenson, and that was only 937 pages. So I'm not saying that like it's amazing just because it's really big, but uh it's taking me—I was shocked. It's actually taking me kind of a long time to get through it.

0:36:29.258 --> 0:36:47.960
<v A>Is that because it's are books on tape uh or Audible books faster or slower than reading? I mean, I know it depends on the person, but like what does an average person or you for example do you read? I read much faster than the Audible narration. Okay, even if it's because, you know, there's reading like skimming through something.

0:36:48.023 --> 0:36:54.402
<v B>No, no, no. Like just my normal reading speed is okay, quite a bit faster. I never really thought.

0:36:54.402 --> 0:36:55.752
<v A>About it until now.

0:36:55.752 --> 0:38:11.780
<v B>I mean, I've never like raced, sure, but I'm pretty sure even like—I'm sure I could read slower if I wanted. But like even just reading at like an enjoyable pace for me, I mean much faster. The the thing for me though is finding time, I guess. I'm just too distracted, but like finding time to sit down and actually read a book is tough. And so I tend to not get it in in as long of periods versus it can take me 45 minutes or more to get home nearly every day. Uh and so that is a time when I can sit there and do my you know, get quality time with a book. Yeah, makes sense. Um and so for me uh you know even if I could read faster, so like this is 55 hours, it might only take you—I don't whatever, I don't I don't know what the ratio would be because it depends on your speed. Let's say 20 hours. Yeah, 20 or 30 hours. But for me finding 20 or 30 hours to read this is just like I don't I don't currently have it scheduled in. And so but I I enjoy the content a lot. Yeah. And so but Oathbringer, I am like three hours left or something. So oh wow, I'm down at the finish line. But I I I don't know that it's going to have an amazing ending or not. Not quite at the end end end yet, but I've i've really enjoyed it so far.

0:38:11.780 --> 0:38:22.962
<v A>So you've talked to me about in or talked to us in the past about um you know world-building versus kind of building story and things like that. Where does this fall in in that sort of axis? So I

0:38:22.962 --> 0:39:46.080
<v B>Mean if you have that much time to, or you know, pages to go over something. So this is interesting. I think this definitely qualifies as world-building. So it's very much about people and about stories, but also about a lot of kind of—you learn a lot about the world these people are living in. And one of the books I read that was this collection of short stories. This is not the one I was saying I didn't like, although I actually—I'm not a big fan of short stories. I don't feel I can get into them, but a lot of Brandon Sanderson's books take place in a sort of meta-universe called the Cosmere. Anyways, this is like super detailed. I guess it doesn't matter, but he has a bunch of books that sort of feel like you can just read them in isolation, and they are in isolation except that it turns out they're all really in a bigger universe, and there are like common traits about the bigger universe. And so there are sometimes easter eggs between the books if you read between the books. And this collection of short stories has a lot more detail about sort of the behind-the-scenes inside baseball of, you know, kind of that thing. And so I think not only is he doing world-building on like a per-series basis, but he's also collectively building all of the worlds together into one universe.

0:39:46.080 --> 0:41:22.225
<v A>That makes sense. That sounds similar to like Terry Pratchett books, right? Where you know there's this—basically there's a—there's a I guess an engine for lack of a better word with a set of rules and an environment there, and all the books take place within the same engine. And so there are certain things that happen that seem kind of just serendipitous, but over time you start to understand how the engine works. And so then when you see that thing again, you're like, 'Oh, even if it's in a different book, you know, you kind of know what's really going on,' and someone who—that's their first book—isn't getting it yet. So like one of the examples of this is the number eight. The number eight in Terry Pratchett books is—you can't say it if you're a wizard, so you have to do seven plus one is—uh, you know, two to the third or something like that. If you say seven plus one is eight and you get, I don't know, struck down—I can't remember exactly what it is—and so there are just times where that comes up, and eventually you read the handful of times in the series of books where that's relevant. But then there's still, you know, other times where it happens, and it's just kind of part of another story, and it just kind of happens. And if you know that, you're like, 'Oh, wow, that's so cool.' Like it's funny that just happened that guy got, you know, obliterated by lightning bolt because he said the number eight. But if it doesn't happen, it just seems like just some serendipitous thing. Like what? The lightning bolt struck that guy down? Okay, let's go on to the next thing.

0:41:23.355 --> 0:41:51.819
<v B>Yeah, so I—to conclude, I mean Oathbringer is a really good book. I'm gonna recommend it even though I'm not finished with it yet, but a little hard to give. I haven't shared anything actually about the book yet, but it's hard to when it's the third book in a series. So go check it out on, I guess Amazon or Goodreads or wherever and sort of read if you're interested in—in the summer, the back of the book, but you'd have to go to a bookstore to find the back of the book. So not going to recommend.

0:41:51.819 --> 0:42:41.554
<v A>That right? And you could read that on Audible, and if you are—if you're not an Audible member yet and you want to join, use our link that helps us out: you go to audibletrial.com/programmingthrowdown. All one word. And if you are an Audible member or or you want to support us in any other way, you can go to our Patreon. Just an update on the Patreon. So I think we're set on the design. I actually—I'm going to print out tonight. My printer actually broke, but but yeah, I got a new printer yesterday, and tonight I'm going to print out the thank-you letters we're going to write. We're going to stuff those in some envelopes along with the emblem, and we're going to start mailing those out hopefully, you know, in a

0:42:41.655 --> 0:42:49.165
<v B>couple weeks. Yeah, I also had laser cutter issues, so I am lagging behind getting all of the logos cut. So but yeah.

0:42:50.380 --> 0:44:08.022
<v A>It's gonna happen. It will happen before the end of the year. Yeah, yeah, and you know every Christmas we're going to do this hopefully—no, you know, we'll get it more streamable that we're not going to do this where half our hardware breaks, but you know every Christmas we're going to do this giveaway. I, you know, I have had my printer break, which sucked, but overall, you know, it's been really fun just, you know, you're really—I mean part of it just looking up where people live like because you know we need your address to mail you at the emblem. Just seeing that we have people all over the world who support the show is really exciting. And being able to make something and something kind of real and physical and send it off to the people who are listening is really cool, and so we hope you all keep, you know, keep subscribing. Definitely tell us—you can use the Patreon chat which I which I follow, you know, I monitor or whatever. Tell us what you think once you get the envelope if you get it broken or something. Definitely let us know. But in general, we appreciate so much your support. Also, if you're in Russia where our podcast is banned—not because of our podcast specifically, but just our hosting provider is banned—if you're a Russian, you can access the Patreon RSS, which is which is super fast and works in Russia. So nice tool of the

0:44:09.945 --> 0:46:06.259
<v A>show. My tool of the show. It's actually two, but they both do the same thing. I Funny and Nine Gag. So these are apps. One is iFunny, kind of like iPad—like the letter 'i' funny—but it works on Android and desktop and everything. The other one is Nine, the number nine gag. So Nine Gag, both of these are just basically a you know, a feed of funny things, and you can kind of tailor it. It also kind of knows, you know, based on your upvotes, it kind of sorts it accordingly. You can also look up certain things if there's a certain topic you want to follow, but it's just a list of really funny things. It's usually memes—usually like a picture with some text. It could be a video with a caption. But you know I'm one of these people. I really believe a lot in this idea that especially when it comes to emotions that we're all like much simpler than we would like to believe, right? And so if you just see something silly and laugh every day, I think it actually will have a profound effect on your mood. And even though it sounds like such a forced thing, and I wouldn't go into it saying like, 'Oh, I need my funny medicine today,' or anything like that, right? But I just in general, it's good to have like systems in place that you know may improve your life. And for me, this is one of these things. Like I have these apps—they send a notification like roughly every day, and so I can kind of, you know, tap notification logs me in. I get to see some really funny stuff, and if I see something really funny, you know, I'll share it. So occasionally Patrick and other people get kind of random memes like how, like, you know, where did this come from? And there's no context at all. It's just something funny I saw in one of these apps. Yeah, and I think it's—it's one of these things that really kind of—it'll let you sort of bond

0:46:06.259 --> 0:46:16.137
<v A>with other people too. Like especially like you might not have a reason to talk to Aunt Sue, but you can always send Aunt Sue that video of that cat, you know, getting stuck to a ceiling fan or something like that. Now.

0:46:17.402 --> 0:47:04.973
<v B>I'm gonna have to scroll through all of the—no, I'm just kidding. So it's speaking of things that definitely don't waste your time. Yeah, right. Jason informed me I'm behind and I'm not hip like all the cool kids, but I started playing PUBG because it came to mobile iOS and Android, and I've been playing on a tablet. So not only did Jason tell me that I was behind the times and that he's been playing this for like literally months, but then he proceeded to tell me that the reason I am so good is because it was actually full of terrible bots and that I wasn't actually beating people; I was just beating crappy bots. So I was really stoked, and now I'm just really sad. So I need to stop the podcast and go back to

0:47:04.973 --> 0:47:09.614
<v A>playing? You got up to where you're playing people, right? I believe so. I—so

0:47:09.614 --> 0:47:12.010
<v B>at least there's at least I'm getting crappier.

0:47:12.179 --> 0:47:59.496
<v A>One of the—so PUBG is PlayerUnknown Battlegrounds, and it's—it came out for desktop initially. And a co-worker, someone on my team actually said, 'Hey, you know, you should buy this game, and we'll play together.' And I said okay. So we played it, and it's just really hard. And also I'm just generally not very good at games where you have to kind of be accurate. Like I don't have a lot of dexterity. And so, you know, I think I looked at my ranking. I know granted I don't play that much. I play maybe two hours a week or something, but my ranking is like I'm in the 70th percentile, and I probably—you know, probably 29 of accounts are inactive. So I'm not at all good at this game. So but just

0:48:00.419 --> 0:49:20.024
<v B>For people who've never played You, it's actually really cool. I was explaining it to my wife, and as I mean, I'm late to the game. I had heard about it before, but I've never played it much or I never played it, never watched a video of it. But roughly the idea is you and 99 other people get dropped onto an island, and it's sort of kind of like a mix of various themes you've seen before: Hunger Games, some different kinds of movies. But your goal is to survive and be the last person surviving. It doesn't take terribly long. I don't know if the computer one is the same, but on tablet it typically takes like 25-30 minutes maybe. Yeah, that's about the same. And so what happens is, after just a couple minutes of being on the island, there's going to start being a circle, and you have to be inside the circle or this like energy field will come crush you when you die. So basically, there's an ever-closing circle that you need to stay inside of, compressing anyone who's staying alive down into a smaller and smaller area. Thereby, in theory, you know if there was lots of people, the density would go up, and they'd fight each other. But you can also collect—but you start off with nothing, and you need to collect armor and weapons and ammunition and health packs, and you're running around scrambling trying to find it. And if you come across someone, then you'll like fight or run away, or you know.

0:49:20.024 --> 0:49:51.141
<v A>Whatever. But yeah, running is actually not a bad idea as opposed to other games where, you know, if you're playing Unreal Tournament or Quake or one of these games, you just run around shooting everything. But this game, you know, is a lot about sound. So if you shoot, everyone's going to know where you are. And people who are really good at the game might say, 'Oh, you know, if I hunt that person down, I can take his equipment.' So not, you know, just letting someone run away is actually not a bad strategy.

0:49:52.154 --> 0:50:37.665
<v B>Right. So, you know, running away, knowing if you're outgunned, knowing if you are going to draw someone's attention. There are some vehicles you can drive around. The vehicles, you can hit people with your vehicles. Um sort of a free-for-all. I've been enjoying it. I don't know how long I'll stick with it because, you know, it's one of those things like for me it was kind of fun like goofing around and like doing reasonably well at. But I'm not sure I'll invest the time to sort of get amazing at it. There seems to be lots of subtleties, and exactly what weapons loadouts you tune for and how accurate you are. And it's also quite a bit stressful. How does the shooting work on mobile? I'm pretty sure it's similar; it's just you use on-screen controls or whatever.

0:50:38.037 --> 0:50:45.276
<v A>Because like for example when you have the sniper rifle, you have to be extremely precise with the mouse to hit somebody. I mean it.

0:50:45.597 --> 0:51:02.134
<v B>Has some amount of auto-aim on, but I don't know to what extent. So, there you don't play between a computer and the mobile device. So they're actually two different implementations of the game as far as I understand. That makes—

0:51:02.354 --> 0:51:08.699
<v A>Sense, right? Yeah, you get a huge disadvantage if you're on your phone and so or vice versa, or if—

0:51:08.699 --> 0:51:12.310
<v B>They have too good of auto-aim, then you'd be at a huge advantage.

0:51:12.495 --> 0:51:13.812
<v A>Oh right. That's true. Yeah. So—

0:51:13.812 --> 0:51:14.436
<v B>I'll have—

0:51:15.280 --> 0:51:19.549
<v A>To try the mobile out. I actually downloaded it, but I haven't played the mobile version yet. Yeah.

0:51:20.427 --> 0:51:27.565
<v B>Everyone probably already knows it. I recommend YouTube channels that have like two million subscribers and currently most popular iOS games. Yeah, you're—

0:51:27.565 --> 0:53:25.900
<v A>Such a rebel way to go against the grain. Although you told me you literally pitched a book as it's good. It was on the bestseller list. Yeah, we're just shilling the whole episode. It's just an hour of us jump[ing] the shark. It was popular. I mean, you know PUBG bestseller list documentation. I mean, what's more popular than these things? Yeah, and now we're going to talk about documentation, the most powerful popular thing ever: um documentation. So, you know, the first thing is, and this is really true of anything, is why document. And maybe we should start every language with 'Why does this language exist?' We kind of do, but—you know, why document? Right? I mean, it slows you down. It's, you know, if it's not done right, you have to keep it up to date. I've actually seen some pretty funny code. We have this thing called Clown Town, and it's just a group at work where people post just miss like bad code, and it's usually just things that have like gone south over time, like rotted in a sense. And there was one where someone posted, and it said—the comment said 'return 1,' but I don't know why. And then the next line was 'return 0.' It was like so, yeah, that can happen. And so, you know, the reason why we want to document is—someone explained this to me at work, you know, it's about five years ago, and it's just so profound. It's just one of these things you don't think about: um, you know if you're at a company, you're almost certainly going to have some type of code review, which means like you're going to read your code because you don't want to review—just, you know, you don't want to embarrass yourself, right? So you're going to go through it, and then the reviewer is going to go through it. And even if you only have one reviewer and no one ever looks at it again, that's already twice as many people if you count your second pass.

0:53:25.900 --> 0:54:03.557
<v A>It's already twice as many people that have read it than written it, right? Um and chances are it's going to be way more than that, right? You might send a code review to two people. Um there might be other people on your team who look at it, right? Also, you might come back five years later. This has happened where you come back five years later and look at something you've written. And you're basically a different person at that point because you have zero context. You're probably using this code for a different reason. Um so that's—that's you know yet another context that has to get filled in, right? Um the

0:54:05.565 --> 0:55:24.945
<v A>Other part of it is you want to document to sort of let people know the intent of your code and also the span. So I mean we talked about the design interview at the beginning of the show, right? Maybe you have a function that sorts less than 100 numbers super quickly, like it runs on some assembly code or something, and it's just insanely fast but only starts at 100 numbers well. Like you need to let people know, right? And there are actually like—um what's the term for this? There are actually like programming language constructs where in the input you specify what's expected to come in and what's expected to go out of this function. I'm totally drawing a blank on the term for that. But in general, most languages aren't like that. Like most languages, you know, you just say this takes an inch; you don't say this takes an inch of this to this range, right? Um I think it's like contract programming or something. Yeah, yeah. But but you know we're not writing like that almost none of us, and so the documentation is really what's going to let the person know like this is the kind of input I expect; this is the kind of output I'm going to produce, right?

0:55:27.342 --> 0:57:07.664
<v B>Even just simple things, like if you're in a language that has null pointers that can this be null? Yeah, yeah, exactly. As I expected. So I mean the first kind of comments talk about is sort of generic across every kind of language, I guess, but most at least as far as I know, every language has is composed of source files, and there's kind of—and I've had this debate back and forth with people over time like do you document large descriptive comments at the top of a file or do you mostly focus on commenting sort of at the line or at the call site or at the function signature or wherever the applicable places? Do you do both? I mean, ideally you would just document everything all the time. But you know it is tough sometimes because like Jason was pointing out, you want to document this so when you lose the context you can come back to it, but it's also hard because I think sometimes people comment the wrong things. Like people comment the obvious things, right? And not the subtle things. But that's really tricky because when you're in it and the context is fresh in your head, the things you think you might need to comment are stuff that is probably easy to figure out later, and the stuff that you chose for some subtle reason you may not think to put a comment on. But you know generally I think it is good at you know especially for large pieces of functionality to have a bunch of comments up at the top that sort of says what the point of the file is, what the direction you're going in? Um maybe some use cases, and that's

0:57:08.204 --> 0:57:14.819
<v A>going to force you to organize your file system. It's going to force you to organize your source files in some meaningful way. Yeah.

0:57:16.152 --> 0:57:54.357
<v B>I mean I'm a big fan of documentation at all levels if that makes sense. Like your organization of your code should be somewhat documentation. Like what files are in what folders, for instance? Um to me or in what modules is like a form of documentation. Like have a logical layout so that if someone's like, I wonder where this thing lives, they have a reasonable chance of finding it on the first try. I've been in code bases before where things just are all over the place; they don't make sense or just one gigantic folder. I don't care for that as much because I feel like it's documentation in depth that's what I'm gonna say. Yes.

0:57:54.475 --> 0:58:39.000
<v A>Yeah, I think too another part of it is it's a living system in a sense because there's just constantly people modifying it. And usually when you see for example, as Patrick mentioned, a directory with 200 source files in it, like nobody really set out to say, 'I want this to be the one directory to rule them all.' What happened is someone started with one file and then two files and then 10 files, and nobody really stepped in and said, 'Okay, we need to—you know, I'm going to take a month to sort of break this up into 10 different directories or something.' And so you know it's going to require like constant effort. And that gets back to the downside of commenting, which is um you have to maintain that. But but you know the upsides are well worth it.

0:58:39.000 --> 0:58:56.828
<v B>Yeah, I mean I don't think anyone's gonna disagree some documentation is good, but finding the balance can be tricky because I find sometimes you get really long comments that are you end up skipping because it's just like, 'Oh man, this person like this.' Yes, I know. You're just looping over all the things in the list.' Yeah, yeah.

0:58:57.587 --> 1:00:56.843
<v A>I got it. Yeah, exactly. Um so yeah, I think there's also ways to sort of self-document. Um you know, I think you know as Patrick mentioned, you can do the document at the top of the file. You could do documents in the functions, in documents within the code things like that. And the nice thing about those is—and we'll talk about these later—is there's something called generators that will kind of basically create a manual of your source code automatically. But in addition to doing that, something else that's basically free and you know it'll save you from having errors in the future. So it's kind of a no-brainer is to basically write self-documenting code. Um and so one example of this—and we'll kind of trade off different examples—is you know, and they always talk about one of the biggest problems challenges in software engineering is naming things, right? And so it's kind of like a tongue-in-cheek thing to say, but there's a lot of truth to that. I think you know picking variable names and function names is super super important. I've noticed over time, especially now that I've gotten good with Emacs key bindings in whatever editor I'm using, I have pretty long variable names, and I find that that really helps a lot. So for example, the other day I had something where this it was a data structure that was you know a list of a list of models, and then each model was a list of examples, and then each example was—I had a list of features. And so I had a variable called, you know, top or I think it was like, you know, root or something like that, and then I I was interested in the first model, so I create another variable that was called, you know, examples_4_model_0, and it was equal to root[0]. This

1:00:56.927 --> 1:01:30.900
<v A>is like a huge variable name, but it tells someone exactly what that data is representing. And if you're using something like JavaScript with ES6 or C++ or something, you could do const. That's even better, right? Because now that variable is only ever going to represent that thing, and people know it. In my case, I'm doing Python, so I don't really have const. Um but you know and it kind of that kind of style and and doing that with functions as well really helps, and it could probably save you from writing a line of documentation.

1:01:30.900 --> 1:02:23.412
<v B>There—I mean I think anytime you have variables and are able to use them like Jason was pointing out rather than just indexing in. Now obviously you could take it to an extreme, but providing extra context for something, breaking up stuff into different functions. Oh, that's a lot of stuff, breaking up things into different functions and saying, 'Hey, I'm gonna put a function here not because I need to, but because it makes it cleaner to read.' Um and anytime you can limit the number of variables any piece of code you have to sort of think about to be able to execute, that's also going to be an advantage. Although we just said to make new variables, um but I mean the keeping variables that are related around are good. But if you have code that just sort of becomes really long and there's lots and lots of variables in play, that also becomes difficult to

1:02:25.200 --> 1:03:47.600
<v A>read. Yeah, definitely. I think you know one thing I do when I'm doing C++ coding—and tell me if you do this—Patrick is—I tend to put a lot of extra braces. Like it's not the braces aren't connected to an if or a for anything like that, but it's like I have a set of and maybe these are things that really should be functions, but you know I I have some um some variable that I know is just going to live for a few lines of this function. So I just put braces let people know like look, this variable dies right away. Um and so you know don't expect it to be around the rest of the function. Um And that kind of helps people modularize it. I feel like there's a trade-off. Like you could just have a lot of functions and let the—um you know let the function you know define all the scope and all of that, but at some point that actually can get kind of hard to read because you end up with a lot of functions kind of scattered all over the place, and you have to be careful like how you sort of order them and things like that. So it's so it's pretty readable. Um So I've found that for particularly like for small things—let's say like less than 10 lines—instead of making a function for that, um I'll just wrap the variables in braces so that you know C++ kind of destroys it, which that's not really that useful per se, but it's really just that people know that this variable has a very small context.

1:03:47.600 --> 1:04:50.680
<v B>I mean I have seen that before. I don't tend to do the exact pattern you're saying. I mean there are certain cases with like standard locks or if I know if I have an expensive allocation where I need to do exactly what you're saying. Um I think people could use the—I for I don't remember what that's called, the curly braces without a if or for loop or whatever, just the empty sections or the sections. Yeah, I think it's just called a scope, but I don't know. Okay. Yeah. So like using scopes probably could use it to better effect. But I mean I think you also don't want to go overboard. Yeah, like it isn't a standard thing and you know. So yeah, but I mean I think all this stuff is to say that you try to be careful in what you name things and use the features of the language to your advantage and in trying to help it make it descriptive. Um But we've also pointed out that types are a form of documentation despite Jason also said that he was working in Python, but actually

1:04:50.680 --> 1:05:52.290
<v A>Hey, hey, hey. You know Python? I don't know if you know this, but we use Python 3, and we use types on everything. Oh, everything. Yeah. So Python 3 has a typing. You can import `typing` and then say like, you know, actually, you do from `typing` import, you know, `Dict` and `List`, and all those types, right? And then we actually have a type checker. I think it uses MyPy, but yeah, I mean, you know, it's there's not like a mandate or something. It's like, oh, you didn't put a type here; you're fired. But it's like, you know, if someone writes a whole file, for example, with no types, then they'll probably get some feedback like, hey, you should put types here. Nice. That's good. Yeah, yeah, yeah. The types are super, super important. Without types, it's just a nightmare. Actually, Patrick and I—it was a time we worked at the same company, and we wrote a bunch of Python without types, and that was pretty rough. Jason wrote:

1:05:52.290 --> 1:06:25.340
<v B>A bunch? No, I'm just kidding. Yeah, it's yeah, you're right. I know a lot of people really like stuff without types. We can get into that. Let's save this for a different discussion. Let's keep going. Sure. So generators—so the idea of a generator is writing comments or specially tagged comments in your code that then gets exported to a web page or a PDF or a different form that sort of summarizes your code without containing your code itself.

1:06:27.306 --> 1:07:26.900
<v A>Yep. And you've probably seen this if you've ever seen like you can tell because it kind of not to not to start off by disparaging it, but it kind of looks goofy because, you know, these generators, they don't—they have to design the way they look based on anything that could come out of your code, right? And so if you've seen this weird sort of four-panel type website where you have all the Java, you know, namespaces and the top left panel, the classes, and the bottom left, and then I guess this is three-panel, and then on the right, you have whatever, you know, class you're looking at the moment. And you'll know it when you see it; it's like they all kind of look the same. Very few people actually change a default template for the default theme, but yeah, that's something that was auto-generated. And so those people don't have to create that website or anything; they just run one of these generators, and a website comes out. They just have to put it on a serving platform somewhere.

1:07:28.377 --> 1:07:35.970
<v B>So I'm gonna start this off by saying I actually dislike code generators as a whole. I tend to not use them, and you

1:07:35.970 --> 1:07:39.560
<v A>talk about like the document generators or just code generators in general.

1:07:39.750 --> 1:07:58.960
<v B>Oh no. I get yeah, document generators. Okay. Yeah, yeah, like Javadoc if I'm writing Java, I never—like, I dislike going and reading Javadocs. I don't find them valuable. I don't. We have some pieces of code that have Doxygen comments on them. I never generate the Doxygen and go look at it. I don't know. You

1:07:58.971 --> 1:08:01.857
<v A>don't think other people do, like other teams or whatever.

1:08:03.190 --> 1:08:50.895
<v B>Don't I'm scared. I'm a skeptic. I'm waiting to be convinced. I think they have their place, and I think if nothing else—I mean, I think they're really useful for sort of enforcing a style to comments, like you should comment on what your return type is. You should comment, you know, what that each fun, each, you know, public function, for example, should have some comment on it that says what it does. But I'm not—like the problem is a lot of times when you try to make them very rich, they actually become less readable in the code. And so I feel people end up in this dichotomy of either making the generated docs good and the code bad or the readableness in the code better and the docs bad. That's a

1:08:51.368 --> 1:09:50.025
<v A>really interesting point. Like I'll give you a specific example where I agree with you on that is the parameters. So if you—if you want to do, you know, the if you want to support Sphinx in Python, which is one of the code one of the code generators in Python, you know, if you put like at param whatever the parameter name is. So if you have a parameter name like number of places, you do at number of places: or I think it's at param space number of places space and then a description of what that parameter is. And if you do that, it looks really nice. You know, the output of that, like after you run Sphinx and you look at the web page is generated, it's really nice, and you can hover over the parameter and it reads it to you in like a tooltip, right? But the actual documentation, like, looks ugly. They give these at signs randomly, and plus like people start explaining parameters that don't need to be explained. Yes, it's like, you know, I know what that parameter means.

1:09:51.257 --> 1:10:28.467
<v B>Know yeah, that's the thing for me is like not only does like the documentation become sort of a little difficult, and especially when people start using hyperlinks and stuff. And yeah, I don't like it; just becomes really messy. So having a hyperlink in your code is okay, but then having it flagged out and tagged properly so that it gets, you know, looks good in the documentation just becomes very cumbersome. But as Jason pointed out a lot of times, which is true of documentation just as a whole topic, is like understanding some things don't always need to be documented. And so something like, you know, I'm trying to think of a good example. It's like one of

1:10:28.800 --> 1:10:39.200
<v A>the things here's an example. Let's let's say you have an array of, you know, model—an array called `models`, and they have a variable called number of models because you're doing this in C++. Yeah.

1:10:39.200 --> 1:10:54.640
<v B>Sure. Yeah, yeah, and you really write a comment: Number of models is number of models. Yeah, yeah, exactly. Yeah, or a function called `getIndex` that takes in a variable called `i`, and you say `i` is the index of which to get. Yeah. Oh, yeah.

1:10:55.095 --> 1:11:14.789
<v A>And yeah, to Patrick's point, like you know when you use a generator, it really compels you to have to explain things that probably don't matter. And uh, you know what that means is people will get a little bit more depth to your comments because if half the comments don't matter, they're going to pay less attention to the other half, I guess.

1:11:14.839 --> 1:11:35.190
<v B>I also have this worry that there's a sort of amount of time people will spend documenting, and I want them to spend it on the stuff that matters most. And if they're spending it on, you know, cleaning up the formatting and spacing of every one of their parameter names that don't matter, they're not spending it in like restructuring the code in just a more readable, maintainable way.

1:11:36.119 --> 1:13:29.046
<v A>Yeah, on the flip side though, like if you look at really core libraries, um you know they make tremendous use of this. And this is like, you know, library like TensorFlow or for example. Like TensorFlow, there's so many people using it, but they're in a sense taking a risk because, you know, they're using TensorFlow instead of building their own thing. And if it turns out they need to extend TensorFlow in some way, they're really counting on it—it's like a social contract there. And uh, if you don't have the generator, it's kind of hard for people to get started, you know, just diving in through the code. So I don't really have this is going to be a weird show in the sense that we don't really have a silver bullet. Um, you know, maybe this is an opportunity for someone to like invent something totally novel, but uh, you know, yeah, I agree with Patrick that the generators kind of cause people to write very odd comments and not very well-structured comments. On the flip side, if people use the generators but write only the important comments, then the generated output doesn't look very good. It's not like it—yeah, yeah—because what the generator will do is it will print all of your functions, but then the majority of your functions will look very bare and they'll look very bizarre. Um, in general, that's a problem with generators where you know you might have, let's say you have a helper function, sort array or something like that, and it's just helping your class do something—maybe it's even private. Uh, the generators now there are rules or maybe they won't, you know, generate docs on private functions things like that, but you're still going to encounter cases where things are basically going to show up in the documentation that don't matter, like a lot of the functions probably don't matter to 99% of your audience. And so,

1:13:30.919 --> 1:13:39.379
<v A>All of that? Yeah, I think you know maybe generators but with a lot of hand-holding could be the way to go, but

1:13:39.458 --> 1:14:40.866
<v B>But you brought up a really—yeah, you brought up a really good point though a minute ago about saying like part of this is under and you're sort of elaborating on it now. Like part of this is how many people are going to be using your code? If you're writing some like deep internal something that isn't really going to be shared by a lot of people, um then the kind documentation is important, but the kind of like put it out to a website maybe less so. But something like, you know, TensorFlow or something that's going to be a common utility, then it's—it might be worth investing in, right? And spending the ongoing cost of maintaining that's a hard balance to strike because I think a lot of times we were talking about before this grows organically. You don't think like, oh, this code is going to be used by everyone. Uh, and then it is, I guess that's a good problem to have. But uh, you know, or you could think, oh man, so many people are going to want to use this, come and spend so much time documenting it, and then, you know, it never is. Yeah, that's that's.

1:14:41.474 --> 1:14:50.282
<v A>Yeah, you want to do lazy evaluation here? Like you want your project to get uber popular and then document it as an uber-popular project? That's

1:14:50.282 --> 1:14:51.420
<v B>tough to do too.

1:14:51.420 --> 1:15:12.473
<v A>Yeah, I mean well, I'll put it on your plate. Let's say let's say you inherited some project that had like you—you inherited Firefox codebase. Oh dear. And and it has, you know, maybe it has some inline doc. Like how would you document something like that? Like what would be the best? It's tough, but

1:15:12.473 --> 1:15:34.208
<v B>I mean, like you're like Firefox is a good example. It's like lots of people and I don't—I have no idea about specifics of Firefox, but lots of people use Firefox, but most people don't use it as like an SDK. So the kind of good point, the kinds of things like what is their JavaScript engine called? I forgot now. Um, but um Gecko or

1:15:34.208 --> 1:15:36.199
<v A>Something is that oh no, no—Spider.

1:15:36.604 --> 1:15:37.684
<v B>Monkey. Yeah, yeah, Spider.

1:15:39.420 --> 1:15:47.894
<v B>Monkey. Okay, so I'll take your word—Spider Monkey. Like he probably needs better documentation than like the font renderer. Yeah, that makes sense.

1:15:49.547 --> 1:16:01.022
<v B>I'm picking stuff up, but right, like trying to understand, like as a whole Firefox probably doesn't need equal documentation. So I guess it's the same thing like we were talking about in the files. It's recursive.

1:16:01.022 --> 1:16:54.955
<v A>Dear, um, so yeah, maybe if I had to come up with a strategy here, I would say if you're writing something that starts to attract a broad base—a broad base of developers, like let's say more than 500 developers or something like that—or you're building an SDK where the goal is to have thousands of developers, like that is the sole most important goal, then go this generator route and take the time and effort to do all the manual curation and stuff like that so that it you've pruned out all the meaningless stuff and you document everything for the stuff that matters. But then for every other part of your system or for every other thing you work on, yeah, just skip the generator and do the comments, you know, kind of yourself in the function and all that.

1:16:54.955 --> 1:17:16.403
<v B>Say actually a lot of the ones I've used JavaDocs are pretty good because I feel that if you use them just in the minimally intrusive way, they're pretty helpful. And even if you never generate the docs—like I don't think I've ever generated JavaDocs; the output I don't know, I don't even know. I wouldn't even know how to do it actually, so I'm pretty sure I've never done.

1:17:16.757 --> 1:17:23.237
<v A>It before. Um, I've done Doxygen and Sphinx. We have NJS Docs, so I've never done JavaDocs either. I've only seen them.

1:17:23.237 --> 1:17:40.349
<v B>But I will say that I have read lots of JavaDoc comments in source code, and that for the most part, that when someone people go kind of sort of crazy overboard, I think they do strike a decent balance. Like you can use it as a sort of slightly more structured comment, yeah, and then.

1:17:42.053 --> 1:17:48.297
<v B>It's just sort of this side benefit that it also happens that if you do that, you could get these generated documents. Yeah, actually.

1:17:49.005 --> 1:19:29.879
<v A>We should explain that a little bit. So the way these generators actually work under the hood is, um, you know, in the generator documentation, they're going to explain, you know, specifically how you need to document—um, whether it's a function, a class, whether it's the top of the file, a module in the case is what it's called in Python, or a variable name, so on and so forth. It's going to tell you, look, if you want to document this parameter of this function, this is exactly what you need to write. It's usually some preamble text or something like that, and that's going to let the generator know the context of what you're about to say. And then you write your comment, and maybe it's based on a line break or based on um, you know, two line breaks or something like that—that's how it knows to reach the end of that. And then what the generator does is it will, you know, recursively parse through all of your source code, pull out all of those relevant comments and the code that it pertains to. It's usually just based on the code that is immediately following the comment. Um, and then uh it will it will generate, and it can generate a lot of things: HTML, it can generate a PDF. You know, one of these generators could generate all of these different formats, and so you could literally just get a PDF with, you know, all of this documentation or print it out and give it to somebody and say, 'Here's the manual of my code.' Um, yeah, it's so in that sense it's really cool. But as we talked about, it has to be done, you know, it's it's the auto-generated stuff isn't, you know, that elegant? You still have to do some.

1:19:34.845 --> 1:19:48.800
<v A>Hand-holding. Um, I've actually I use Doxygen for my PhD code, so um my PhD project was like relatively popular. I don't know, let me look it up. Oh dear. Um yeah, now it's probably I'm gonna feel.

1:19:49.071 --> 1:19:52.193
<v B>Bad. No, don't end this with me feeling bad. Um well,

1:19:53.695 --> 1:19:59.365
<v A>This is uh this is like years and years of work with no pay, so you should not feel bad at all.

1:20:02.014 --> 1:20:22.780
<v A>About this. Um yeah, and I used I used Doxygen for that, and I felt like it was it was pretty reasonable. I want to bet probably nobody looked at it. Um but uh it kind of one thing it does, it kind of enforces you put some pressure on you to document everything because it looks weird when you generate this document and half the stuff's empty.

1:20:22.780 --> 1:20:51.644
<v B>While you're looking that up, I mean, I think documentation in general is one of those things that everybody feels we could do better at. Um and I don't know that anyone I know—I don't think there's an exactly a clear best balance of it. Um So be practical, but do write documents. Don't be the guy or gal on the team that says that 'Documents my code is amazing; it doesn't need documentation.' Yeah.

1:20:52.740 --> 1:20:54.647
<v A>Another thing is a lot of

1:20:56.875 --> 1:21:57.000
<v A>People don't—what's the word for this? Okay, a lot of people don't. If you're running a bunch of shell commands, you might not put that into a file, and you should do that. So in other words, the biggest documentation faux pas I've noticed is actually, and maybe it's just the nature of the particular, you know, type of programming I do, but the biggest mistake I see is not people not documenting the functions and things like that, but it's somebody has like this: 'Oh, I run this and I run this command. I run this command,' ends up being like literally could be 10 commands, and they just type them all in every time. Don't do that. Like even if it's just one command, make a Bash script, document the Bash script, and put it in the repository. So you'll notice if you go to the Eternal Terminal repo, I have a bunch of Bash scripts that are just one-liners, and they're not even that complicated, but it's just so easy to forget—to forget these one-line Bash scripts, you know.

1:22:00.392 --> 1:23:59.760
<v A>So yeah, I think when it comes to shell documenting shell, the flow is actually really important. So all right, but yeah, it's—I guess to conclude it, it's a living thing. Don't expect to have some silver bullet. Patrick and I, between the two of us, we've been in software—I mean, not combined a lot of years, too many years actually. The other day, anyway, I'll go on a tangent on this, but yeah, we've been doing this for a long time, embarrassingly long time, and we don't really have a silver bullet here. In general, with anything like this, it's just to stay on top of it. So personally, the stuff I'm doing now at work, I've definitely gone loose on the documentation. It's something that wasn't very popular, and now it's becoming more popular. And so now it's time to say, 'Okay, I'm going to take a week, and I'm going to just really clean up the documentation.' And what that will do is it will actually force me to clean the code as well—to organize the code into different, you know, organize the files and things like that. So just treat it like that, instead of trying to find some perfect plan in advance. Just look backwards instead of forwards, see how things are going, and then kind of keep adapting. All right? All right, thank you so much for supporting the show through Patreon, Audible, also through emails. This actually was a recommendation, but it was a recommendation from over a year ago, and I was just going through old emails, and specifically looking for show topics. I saw this one. I thought, 'Oh, this is a great topic; it could really appeal to anybody.' So I honestly didn't keep track of who told me what, but whoever suggested this.

1:23:59.760 --> 1:24:23.661
<v A>Thank you, and for people who send us emails, reply to us on Twitter, Facebook, so on and so forth. Thank you so much for your feedback and financially obviously is great; it keeps the servers running, keeps the lights running, lets us buy microphones and things like that so we can kind of reach out to more people. So thanks a lot, and we'll see you next month.

1:24:30.597 --> 1:24:52.740
<v A>The intro music is Axo by Binar Pilot Programming Throwdown is distributed under a Creative Commons Attribution-ShareAlike 2.0 license. You're free to share, copy, distribute, transmit the work to remix, adapt the work, but you must provide attribution to Patrick and I, and ShareAlike in kind.

