WEBVTT

0:00:14.543 --> 0:00:19.757
<v A>Programming Throwdown Episode 90: Terminals and Shells. Take it away, Jason.

0:00:20.162 --> 0:02:16.940
<v B>Hey everybody. Yeah, I have an interesting intro topic. Basically, this is something that actually happened a while ago, but you know, I wanted to talk about it right away. But then at this point, the show is actually popular enough that people I work with sometimes listen to the show, and I didn't want to just jump into something that happened—that'd be kind of weird. So basically, I've been waiting till now to kind of talk about it, but you know, it's about ambition and kind of the goods and bads of ambition, right? So what is ambition? Ambition is, you know, somebody's sort of driving to kind of push themselves in some direction. Like they want to have more responsibility. They want to—you'll be—they want to do more. I can work more hours if you're working hourly, things like that. And there are a lot of different reasons for this, right? Someone might want to make more money. Someone might want—that seems like most obvious—but that's only one of maybe at least, I don't know, three or four things. I mean, someone could want more prestige and more honor. Like they might want a nice title that they don't have. Somebody might want—they might find the work more enjoyable. Like they might find what they're doing right now kind of too boring, right? Or someone might want influence. They might want to be able to say things and people like to some degree have to listen to them, right? These are all kinds of reasons for ambition. There's probably others as well, and they're not inherently bad things. I mean, I think that's sort of what drives a lot of people. But where it becomes a problem is when people don't recognize—like they just don't know kind of where they're at. And this is one of those things that I—looking back on my career, this is one.

0:02:16.940 --> 0:02:21.038
<v B>things that I didn't have a good sense of either. So like when I was a

0:02:21.038 --> 0:02:21.730
<v A>junior engineer, I

0:02:22.169 --> 0:04:18.825
<v B>thought senior engineers were just people who coded slower than I did, right? And I thought managers were people who did nothing, and I thought directors were just people who—you know, wrote like mass emails encouraging other people, you know. And then I became a senior engineer, and I was doing all these design reviews. There were problems, like if there weren't good unit test coverage, and that caused the issue on the customer side. I would take a lot of heat for that, and we'd have to have discussions about that and why that happened, etc., etc. And that all took a lot of time, and so that was less time that I was spent writing code. And so I realized that—well, you know, those senior engineers are actually doing things that are really important, and they're very busy. And then, you know, now I've moved into being a manager, and I realize there's a ton of work there too. I feel like I'm just kind of busy all the time. That's a pretty—you know, I guess that's one dimension of looking at it just in terms of busyness. But in general, it's as you kind of go through that job, go through your career, you kind of are exposed to the bigger and bigger picture. And sometimes there's people want to really rush ahead, but they could actually rush like so far that they end up kind of like collapsing under their own weight. So they get some role that's just way too—requires like way too much experience and the right kinds of experience and things like that. And I was talking to somebody a while back who was kind of in that position, and they were trying to figure out how to get sort of the next promotion as quickly as possible, and they didn't realize like that they were already kind of in this kind of bad position. And it's kind of an example where ambition can kind of blind you a little bit. What do you think? Have you had people—like that? Have you been like that? And how do you—how do you sort of deal with that, Patrick?

0:04:19.382 --> 0:05:40.360
<v A>I mean, I think part of it—I remember being like, I guess you're pointing out part of it is like when you first start off and you think like, oh no one above me doesn't know all these new things I know coming out of school. And then you learn—my more recent bent on it has been a little bit like building up your gut feel that like there are a lot of things that you don't know whether a certain approach is going to be too fast or too slow, and you don't want to become inflexible and say, 'Look, I did it this way before, and it didn't work; therefore, it'll never work.' But at the same time, you need to feel for like where hidden complexity might lie or what are the most important parts to test if you're going to build a proof of concept of something. And building up those things over time. And I think what you're sort of indicating is like young people don't—or young people junior to a new skill, you don't always—you can't always appreciate what's happening above you. You only know that it's like beyond your scope, and it can look really bad to have that blind ambition where you say, 'Look, I just want to be promoted; I know everything. I'm excellent at my job,' whereas the people above you are going—well, it's clear you're not.' Because you really can burn bridges. Yeah, that's true. So yeah, I mean, I have seen this. I think it's important to—I guess one of the concepts is like 'manage up,' because sometimes it's hard to know if your manager doesn't know what they're doing or you just don't know what they're doing. Both are

0:05:40.484 --> 0:05:43.032
<v B>possible. It's a really good point. It's a really good point.

0:05:43.032 --> 0:05:45.023
<v A>both are possible. And oh sorry, how do you?

0:05:45.420 --> 0:05:55.806
<v B>how would you know if—you think how would you know if you're ready for the next level? Do you would you just go and ask your manager, 'Am I ready for, you know, the next step?'

0:05:56.211 --> 0:06:25.962
<v A>will not answer your question and answer a different question. So I think to me this is one of the reasons why I think it's important early on to move around a lot—like both within your current company and to some extent change—like don't be afraid to change companies. You don't want to do it too often, but too little is also dangerous. And part of that is every time I've ended up a new company, I always think this like, 'What am I going to do? Oh, I don't know anything. How am I ever going to be productive? Why am I not getting work assigned?' But then it always ends up working out, and I think it's sort

0:06:25.962 --> 0:06:26.920
<v B>of that. That's so true.

0:06:26.920 --> 0:07:23.185
<v A>I think it's related to what you're—what you're kind of asking like how do you know? And the answer is, you never do actually know. Um but it like it kind of tends to work out, and you try to find someone who seems to know what's going on. So I also recently have, you know, started to do more kind of manager tasks and, you know, try to communicate to people that, 'You know, hey, this is what I—what I think it means to grow into your role.' And seeing people—one of the ways is seeing people come to a person and ask them for help, not a person offering their snide advice or just doing, but actually people coming in like genuinely wanting assistance in something. Yeah, and I think that's a good sign when you—when people come to ask your opinion on something, and not just like in a formality, but like they seem to actually want to engage with you because they think you're helpful to their problem. That's a good sign you're growing, right? And that you are probably coming ready for the next role, but I mean, you never do know, right?

0:07:23.775 --> 0:09:16.720
<v B>Like that's right. Yeah, it's always, and the thing is, the dynamics change too. So for example, it could be—you know, let's say you start a company and find some great product-market fit, and the company is a roaring business. Well, then maybe you could be a manager, a director; you could be anything. And the world is your oyster, right? But then things could go completely south, and then maybe even being a manager is really hard. You know, I think another thing too is—so okay, there might be, you know, when I was a junior engineer, I would get really upset when things didn't really work out, especially if it wasn't my fault, right? So when things are sort of unfair, or when you work really hard and then for other reasons the project falls away—like maybe the contract negotiation broke down before the contract was signed, the whole thing gets canceled, right? And that stuff used to really frustrate me. But now think about this: let's say you're a Director of 200 employees at any given time. One of those groups of people, one of those teams, or at least one of those employees is having some kind of crisis, like that. And your job is to basically deal with all of these crises simultaneously, and it just never ends. It's just there's always a big problem, and as soon as that problem is fixed, there's another problem somewhere else. And so that's one of the things I realized recently—or I guess later on in my career—is that yeah, the Director is just kind of on fire all the time, and they have to be someone who can kind of jump into different roles. So at one point, my director was acting as a first-level manager to a team that where the manager had quit. Um, and so you

0:09:17.091 --> 0:09:20.027
<v A>have to be able to jump into that role, and at the

0:09:20.027 --> 0:10:07.362
<v B>same time deal with—you know—crises across I don't know ten, eleven other teams that could just spring up at any time. And all of that requires almost like encapsulation to kind of draw it back to technology. It's like encapsulation where you know you might know about Assembly code, and you might learn about C code, and you might—or maybe you can go learn that electricity and then like capacitors and things like that, and it all kind of builds on itself. And so the Director can deal with all these crises because none of them really affect him that much because he's experienced a lot of other crises and things like that. And so that's—that's really been eye-opening to kind of see that that role actually is really hard, and it's actually it's not that fun. So but

0:10:07.412 --> 0:10:41.399
<v A>I think also ambition can apply to even just technical growth or whatever, like taking on a coding problem or challenge or architecture you're not ready for. Can that be a good point to bite you? Right? So if someone says, 'Hey, I'm going to need this in a week,' and you're like, it's an opportunity to say, 'Hey, I'm going to tackle that.' But if it's more than you can chew, like you also be careful because you're spending some amount of whatever invisible credits to kind of like take that task on. And if you aren't able to return back more than the credits you spent, then that's sort of a net loss for you. So if you—that's okay. Yep.

0:10:41.820 --> 0:11:19.975
<v B>No, totally. One time I ended up—I was tasked with writing a DSP, and you know me; I know nothing about C or low-level really anything. And yeah, it was in hindsight, I mean, it was a very poorly assigned task. But you know, I realized I was just way over my head, and it was extremely frustrating. And yeah, I think it's one of those things where—where I guess as a manager, you have to sort of assign people the right tasks and be on top of that and things like that. But but you also as an individual contributor, you have to be able to say like, 'Okay, this is kind of beyond.'

0:11:19.975 --> 0:11:21.662
<v A>me. I need help.

0:11:22.480 --> 0:11:25.409
<v B>You should be able to like sort of swallow your pride and things like that.

0:11:25.830 --> 0:12:32.706
<v A>I think this comes a lot into interpersonal communication as well. So like when I'm—when you're—when you're sort of describing this, one of the things is knowing like when to ask for help versus when to just figure it out. Yeah, and like falling behind on something and not telling your manager becomes like a problem. If you end up like, 'Oh, if you just told me a week ago, I could have helped you out,' or 'We could have changed something around.' And so trying to like read the situation and like monitor how other people are viewing things or how loaded their work is—I mean, I think a lot of this comes down to that, right? So if you fail on something, but if you hadn't tried it, no one else could have tried it either. That's not a big deal. If you took something that someone else easily could have fixed and you sort of like take too long and botch it, then that's—that's a problem. That's more of a problem. And no one's going to actually tell you which things align to your skill set best as well as you can do for yourself. And some of that you also have to like kind of read the room, like see how other people are feeling, what they're doing, and ultimately make sure you're on a good team which has opportunity growth and people are willing to let you sort of fail a little bit without coming down on you.

0:12:33.111 --> 0:12:54.964
<v B>Yep. Yeah, it totally makes sense. Yeah, definitely stay in a lot of communication and don't feel bad about just saying, 'Look, I don't know how to do this.' Cool. All right. And also yeah, I guess—yeah, your manager you can be just—I mean, depends on the manager, but you should be able to be just completely transparent with them, and don't hesitate to go to your manager and say, 'I want to be—I don't know.'

0:12:54.964 --> 0:12:56.500
<v A>Principal Engineer tomorrow, but then

0:12:56.780 --> 0:13:10.472
<v B>Also, you know, take your manager's advice very seriously when they say, 'You know, this is where we think you're at.' And yeah, I think ambition is good if you use it in the right way. All right? You want to jump into news sure. So,

0:13:10.472 --> 0:15:06.080
<v A>My first one is an article—okay, I guess a GitHub repository of Jupyter notebooks or IPython, and it's in GitHub called Common Common and Bayesian Filters in Python. We'll have a link in the show notes. There's not a catchy title to this one, sorry. But two things, or a couple things that are interesting. So first of all, I didn't know that this was a thing on GitHub now where you can click the .ipynb IPython notebook; you can click on one of those in a GitHub repository, and it'll actually like load it up for you. Yeah, it's not amazing, that's pretty cool. I'm not a—I'm not the biggest Python person, so maybe everyone else already knew this. But the second thing is if you've never come across Common Filtering or just Bayesian filtering in general and what that means. Jason mentioned DSP work. If you do embedded processing, if you're—I mean, it actually comes up in lots of different things if you're taking mostly I guess observations of the real world where some whatever you're using for your sensor can be noisy. I think we've probably talked about this a little bit before, but whenever you're sort of taking a measurement and that measurement is prone to some amount of error, and you want to have an understanding about what your belief of the real value is as you take these samples over time. So an example is if you get a GPS coordinate off of the GPS antenna in your phone—that is some error in it. That error kind of moves around over time. So if you keep your phone in one spot and you keep reading samples over time, over time all of the samples average out to, you know, probably very close to your location with maybe a much smaller bias than any single sample. But what do you do if you're also moving? Like what if your phone's moving? You can't just sort of like accumulate all the samples for a minute and then average them; you'll get a really bad answer. And so, right, common filter is a way of sort of

0:15:06.080 --> 0:15:25.354
<v A>taking those describing statistically how to sort of take those measurements and use a Bayesian update process and like kind of update your belief. So you take a measurement, you input the measurement into your sort of model, and then you update the model to reflect that new measurement, and then you get your sort of new estimate of where you

0:15:26.114 --> 0:16:07.845
<v B>are? Yeah, the biggest thing about the reason why common filters are important is that they handle the covariance right. So for example, you know, you could have a set of numbers and just take the last—let's say there's just one signal. You could just take the last thousand samples and average them, and you're done. But then the issue is what if there are two signals? And what if they relate to each other? So when one goes up, the other one also goes up, or when one goes up, the other one also goes down. Then that relationship—you should be able to take advantage of that. So if one is going up, you shouldn't have to collect the average to know that the other one's going to go down. And that's what the common filter

0:16:08.149 --> 0:16:45.257
<v A>does. Um so these are enormously powerful. They come up in all sorts of use cases and examples. And um this GitHub repository, I guess, is sort of like an interactive book. Um and I didn't go through all of it. Um but I went through a little bit of reading it and trying, you know, looking at some of the first chapters, examples. Now that was a really good descriptive way of doing it. This is a really complex topic. It took me many tries at trying to understand common filters before it sort of clicked. I guess this isn't really my background or my area, so maybe that's my excuse, or maybe I'm just really bad at this stuff. Um well, common filters actually depends on a lot of knowledge, and

0:16:45.460 --> 0:16:55.467
<v B>and to jump right into it—I mean, without like a background in Bayesian stats and stuff like that, it's a challenge. I mean, yes, I have not probably had to cover a lot of a lot of

0:16:55.855 --> 0:17:32.085
<v A>background. So I thought this was pretty—maybe I'm somewhat tainted by having tried it a couple times, but it seemed pretty good to me. I like the presentation. I like the style. I like the way they were sort of describing it. I didn't make it through all of the chapters. It gets pretty complicated into Unscented Kalman Filters, Extended Kalman Filters, Particle Filters, you know? It sort of gets to some pretty advanced topics, so I didn't make it all the way through. But the sort of beginning stuff with that was really useful. So I know this came up as early as college where there were times I kind of would have liked to know what these were and I didn't. So if that's you, I encourage you to check

0:17:32.507 --> 0:19:27.060
<v B>it out. Cool, that's awesome. Um yeah, so my news is Distributed Consensus Revised. That's a mouthful. So basically, um okay, so consensus is imagine you have a set of machines and they all have one—that they're all or let's say they're all storing a number, and that number right now is one. Um and they all want to increment that number. Um you know, that could create some real challenges, right? Because you could kind of fan out this request. So let's say a machine fans out the request and says, okay, now the number is two. Um all the machines start doing that. Let's say that all happens at the same time. So everyone tells everyone else, okay, yeah, the number is two now. So then now everyone has two, but that's not right what they should have, you know? If there's let's say 100 machines and it started out at one, it should be 101, but now everyone has two, right? So uh or let's say it gets—you know, that's let's say you have a case where two machines both want to change that number. One wants to set it to three, one wants to set it to five, and a third machine gets both of these requests. Well, what what should it do, right? So imagine, I mean, this happens a lot in the real world. Let's say you—um let's say you're on Amazon and you add something to your shopping cart, and let's say someone else, maybe even another country or something, adds the same item to their shopping cart. There's only one of those items, right? But you're both talking to different machines, and each of those machines like there has to be some resolution there, right? Now you can't of course if you had just one server that'd be relatively easy, but that's not practical. You can't run Amazon on one server. So you have to handle this problem where there's this sort of conflict, like somebody has to win, right? So if you have a database with hundreds of machines and you have two machines that are both

0:19:27.060 --> 0:21:06.800
<v B>saying I own this item now, or this person—this person owns this item now. And that starts spreading some of those machines are going to get, you know, a double count here and they have to figure out what to do with that. It's extremely hard problem actually. Um and you know there's there's a lot of research that goes into it. Um it's going to be hard to sort of dive into all of it, but hopefully have motivated you enough to read this article. The article is great. It's not um, you know, the research paper or anything like that, although it has a link to it, but it's really a blog post from somebody who's trying to walk people through how that all works. Um it's pretty fascinating. Um in my head I'm trying—I'm trying to figure out an easy way to explain it. You really can't. Um you can imagine how hard that problem is. Uh part of it has to do with um, you know, there's sort of a democratic aspect to it where if you have a majority, that majority tries to like dominate the other one. Um there's a process called leader election where you try to elect a leader and then whichever result that leader gets first um becomes the right one. So there's there's one machine who's the leader. If that guy says that you bought the shoes, then that other person's request, you know, gets gets canceled like Amazon has to revert, has to undo that purchase. But you get it? You're in um and so then you know you have this now meta problem: how do you elect this leader? The whole thing I think is super interesting, very complicated. I mean, you have to do latency in the network. You know, you send a message, but it doesn't get to the other person right away. It might not even get to them at all. And the article is part one of a series that kind of walks through all of that. So

0:21:06.800 --> 0:21:35.828
<v A>yeah, I guess this is the normal algorithm people use. Here is Paxos, is that right? But then there's like a simpler version, Raft. And yep, it's like I vaguely read them a couple times and it's like I see the gist, like at the level you sort of suggested that there's latency and dropped messages, and the network can be sort of subdivided and then reunited later, and you need to make sure like that decisions can be made and that everyone eventually agrees on those decisions. Yeah.

0:21:36.132 --> 0:22:35.920
<v B>Yeah, exactly. Yeah. So so they made Paxos, and the original. So ZooKeeper is definitely the most popular open-source library for this. ZooKeeper is basically a little key-value database, but all of the keys and all of the values are replicated. So every node has a copy of the entire database, which is why you can't be that big. Um but it's all—it's all kept up to date. And um in the beginning they use Paxos, but the issue with Paxos is um it's, you know, when you deal with the real world like theoretically it's great, but once you go into the real world or latency and networks that can drop out and things like that, it just had huge limitations. Um like you would just never reach consensus. And so you have to have some hacks. Um and then over time those hacks got more and more refined. They developed some really solid kind of mathematical bounds, and then the hacks became basically a better version of Paxos, and that's Raft.

0:22:36.848 --> 0:23:33.025
<v A>Cool. My next—I guess I sense a little bit of a theme to this week's, this month's articles. Um my next one is this actually came out a while ago. I saw this on Hacker News, um but I don't think we've talked about it, and I think it's pretty cool. This is HN Academy, and what it does is looks in Hacker News posts for Coursera courses or edX courses that are talked about or suggested as like ways to learn about something and aggregates them sort of over all time, over the last month, over the last year, and indicates like things. So when you go to a site like Coursera or edX or one of the other what is it MOOC—MOOC? Um then yep, then you know you end up with this giant list of things. It's like I don't know where to start. Which one of these are good or bad? I've done some before. I was like, oh, this really feels like someone with a VHS camcorder in the back of the room just kind of like it's cool that it's

0:23:33.025 --> 0:23:37.665
<v B>there, but I'm not clear. I'm learning anything. Um and then other times like, oh, this is really well done.

0:23:37.784 --> 0:24:14.520
<v A>so I think this is a good starting point for trying to filter those down to things which are which might be useful or practical. So there's some pretty good stuff in here including things we've talked about before. So like from Nand Gate to Tetris is on here as a course. There's Jazz Improvisation from the Berkeley College of Music. Oh, that only had one citation. Okay, well, that's not that popular, I guess. Um learning how to learn Quantum Information Science. You know, kind of list them out. It's it's an interesting thing if you're nothing more than just a kind of cool courses to check out if that's something you're into. Cool.

0:24:15.027 --> 0:24:23.414
<v B>That sounds awesome. So is this—is this like a meta, like an index of mooks? So it's like at the end it's going to point to one of these.

0:24:23.414 --> 0:24:40.322
<v A>Things. This is a new trend, I guess. I don't know exactly what it is, but the awesome lists or whatever. Oh yeah, I don't know. Maybe I've missed the meme. I don't—I don't exactly understand what they are, but I see those occasionally pop up where someone sort of makes like a giant list of resources. I would view it kind of like that. Yeah, yeah.

0:24:40.727 --> 0:26:30.280
<v B>That makes sense. I think I call them 'listicles' because, like, articles. Okay, clever, I guess. All right, cool. So we actually have something new. I'll talk about it briefly: a new part of the show. You know, we have had over the years many people email us asking us to basically talk about something that they're interested in, and they wanted to sort of sponsor that discussion, right? And it's been everything from people like—I'm not going to name any names—of people trying to get us to talk about soda, like literally soda. There's been everything from that to things which are really, really interesting and actually to the point where some of the times we've even just said, 'Hey, you know, we won't do a sponsor discussion.' But why don't you come on the show and talk about it? Spend a whole show with us. And some of our best shows actually have come out of that. But there still have been people who they want to sort of get a message out, and it's actually a really cool message, but it's one that we didn't find organically, right? So what we're going to do is we have this new area called Sponsored News—Sponsored News Link. And so this is going to be something that we're generally interested in. We're not going to try to fill this with anything. It's going to be something that we see and we're like, 'Wow, that's really cool. People should know about that.' But you know, total transparency: that's something that was presented to us. So, kind of keep that in mind. So our first ever sponsored link is the O'Reilly Open Source Software Conference. So this is pretty cool. Have you ever gone to or had you ever gone to a conference before you started working, Patrick?

0:26:30.280 --> 0:26:35.000
<v A>Gone to a conference that wasn't only a part of my company's conference?

0:26:36.051 --> 0:26:45.130
<v B>Really? Wait, seriously? Yeah. Wow. So you've never gone to like—I don't know, like just a generic like C++

0:26:45.130 --> 0:26:48.454
<v A>Conference? CPPCon? Nope, never gone, or just like a conference?

0:26:49.180 --> 0:26:53.247
<v B>That had like—yeah, SIGGRAPH? You ever got SIGGRAPH? So I've never gone.

0:26:53.247 --> 0:26:59.160
<v A>To like a research conference? I've never gone to. Seems like no. I just was thinking about that. I've never done it.

0:26:59.160 --> 0:27:04.907
<v B>what about like a trade show like if you worked on a product no that product really okay so i mean i've gone to

0:27:04.907 --> 0:27:10.459
<v A>Stuff where it's like my company was hosting a bunch of people from the company to talk about the company? That's I've been to, like that.

0:27:10.459 --> 0:27:38.202
<v B>Before. Yeah, right. That makes sense. Okay. Well, I have been to a lot of conferences. I'm a conference-aholic, um and I've got to everything from actually—I mean, just this month I went to the Spark AI Summit. I went to—I'll be going to a conference at Netflix on Friday. And there's even another one. Oh yeah, there's a VMware AI like a summit anyways.

0:27:38.880 --> 0:27:41.037
<v A>I go to a lot of conferences. It's cool to.

0:27:41.037 --> 0:29:38.780
<v B>Talk to people, see what they're doing. There's typically like a vendor area—so that's people who have booths set up, things like that. There's a Keynote Hall, so there'll be one or two big talks where they expect a lot of people to go and they kind of have the right infrastructure for that. And then they have breakout sessions, so at any given time there might be three or four people talking, and you can only really see one at that time slot, and they try and space it out so that not all the, let's say C++ people are talking at the same time or something like that. So Open Source Software Conference is actually one of the longest-running open source conferences. It's been going on for about 20 years, and you can actually if you go with the link that we're going to post in the show notes, you get 25% off admission to the conference. It's a little bit steep if you're not a student, so if you're not a student with the discount it's seven—about $750. Most people can get their company to kind of cover them. In my case, yeah, I most of the time I get the company to cover it. If you're a student then you can get some really nice discounts as well. You can look on the website for information there. And that could be, you know, high school student, college student—doesn't matter. But there's gonna be a lot of industry experts there. There's gonna be folks from Google, like holding Caru is gonna be there from Google, Julian Simon's gonna be there from Amazon. There's gonna be a lot of folks there. Definitely you know check it out. I think conferences are a really good way to learn kind of what the state of the art is. And the nice thing about open source is, you know, I've gone to conferences where folks talked about their amazing system they built and well, we can't have access to it. It's like, 'Here's this great stuff we built,' and it would take you, you know, five people working for three years to build the same thing. But this conference is all open source, so everything somebody says, you can just download it off the internet and try it yourself, which is

0:29:41.305 --> 0:29:42.975
<v A>Pretty cool. All right, and with

0:29:43.178 --> 0:29:45.338
<v B>That time for it is time for

0:29:45.338 --> 0:29:46.350
<v A>Book of the

0:29:46.705 --> 0:30:25.990
<v B>Show. My book of the show is—it's a little bit embarrassing, but I've been listening to Oprah Super Soul Podcast. I'm definitely not the stereotypical Oprah subscriber, but this actually, I was flipping through the news on—I use an app called Flipboard for news, and I generally like a lot of news about like not necessarily self-improvement, but I like positive stories. I like hearing people's success stories. I like especially like entrepreneurs who succeeded. I like reading about their stories. And so over time, Flipboard has kind

0:30:26.310 --> 0:30:27.002
<v A>Of picked up

0:30:27.424 --> 0:30:40.440
<v B>on that. You know, their algorithms or whatever. I've picked up on that, and so I guess that's how it showed me like top and most inspirational podcasts, and this was number one. I thought, 'Okay, let me check this out.'

0:30:40.772 --> 0:30:42.696
<v A>So this is the Oprah like from TV.

0:30:43.050 --> 0:31:43.760
<v B>Oh yeah. Yeah, this is the Oprah. Apparently, she has a number of podcasts I found out later. The Super Soul is just the one that I happen to be recommended in this article. And it's—it's her just interviewing people who are kind of inspirational speakers and thinkers. So like all the stereotypical inspirational speakers have an episode. There's a Tony Robbins episode, there's a Joel Osteen episode, there's you know basically like pick any inspirational speaker that's really prominent, and they have an episode on this thing. There's probably 30 or 40 episodes, and yeah, I've been listening to them. They're pretty fun. I mean, it's really fun to hear a bunch of people's perspective, and some of the stories are really powerful. So I've been having a lot of fun with it. I do have a set of books queued up that I have to get to, and so I'm probably going to do that this coming month, but I definitely binge-listened to Super Soul Podcast last month.

0:31:44.189 --> 0:31:47.496
<v A>Are the production values pretty high on the podcast? Oh.

0:31:47.699 --> 0:32:13.440
<v B>Yeah. I mean, this is yeah, extremely high. I mean, it's very well edited. There's no downtime. They cut out you know even like from the—you could tell that like they're cutting out parts of the interview that aren't that interesting. It's you're not getting like it's not like a Joe Rogan type thing where you get every second; you're getting just the best, let's say 30 minutes out of what might be like a two-hour interview.

0:32:13.440 --> 0:33:14.820
<v A>So I've noticed there's some new podcasts coming out, and to be fair, although we do a podcast and have for many years, I actually don't know that much about podcasting. I know it shows, but or—and I don't like editing the podcast. So I've noticed there's a bunch of things where they do like they'll talk to various people and like have interviews and like cut—it's a whole almost like a very produced TV show versus as you said, I was gonna say like our show or I guess Joe Rogan. I have listened or watched one time when I think Elon Musk was on because it was in the news. Yeah, and so yeah, it's a very sort of like much similar to our podcast, like there's like a rough agenda, but it's just kind of like a free, like a train of consciousness sort of like conversation. And there's these other ones that have come out though that are very much like there's a segment and then they cut to an interview somewhere else and then cut back to this other thing, and you can tell it's out of order and they've stitched it together later almost like a you know talk show would be. And I find—I guess this is becoming like a thing. Man, we were like podcasts are hot again.

0:33:15.297 --> 0:33:23.414
<v B>Yeah, I mean when we were podcasting it, uh, it was like pretty hot and then it this is probably the third wave of it feels like.

0:33:23.414 --> 0:33:24.494
<v A>It's happened a few.

0:33:24.915 --> 0:33:29.489
<v B>Times. Yeah, this is the third wave, and here we are, which is pretty cool. Well, I

0:33:30.535 --> 0:34:35.520
<v A>don't have a podcast to recommend, but I do have a book. Um, the book I just finished reading is Red Sister by Mark Lawrence, who I have not read a book from before, I don't believe. And this is the first book in a trilogy, which the third book just came out this year. And this is a fantasy book, or at least the parts of it I've read are. And again, I always struggle with this, but this is roughly about a peasant girl who has sort of like strange things happening around her and to her, and she ends up in a nunnery—no, a convent, that's what it's called, a convent. Oh, um so she's with other nuns, but there's there's this concept sort of like of old bloods, so there's like these four races that had kind of like magical abilities and people in the sort of time of the books storyline some some people sort of manifest those powers from those sort of like people that came before them.

0:34:35.520 --> 0:34:36.415
<v B>So um in

0:34:36.415 --> 0:35:46.060
<v A>this convent, people have various magical abilities—or no magical abilities—and they just sort of like are in the religion that the book sort of describes. And it's so it's sort of like a magical fantasy book, but I really enjoyed it. It's pretty different to a lot of the other books I've read, but doesn't it? It's a sort of what do they call, like a coming-of-age story, right? Like it starts with a small girl and she's growing up and she's like in school. It's a very, I guess, a common trope, um, but I like that there are some twists to it. So like the world that they're on is being covered in ice. So basically the entire world is covered in ice except a band around the equator of, I think it's like around 100 miles or 50 miles or something. Oh, so the world is sort of like slowly becoming covered in ice, which is causing problems and sort of the past is getting covered up as the ice contracts. And then you learn some information about that and possibilities for the future. And so I've only read the first book, so I don't know how the series ends, but I thought it was pretty good, so I'll I'll give it a recommendation. Not five stars for me, but but a solid four stars. I finished it and I immediately started the second book, so that's a pretty good recommendation, I guess. I haven't finished that.

0:35:46.060 --> 0:35:50.024
<v B>So the ice is expanding or contracting? Uh, sorry, are they—the

0:35:50.024 --> 0:35:57.938
<v A>band is getting narrower, so the ice is expanding. So their sun is dying. Their sun is dying and their world is becoming

0:35:58.360 --> 0:35:59.280
<v B>colder? Oh, interesting.

0:35:59.710 --> 0:36:28.560
<v A>So um but yeah, so there's some interesting things. I don't obviously like all the secrets aren't revealed in the first book of a three-book trilogy, um, but I liked it, and I listened to that on Audible because my commute is long. And um I like I said I already started on the second book. It's when I get to the end, I get nervous. This is how bad it is if I if I see that my book is going to end during my commute. I make sure to download another book so that I don't have to sit the sort of half of a commute not listening.

0:36:28.560 --> 0:36:31.334
<v B>To? No, I'm not even kidding. This is so bad.

0:36:31.334 --> 0:36:43.840
<v A>So when it gets like within an hour of the end, I always make sure to download whatever book I'm going to listen to next, so I make the decision about what I'm listening to next beforehand so that I'm not sitting in the car like I don't have anything to listen to.

0:36:44.513 --> 0:36:50.672
<v B>Oh my gosh. Well, I mean at least you're not trying to download it while you're in the car halfway through your commute, yeah.

0:36:50.672 --> 0:36:52.748
<v A>That would be distracting. Probably, I wouldn't recommend that.

0:36:53.040 --> 0:38:51.280
<v B>Yeah, that's—that's not good times. That's and if you already have an Audible subscription or if you don't want one, you can also help us out on Patreon. You go to patreon.com/programmingthrowdown and help us out on there. We've been able to get a decent amount of advertising out on different platforms to try to get more people interested in the show and things like that. And it's actually really inspiring. We've gotten a lot of emails from people recently who said, 'Hey, you know, just wanted to thank you. I got into the show, and I've been able to do XYZ.' And we really appreciate that. That's cool. That's why we're doing it. All right, time for tool of the show. My tool of the show is Folly. So Folly is a set of C++ libraries. Some of them are header-only libraries; some of them you have to compile, but they do a variety of different tasks. I mean, it's almost like Boost, but like the Boost library, but just different. It does different things. The one that I used which drew my attention to it is Folly Future, which is pretty cool. The idea with Folly Future is in my case I had a set of tasks and those tasks formed a DAG—directed acyclic graph. So imagine you have tasks A, B, C, D. Tasks A and B can run right away. Task C depends on task A, and task D depends on tasks C and B. So A and B runs. B finishes, doesn't matter. Can't do anything yet. A finishes. Okay, now I can run C. C finishes. Okay, now I can run D. And so I had to—I had this DAG and I wanted to execute as quickly as possible, and it's kind of complicated. I mean, you could always poll. So you could sleep the processor.

0:38:51.280 --> 0:40:05.663
<v B>For let's say a millisecond, and then you could check see where you're at, but that's kind of slow and just needed to run at really high scale, really, really large scale. So with this Folly Future library, I was basically able to say you have a set of what are called Promises, and a Promise is basically it's a set of function pointers that are going to get executed when you fulfill the Promise. So in this case, you know, I had a Promise for—I had a Promise for each of my dependencies. So in other words, there's a Promise for A, a Promise for B, Promise for C, Promise for D. And when let's say A finished, then it set that Promise to true for A and then also set the Promise to C for true, set the Promise of C to true, which meant C could run. Then when B finished and it set the Promise for D. And so in this way I didn't have to have any sleep in the code or anything like that; it could just instantly run. Now under the hood, it's doing some type of polling, but it's extremely, extremely fast. No, no, they're letting.

0:40:05.663 --> 0:40:13.645
<v A>The operating system actually has support at like the OS level so it doesn't have to poll; it actually sleeps the process until it gets signaled to wake up.

0:40:14.050 --> 0:40:29.946
<v B>Yeah, that's right. That's right. Yeah, I kind of didn't really—I kind of misspoke there. Yeah, sorry. The operating system itself, no. You're totally right. The operating system itself, like the kernel, is kind of—I guess at some point the kernel is polling or doing some type of, you know, well, it just has a registered list.

0:40:29.946 --> 0:40:54.044
<v A>So it basically sort of think about kind of like a semaphore so it knows that hey when something is pushed into a channel or whatever, like it knows to go wake up that process. Like it has a sort of lookup table and so it knows, oh, you're calling like select is how that works. Like it goes to sleep and says, 'Hey, I'm interested in any one of these events.' And if one of those events sort of fires, it goes, 'Hey, who do I need to wake up?' and like have them execute.

0:40:54.449 --> 0:41:12.880
<v B>Oh, that's all. That makes sense. It's even better than yes and sleeping. Yeah. So so yeah, check out this library. There's a lot more than just features, but—that was the one that I just happened to use right now, but yeah, I thought it was really cool, and if you're doing any C++, I highly recommend.

0:41:13.112 --> 0:41:14.479
<v A>Wait, so

0:41:15.407 --> 0:41:53.174
<v B>Are you doing C++? Now. So yeah, basically actually a shameless plug. I presented at another conference. Speaking of conferences, I presented at the F8 conference, and you could actually go watch me. But one of the things that we're working on is, you know, we do all this machine learning, but then we also want to serve the model. Like at the end, we want people to actually use the model, and so we've built like this serving library that you could run on a phone, you could run on a website, on whatever you want. And so I'm kind of helping out with that. Hey, that's pretty.

0:41:53.865 --> 0:42:17.440
<v A>Cool. Um so the other thing is I said I have used Futures in Java, so I do actually—it takes a while to get used to the sort of that paradigm, but I do actually prefer it for all the reasons you said. It's better than the sort of like wait for this to be done and then move on to the next thing and sort of doing that manually being able to sort of like chain the functions is seems more.

0:42:18.452 --> 0:42:19.769
<v B>Natural. Yep. Yeah, totally.

0:42:21.507 --> 0:42:34.315
<v A>Like that. Um, my tool of the show is again a game because apparently it's the only thing I'm good for. Uh, and this one is one I found very recently: Golf Blitz. So, a word of warning: this is a free-to-play game. So, oh no, if

0:42:34.315 --> 0:42:35.412
<v B>you can't, if you

0:42:35.412 --> 0:42:37.589
<v A>can't deal with that? Like, I'm sorry.

0:42:38.264 --> 0:42:40.052
<v B>Um, well, what do they, how do they

0:42:40.508 --> 0:43:39.040
<v A>make you suffer? No. Okay, so here's the thing. So two things: one is it's a very casual game. Like I don't play in a way that I care. Um, and so I don't actually even know what the—I think the pay mechanism is to like upgrade your character faster. You have to wait. You have to get sort of open these envelopes, and then the envelopes you get like power-ups. And if you want to open the envelopes, you have to wait or pay one of the five kinds of currencies in the game or whatever. I don't know. I don't pay attention to it. All I know is that you play with three other people online, and I normally don't like online games, but you basically are hitting a golf ball, and there's crazy courses where it's a very 2D thing, which is a common trope, I guess, has happened before the sort of like 2D golfer game. Um, so you hit the ball, but it's kind of funny because the balls can collide in air, and you can bump into other people's balls and move them, and the courses resemble sort of like roller coaster kind of like crazy, crazy setups.

0:43:39.040 --> 0:43:45.200
<v B>This isn't 2D? Yeah. Oh, because it sounds like a 3D thing with all the physics or whatever. Yeah, but

0:43:45.200 --> 0:43:47.805
<v A>2D. Um, okay. So, but when you hit the ball,

0:43:47.805 --> 0:43:52.429
<v B>it goes up right? Yeah. Oh, you're saying, but like all the graphics are 2D? Yeah. So

0:43:52.598 --> 0:44:14.569
<v A>it goes. Yeah. So it's all 2D, and the—and the game is like, you know, like level like, uh, you might the hole might be directly under where you're standing. She might be standing on sort of a floating island, and then there's like two islands to either side of your island, and then a line island underneath you. You've lower, and you need to like hit from one to the other, and then from the other back to the middle, and you're trying to be the first one to get into the

0:44:14.991 --> 0:44:15.760
<v B>hole? Okay, all right.

0:44:15.760 --> 0:44:26.061
<v A>And so it's like the blitz part, but there's a sort of a cool down thing. Like once you hit and your ball stops, you have to wait like two seconds before you can hit again, so you can't just like hit, hit, hit, hit like you want to.

0:44:26.061 --> 0:44:27.394
<v B>Be strategic, and so you know.

0:44:27.512 --> 0:45:22.626
<v A>There's some strategy goes into it, and they try to match you with people who are about the same experience level as you. But anyways, I played it as just like a goofy casual game, but you play until, I think you get sort of a certain number. I think you get three points for getting first and two points for second, and I think you have to get what? I don't even remember now, like eight points to win or something. Okay, to win the sort of that collection of matches, but so it's like three or four holes, and it plays in probably two minutes or something, or three minutes. I've never timed it less than five minutes to sort of play like one iteration of this, which is a really good amount of time for me. Like, oh okay, I can sit down, I can play this for like four or five minutes and I'm not hugely invested in it. When I was playing PUBG, I always hated like you would play, you would play for like 30 minutes and you get to the very end, and then you just get shot because like somebody, you know, just it just happens sometimes. But I felt very invested because it was so much time. Then you gotta play.

0:45:22.626 --> 0:45:23.655
<v B>Exactly. And so I

0:45:23.655 --> 0:45:31.350
<v A>this isn't that way, and I like it because of it. It's a sort of very casual game, but yeah, warning: it is free to play. It is on both iOS and Android, though.

0:45:31.755 --> 0:45:52.478
<v B>I will check it out, man. It sounds cool. All right, on to the topic. Topic is terminals and shells. This actually came from a request from a person on Discord who has a Discord name DoubleStep. I'm looking right now to see if they have a real name. No, it's okay. Just

0:45:52.596 --> 0:45:53.520
<v A>use that name.

0:45:53.520 --> 0:47:47.760
<v B>That's good. Yeah. No, in real life there's that's just what their real name is: SecurityCard. Yeah. Um so he asked us talk about terminal emulators. We'll do that, and we'll take it one step further; we'll talk about shells too. How about that? I think it was a good show topic. It's um you know this is one of those things where um I don't know, I don't know if you're in the same boat, but for the longest time, I didn't spend any time at all on tooling, and um a little bit can actually go a long way, like having a decent terminal emulator set up, a decent shell, um learning like the very basic keystrokes, um like let's say you want to do like a find replace, like being able to learn the keystrokes that can actually help a lot in productivity. And with that said, um we'll jump into terminal emulators. So first, we'll kind of let me kind of explain kind of how this whole thing works. So you open up your computer and you type cmd.exe and hit Enter if you're on Windows. If you're on Mac, you know, you you type uh you go to the Quick Launch and you hit Terminal. On Linux, same thing, and a program pops up where you can enter some commands. Um that program, so that thing that renders that border—it's rendering the blinking cursor—that's the terminal emulator, right? What you see is on the surface is a terminal emulator. Now when you hit, let's say L on your on your keyboard, um what's happening there is the terminal emulator program is capturing that keystroke and it's sending it to a shell. Now you might have a terminal emulator that supports tabs or multiple windows, and so it could actually have multiple shells. Um some of them even have uh panes, so you can actually have one window and it's split into two, so the left half of the screen might be running top, the right half of the

0:47:47.760 --> 0:48:45.683
<v B>screen is interactive. Um and so so the terminal emulator might have one or more shells. When you hit L, it finds the right shell—that's the active shell, the one that's that is accepting your input—and it sends your L command to the shell program, right? So when you start the terminal emulator, it doesn't know anything about prompts or file systems or any of that. What it does is it launches a program inside of it called the shell. And what the shell does is the shell is responsible for, you know, connecting you to all those commands. So when you type ls and Enter, the shell has to go and find the ls executable, um you know, run it, um get some kind of output, and then it will send that back to the terminal emulator which will render it on the screen. Um does that make sense, Patrick? Yeah, I actually didn't quite

0:48:45.683 --> 0:48:47.843
<v A>know that, but that makes a lot

0:48:48.231 --> 0:49:47.462
<v B>of sense. Okay, cool. So so now the terminal emulator and the shell are actually talking to each other. Now most of the time it's very transparent. Like you press an L, the terminal emulator tells the shell, 'Hey, L.' And the shell says, 'Okay, let's let's um let's just echo that L back to the person because you know there's nothing for me to do yet; they haven't hit Enter.' Terminal emulator says, 'Okay, I'm going to draw an L because you told me to draw an L.' Um but there's actually a protocol. Now by default, the protocol is a pass-through. You type an L, you get an L. But there are what's called ANSI codes—ANSI. I think I don't know what that acronym stands for, but ANSI is think of it as like as like the protocol. So for example, if you do um if you remember your ASCII codes, you know there's I think it starts at I want to say somewhere in the 20s or 30s. Do you remember what capital A is in the ASCII code? Capital A?

0:49:47.884 --> 0:49:56.322
<v A>is oh man uh I don't know what it's off to my head, but 65 or hex 41. Six oh. Okay, but

0:49:56.575 --> 0:50:04.962
<v B>there's a number of there's a number of codes that that are not um that don't map to anything, right? And so um I

0:50:05.029 --> 0:50:10.024
<v A>think so. 20 hex 20 starts the like printable commands starting with space.

0:50:10.379 --> 0:52:05.360
<v B>Okay, there you go. So before that, there's, you know, there's an opportunity there to use those extra codes to send some special information. And so there's a set of these codes that you can run in sequence, and that's going to tell the terminal emulator, 'Hey, I'm going to do something special.' So these letters that you're going to see next, they're not just regular letters. You need to draw; they're going to be commands to tell you to act a certain way. And you can do a variety of things with that. You can actually move the cursor around, so you could tell the terminal emulator, 'Hey, I want you to take the cursor and move it to, you know, row three,' even if you might be on row 30,000 or something like that. Well, I guess your screen is not that big. If you're on row, I don't know, 20, you just go to row three. You could also change colors. So if you've ever run a shell command or so you've ever run a command line command and it actually displays colors on your terminal, those are special ANSI sequences. So that's part of that protocol the shell is running your program. Your program is telling the shell, 'Hey, you know, send this special code.' And then to turn the text to red, that shell is telling your terminal emulator to do that. Your terminal emulator says, 'Okay, for now on all the letters I see, they're all going to be red.' And then you say 'Hello World,' and then hopefully, if you're nice to the person who comes after you, change it back to white, and then you exit the program, right? There's actually a bunch of really crazy ANSI commands that are supported by most terminal emulators. You can actually render an image to the terminal, which is pretty wild. I mean, imagine it's just in Command.exe and all of a so that's an image shows up. It's actually doable. And yeah, a bunch of cool things that are.

0:52:05.360 --> 0:53:05.457
<v B>Possible. There you can ring the system bell. That's actually pretty frustrating. If you've ever done `cat` on a binary file, what that's going to do is it's going to render all of those raw bytes of data to the terminal. And so that's why if you ever `cat` a binary file and weird stuff starts happening to the terminal, it's because of those ANSI codes. So, you know, it's this binary file is just holding arbitrary data, and your terminal emulator is trying to—sorry, your shell is trying to interpret that and send it to the terminal emulator. Your terminal emulator is just drawing all these weird symbols, and all of a sudden, just coincidentally, it gets, you know, it asks an ANSI code to ring the system bell or to change the color to red or something like that. And so that's—that's why it's usually bad news. Usually your terminal is just hosed if you do that. So that's in a nutshell how that all works. Do you have any questions? So, the terminal emulator.

0:53:05.457 --> 0:53:57.145
<v A>Now I'm going to botch up the part I understand. So the idea is to replicate that this used to be some mainframe, and your computer would send some command over the network link to the computer. So you had like sort of a dumb—not a computer like we have today, but you would have some really dumb electronics that didn't know anything. And so when you typed a character on the keyboard, it literally needed to sort of send the information that that key represented to a computer somewhere else in order to know what to do with that character. And this is why you said that sort of like echo thing. So like it—the idea is like I typed the letter 'L,' and my my keyboard and my screen like aren't connected to each other. Like the keyboard sends the message to the other room, and then it sends back, 'Oh hey screen, you need to print out that letter onto the screen at this location or whatever.' And yeah.

0:53:57.921 --> 0:54:00.216
<v B>Exactly. I mean, that's the history of it. Yeah, and so.

0:54:00.640 --> 0:54:08.181
<v A>So that history evolved into like what you're saying, which is like well now we don't send it necessarily over the network, but you just send it to sort of a local.

0:54:08.586 --> 0:54:10.544
<v B>Running process. Yeah, exactly. You got it.

0:54:10.628 --> 0:54:25.056
<v A>Yeah, and so the terminal emulator invokes the shell as like the first thing it does if that's what you have your environment set up to do. So when you're—you set like what shell you want to run, and it runs that program as the first thing it does.

0:54:25.495 --> 0:54:50.352
<v B>Yep. Yeah, exactly. So the first thing terminal emulator does is it forks. It forks that shell, and the reason why it forks it is if you do something bad and destroy the shell, you don't lose the whole screen, the whole app. And then yeah, just through interprocess communication, it's going to send those letters to the shell, and it's going to get back whatever the shell wants to send it. Okay.

0:54:51.010 --> 0:54:56.528
<v A>So the terminal emulator is like basically all for like handling input and output and rendering the like results. That's.

0:54:56.528 --> 0:55:01.304
<v B>Right? And it's also a shell manager, like tabs and all of that. Oh sure. So okay. Yeah.

0:55:01.641 --> 0:55:04.122
<v A>So it has many different shells. It has to know which.

0:55:04.510 --> 0:55:21.064
<v B>One is active based on if you click over or if you—what is it on Mac? I think it's Command+Shift+[ moves you over to the next tab or something. And so that the terminal emulator has to intercept certain keystrokes, okay, and has to know that that's actually for me, that's not.

0:55:21.064 --> 0:55:35.138
<v A>For the shell and all of that. Okay? So when you, how does it interact? And we'll talk about shells in a second because then it's up next. So how does the terminal emulator interact if you run something like Tmux or something that allow our screen where you—Yep, that makes

0:55:35.138 --> 0:55:36.049
<v B>sense? Like what is?

0:55:36.049 --> 0:55:36.994
<v A>it so yeah yeah

0:55:37.804 --> 0:56:36.141
<v B>So that's—that's a pretty deep question. So by default, no. It's fine by default. Like Tmux and Screen are running inside the shell. So one thing: the terminal emulator and the shell are sorry, the terminal emulator is constantly telling the shell the size of the screen in characters. So if you resize the window, the terminal emulator actually tells the shell, 'Hey, you know now your operating space is, you know, 100 characters by 40 characters.' So the way Tmux works is Tmux knows that size. And so, you know when it renders a bar at the bottom and when you split the screen in half and things like that, Tmux is using that information. But other than that, it's completely living in the context of the shell. It doesn't know anything about the terminal emulator. And same thing for Screen.

0:56:36.141 --> 0:58:33.920
<v B>Now there is a catch. There's a special mode in Tmux called Control Center, which is actually a completely different app. It's just made by the same person who made Tmux. And if you have Tmux Control Center, that only works with iTerm2, the terminal emulator. And that actually uses again uses this ANSI system—ANSI escape code system to send special commands that only iTerm2 understands. So using this Tmux Control Center, Tmux can actually even move the windows around and things like that. So if you wanted to write a program to create four tabs, you couldn't do it because the shell there's no way for the shell to tell the terminal emulator to do that unless you're using iTerm2. iTerm2 has that built into the protocol, but it's not standard. Okay? Yeah. So jumping into terminal emulators, like some of the popular ones, on Windows, you're usually stuck with terminal emulators that were terrible, to be completely honest. There's Cmd.exe and PowerShell. Both of these—I mean, I'm sure I'm gonna get hate mail for this, but let's be honest, these are terrible. These are terrible, terrible terminal emulators. You know, with Command.exe, if you click it, like kind of highlights, but it does this weird box highlighting. Have you seen this? No. So if you—if you want, let's say you have a line that starts from after your prompt and kind of ends in the first or second character of the next line, you can't actually select that text because when you select in Command, it selects like a box. It's like a drag, like a lasso. That's one of

0:58:33.920 --> 1:00:07.298
<v B>the reasons. I mean, there's no tabs, there's no multiple windows. It's just not very good. I don't think it even supports colors. Actually, PowerShell does, but now Microsoft lately has been on an absolute tear. I mean, they have been killing it. Someone kind of—I mean, maybe it's a lot of people attribute it to the new CEO, but they really have kind of swallowed their pride. They know what they've been good at and what they've been bad at, and they went and rewrote an entire terminal emulator from scratch, which they're calling Windows Terminal. I tried to compile it yesterday and I couldn't, but part of it is I don't know what I'm doing. I don't do development on Windows, so I took my gaming PC and tried to build it, and I got stuck. But they are going to release a binary in a few months, and so I'm really looking forward to that. The videos look very appealing. It looks very similar to what we have on Linux and Mac. So I'll talk about those. On Linux, your choices are GTerminal or Console, depending on whether you're using GNOME or KDE. There are alternatives of course—there's RXVT, there's Terminator. I mean, the list goes on and on, but those are the two big ones. If you're on OS X, then you're using either Terminal, the built-in terminal, or you're using iTerm2. I'm a big fan of iTerm2. Which one do you use? Yeah.

1:00:07.585 --> 1:00:08.800
<v A>I do use iTerm2.

1:00:09.280 --> 1:00:42.803
<v B>Yeah, yeah. iTerm2 is in my opinion is much better. Definitely worth the download. As far as other terminals, there is actually a cross-platform terminal called Hyper. You know, it sounds really appealing because you could just learn Hyper and now it doesn't matter whether you're on Windows, Mac, whatever. But it's just not very good yet. It's still a little bit immature. I think eventually that's kind of where things will go. You know, it's built on Electron and all of that, so that seems to be where desktop apps are headed.

1:00:42.870 --> 1:00:44.558
<v A>So keep an eye out.

1:00:44.558 --> 1:00:50.279
<v B>On Hyper. I think the website's hyper.js—sorry, that's the name of it. I think the website.

1:00:50.279 --> 1:00:52.152
<v A>Might be hyper.is, I think, but if you

1:00:52.911 --> 1:00:59.020
<v B>look up Hyper Terminal, you'll find it right away. That might be where things are heading, but it's still a little too early for.

1:00:59.324 --> 1:02:41.451
<v A>So, you talked about the terminal emulator and then it talks to the shell. And so the shell is what's responsible for sort of like doing the things you think about being on the command line. So if you know, like you were saying before, like I typed the letter L and I typed the letter S and I pushed return, that's the shell's job to invoke the program in the file system called `ls` to list a directory. Um yeah, and so if you had a like really terrible shell, it wouldn't know what to do. That, and then also like as simple as that sounds, like I was thinking about this earlier, there's actually a lot that goes into that. So people always talk about like using Linux or getting started or like programming, and I forget how many things you have to learn to sit down and do this. Like, like Jason was, 'Oh, I'm trying to compile this shell or whatever.' And all the things to do. But for me, it—it's somewhat hard to remember now like all of the things. I didn't used to know like you needed to `cd` into this directory and then you need to `ls`, and then there's a path. So if I try to run a program like `ls`, like the shell needs to know where that lives at, and it knows where that lives at because of this environment variable called PATH. But what's an environment variable? How do I change it? How do I set it? And these things are like by convention, somewhat similar across shells, but they don't have to be. So most people are used to running the Bash shell, the Bourne Again Shell, which was the successor to that, just the shell `sh` or the the Bourne shell. Um and so there was a collection of these kinds of shells, and I guess I don't want to say one out because someone will email us and tell us that that's not how it is at all. But well,

1:02:41.772 --> 1:02:45.636
<v B>no there is there is sh and cs yeah that's what i was gonna say so

1:02:45.636 --> 1:04:42.000
<v A>There were CSH, KSH. Um yeah, there's like a whole variety of these all with various ways of interacting, and they mostly work with each other, and I guess there's like some sort of conventions and Posix sort of like guidelines for how to do stuff. But like how to write a `for` loop would be different between them. How environment variables work would be you know kind of different between them. If you did piping between programs—that's like a function of the shell. So if you ever did, like Jason said, if you ever output a binary file, the `cat`, so just `cat` the file and it, you know, sort of prints the whole file to your screen, to the terminal emulator from the shell. It sends all the ASCII characters to the terminal emulator to display them, some of which are ringing bells and some are changing colors or who knows what. Um and so when that interaction happens, if you did like `cat` and then—and Bash and Zsh and a lot of others—there's this vertical line, the pipe symbol, and then you know you did the `wordcount` program, `wc`, and then dash L for count the number of lines. You know, the handling of executing one command taking its output from the sort of the standard out and putting it into the standard end of the next program—like that's the function of the shell. That's what the shell is doing, and how that works is you know like I said sort of by convention and by these standards, but ultimately you could just write a shell that did whatever you want. It could use the dot instead of the pipe command, that might be confusing. Yeah, but it could do that. Um and things might break in various strange ways, and it often does so. If you ever end up running a different shell, sometimes things don't work. So one of the instances is like we've talked about on the show before: Oh My Zsh and the Zsh shell, which actually is pretty old, but Oh My Zsh is a little newer and how it adds a lot of really awesome things, which you can talk about in a second. Um but one of the things is I believe it's how

1:04:42.880 --> 1:05:50.603
<v A>environment arrays in environment variables is different between the two. And so if you have a script would work in Bash and you try to run it in Zsh, you might—how they store arrays isn't a like just `sh` shell level feature, but one of these like it's like a Bash feature that people get used to, and if you try to run it in Zsh, it won't work. Um And you can run into incompatibilities between these two. Um also, like if you run a child shell as part of a command—like you're running a script and it sets environment variables—do those environment variables propagate back up to the parent shell or not? Like all of those things are conventions that sort of end up getting handled by the shell. But it's mostly the interaction between through the terminal emulator to the shell is your ability to run all these programs, either programs you've built or programs that the system knows about, and giving those programs the paths they need—like where the dynamic libraries live. So on a macOS, that would be dylibs; on Linux it'd be `.so`s; on Windows it'd be DLLs. Uh I don't even know people do that in Windows that way, but like and there's other ones that's

1:05:50.603 --> 1:05:51.261
<v B>Like me neither.

1:05:51.261 --> 1:05:53.809
<v A>Setting up that environment is the job of the

1:05:55.834 --> 1:05:56.475
<v B>Shell. Yep, and

1:05:56.762 --> 1:06:45.520
<v A>So that's totally—Oops, that command prompt that you see is another function of the shell. And you know back in the day I didn't know it could do cool things. Um but today it feels like I see people—I go to other people's computers at work and they've got all sorts of crazy things displayed. And some of them are, you know, Oh My Zsh theme; some of them are even just things you can do in Bash. Um But they can show like what Git branch you're on. So mine will tell me if I'm in a, you know, I'm in this Python virtual environment on this Git branch and you know let me know, you know kind of my current state of that window because I have multiple open. Um And that's really useful. Being able to tab complete is super helpful, and one of the things I like about Zsh that I think does work in Bash but it doesn't work as well is the fuzzy matching. So oh yeah, the

1:06:45.520 --> 1:06:47.134
<v B>Fuzzy matching is so much

1:06:47.185 --> 1:06:59.655
<v A>Better. Yeah, I love the fuzzy matching. And also like in Oh My Zsh configured, you know, you can double-tap the tab and it'll give you the ability to use your cursors to select the thing you want to complete to. So yeah. So

1:06:59.655 --> 1:07:48.799
<v B>Just to give an example of this: let's say you—so you know on Linux it's all case sensitive. So let's say you have a folder called, you know, MyPics, and P is capitalized. And so you do `ls mypics`, and you don't capitalize the P. You do `mypics` and then hit tab. It won't do anything because there's nothing there. There's no folder like that. Um I know—no, sorry, with the fuzzy matching it will actually just match it. But now let's say you you do something where um the fuzzy matching matches it but it's not quite what you wanted. So let's say you have MyPets and MyPics, and you do `myp` you hit tab, and you get MyPets. You can actually hit tab again, and it will yeah give you this really cool menu where you can kind of hit tab to cycle through the

1:07:48.799 --> 1:09:48.720
<v A>menu, and that's configurable. Um And you know people have very elaborate configurations and not elaborate configurations. Um But as Jason I guess was pointing out earlier, like spending time on your tooling—like making sure that you have an environment that suits you kind of sometimes feels like a waste. And some people obviously take it to an extreme where they spend they spend more time sort of like making it trickying it out and making it look cool than actual like functionally improving what they are doing. But spending some amount of time and getting something that works well for you really does make things faster, and learning enough shell commands that you know you can get by and get stuff done and do simple scripting really does get you out of a lot of binds because it is often much faster as sort of Jason was indicating to write sort of like a one-line Linux script than to write a Python script that would be really overcomplicated to do. Uh or try to figure out how to do it in C++. I guess. Um All of those would be pretty hard to do, so learning enough of it to get you out of the easiest examples is a desirable feature. But there's other kinds of shells as well. So we mentioned like CSH, um there was KSH. These are ones like I personally never used them before. I've done them like launched them by accident and then realized like I don't know what I'm doing and got out of it. Yeah, I've done that too. Um But I will say the other thing is that if you want to write the sort of—I don't know maybe like the best way, but if you don't know what other people are going to be using, it's often at the beginning of your script you do the—what is that? They call like the shebang, right? Like `#!` and then the program that should execute to launch the script. And if you do sort of `/bin/sh` instead of like `/bin/bash`, and actually make sure your script is compatible with the sort of just the `sh` shell—the kind of simplest shell—then you have

1:09:48.720 --> 1:09:58.160
<v A>more likelihood that it's going to be portable to other things. Um if you don't do that, it's just very likely you end up running it as a Bash script or a Zsh script or whatever your current shell is.

1:09:59.200 --> 1:10:11.457
<v B>Yeah, yeah, that's right. As long as you do that shebang, then even if someone's in Bash but your shebang is Zsh, it'll switch over to Zsh to run the script, and it's

1:10:11.457 --> 1:10:15.186
<v A>possible they don't have that installed because it doesn't come installed on all systems. Yeah, and they'll

1:10:15.186 --> 1:10:16.317
<v B>just get an error.

1:10:16.317 --> 1:10:17.127
<v A>Sure. Yeah, yeah.

1:10:17.346 --> 1:10:21.599
<v B>Yeah, but that's easier than a person runs it and they get some really bizarre error. Yeah.

1:10:21.599 --> 1:11:48.623
<v A>That's I've had that happen a lot. Most people don't actually specify; they just name it .sh and they don't actually do the shebang at the top. Um so be kind. So the other popular ones we've talked about: Bash, which is the default on many—I think it's a default on macOS, I believe is a default on most Linux distributions. Um we talked about Zsh with Oh My Zsh. Sort of like configuration is really nice. The other one I know some amount of people around me use is Fish. Now, Fish is a little different in that it does a lot of really cool things and it's much newer than a lot of the other ones, but it doesn't have full POSIX compatibility. So they decided that some of the things that POSIX chose to do were wrong or outdated, and so they've chosen to break POSIX compatibility and trying to be a more understandable shell. So they try to give better errors; they try to do the thing that's more expected than the thing that's more compliant. Um but I do find that if you're in a shared environment where other people are writing shell scripts that you're supposed to run for like configuring your development environment or something, and you run Fish, you're often going to be having to make changes yourself to get it all to work because it is far less compatible than Bash and Zsh. But the people who use it just say it like it's totally worth it. I've never stuck with it long enough to try, so I

1:11:49.095 --> 1:13:47.997
<v B>can't say. Yep. I'm in exactly the same boat where even things like setting variables doesn't work the same way. I think in Fish you just say let x equal three, but everyone else you just say export x equal three. And um and so yeah, it's just too non-standard for me to get into it, but I also know some people who absolutely swear by it, so it might be worth trying for like a month and then seeing how it goes. Um one thing, if you regardless of what shell you use, if you write any type of script, it's really good to have ShellCheck. So ShellCheck is a program which it's like a static analysis tool for shell scripts. Um so you can get it as like an Emacs package. Um most, you know, if you're using Visual Studio Code, there's a—there's a plug-in; it's very ubiquitous. Um and it will tell you things that are a little bit dangerous, like one of the things that really burns people is um is handling file names. And you know most of the time it's okay, but um you want to be robust, especially if the file names are programmatically generated. Um so if the file name has a dash in it and you don't handle that file name in the right way, you can end up um you know causing some causing some issues. Um it's like for example, you try to remove the file but it's actually if the file is like, you know, uh you know json-r, you remove the file and then it interprets the dash r as a switch, and then it removes like everything in that directory, and there's just like weird things that can happen there. Um and so you have to be good about sort of escaping the strings correctly and things like that, and ShellCheck will like be very clear about it. You'll just say, 'Oh, you know, use the double quote; it should be a single quote here.' Um things like that because there's a lot of nuance there, and I definitely don't claim to be an expert, but I rely pretty heavily on ShellCheck to uh just make sure it's doing the right thing. I

1:13:48.419 --> 1:13:51.591
<v A>didn't know about that. I am going to be doing that, trying that out tomorrow.

1:13:51.810 --> 1:13:56.940
<v B>Cool. Yeah, you can ShellCheck your entire repo. I bet you'll find hundreds. I don't think I'm

1:13:57.717 --> 1:14:00.045
<v A>gonna like what? I might. Yeah. No, I mean it's only—you

1:14:00.383 --> 1:14:50.320
<v B>have to have special characters in the file name, which is very rare actually. Dash is not that rare; dash can easily happen. Um but some of the other ones are pretty rare like star asterisk and stuff like that. Um but yeah, that's those are terminal and shell. So um double step. I hope you enjoyed this. This um this is a great suggestion, actually. Thank you for for suggesting this. Um we had a set of—I mean, we have a list of ideas, um but but that one was just immediately really useful, especially it was timely because the Windows Terminal was just announced May 2nd. So um thank you for that, and uh thank you all for listening, um supporting the show, and all of that. If you're new, welcome. This is a good episode just to to join the to listen to for the first time, and uh we'll catch you all next month.

1:14:54.265 --> 1:15:25.520
<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 share alike and kind

