Programming Throwdown - Terminal and Shells
Episode Date: May 21, 2019Hey all!! Ask and ye shall receive! Someone in the Programming Throwdown discord suggested that we cover terminals and shells, so here we are! Despite sounding simple on the surface, there's ...decades of complexity around terminal emulators and system shells. Patrick and I unpack this and more in today's episode! Thanks so much for all of your emails and support on Patreon! It's your enthusiasm and financial support that enable us to teach so many people, and we are eternally grateful for your support! Show notes: https://www.programmingthrowdown.com/2019/05/episode-90-terminals-and-shells.html ★ Support this podcast on Patreon ★
Transcript
Discussion (0)
programming throwdown episode 90 terminals and shells take it away jason hey everybody um
yeah i have an interesting intro topic. Basically, this is something that actually
happened a while ago but 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 until 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 sort of driving to kind of push themselves in some direction.
Like they want to have more responsibility. They want to, you know, be, they want to do more, like work more hours if you're working
hourly, things like that.
And there's a lot of different reasons for this, right?
Someone might want to make more money.
Someone might want to, that seems like most obvious, but that's only one of maybe
at least 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 kind of reasons for um ambition there's probably others as well
and they're not inherently bad things i mean i think that that's sort of what drives a lot of people but where it becomes a problem is when when people
don't recognize um like they just don't know kind of where they're at and this is one of those
things that i i uh like looking back on my career this is one of the things that i didn't have a
good sense of either so like when i was a junior engineer i 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 who, you know, wrote like mass emails encouraging other people, you know.
And then and then I became a senior engineer and I was doing all these design reviews.
There were problems like if there were problems. Like if there
were, if there wasn't good unit test coverage and then that caused an 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, et cetera, et cetera. And that all took a lot of time. And so that was less time that I
spent writing code. And so I realized that, you know, that 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, really rush ahead, but they could actually rush like so far that they end up kind of like collapsing under their own weight um so you get some role that's just just way too uh 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're 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. And 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?
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 oh no one above me doesn't know all these new things i know coming
out of school and then you learn i i my more recent uh bent on it has been a little bit like
building up your gut feel that like there's 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
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 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 um both are possible that's a really good point
it's a really good point both are possible and oh And how do you how would you know if you think how would you know if you're ready for the
next level?
Would you just go and ask your manager, say, am I ready for the next step?
I 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, 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 of, that's so true. 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. 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 um 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 code reviews but actually people coming in like
genuinely wanting assistance in something um 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 becoming ready for the next role, but I mean,
you never do know, right? Like that's right. Yeah 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 you 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. I think another thing
too is, so okay, there might be, 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, you know, the contract was signed and 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, right? 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, you know, 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,
you know, 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 where the manager had quit. And so you have to be able to jump into that role
and at the same time, deal with crises across, I don't know, 10, 11 other teams that could
just spring up at any time.
And all of that requires, it's 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 they 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 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 uh 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 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's a
bite you right so if 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 uh whatever invisible credits to kind of like take that task on and if you aren't
able to you know 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 no totally one time i 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, in hindsight, I mean, it was a very poorly assigned task.
But, you know, I was just way over my head.
And it was extremely frustrating. And I think it's one of those things 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 you also, as an individual contributor,
you need to be able to say like, okay, this is kind of beyond me.
I need help.
And you should be able to sort of swallow your pride and things like like that 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 uh yeah and like falling behind on something
and not telling your manager becomes like a problem if you 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 um 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 a that's a 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 sort of coming down on you
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 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 principal engineer tomorrow but then also you
know take your manager's advice very seriously when they say you know this is where we think
you're at and uh yeah i think ambition is good if used in the right way.
All right, do you want to jump into news?
Sure.
So my first one is an article,
I guess a GitHub repository of Jupyter notebooks or IPython.
And it's in GitHub called Common Amb common and Bayesian filters in Python.
Uh, we'll have a link in the show notes.
There's not a catchy title to this one.
Sorry.
Um, but two, two things are a couple of things that are interesting.
So, um, first of all, I didn't know that this was a thing on GitHub now where you can click
the dot I P Y N B I Python notebook.
You can click on one of those in a GitHub repository,
and it'll actually load it up for you.
Yeah, isn't that amazing?
That's pretty cool.
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 so an example is if you get
a gps coordinate off of the gps antenna in your phone that has 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 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 taking those uh 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 uh 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 are.
Yeah, the biggest thing about,
the reason why Kalman filters are important
is that they handle the covariance, right?
So for example, 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 column filter does.
So these are enormously powerful.
They come up in all sorts of use cases and examples.
And this GitHub repository, I guess, is sort of like an interactive book.
And I didn't go through all of it, but I went through a little bit of reading it and trying,
you know, looking at some of the first 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.
Well, common filters actually depends on a lot of knowledge.
And to jump right into it, I mean, without like a background and like Bayesian stats and stuff like that, it's a challenge.
I mean, you probably have to cover a lot of background.
So I thought this was a pretty, maybe I'm somewhat tainted by having tried it a couple of 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 common filters,
extended common filters, particle filters. 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 I thought was really
useful. So I know this came up as early as college where there was 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 it out.
Cool, that's awesome.
Yeah, so my news is distributed consensus revised.
That's a mouthful.
So basically, okay, so consensus is,
imagine you have a set of machines and they all have a one.
Let's say they're all storing a number,
and that number right now is one.
And they all want to increment that number.
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.
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, if there's, let's say, 100 machines and it started out at one, it should be 101. But now everyone has two, but that's not right. What they should have, you know, if there's, let's say a hundred machines and it started out at one, it should be 101, but now everyone has two,
right? So, 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 should it do?
And so imagine, I mean, this happens a lot in the real world. 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
and 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? 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 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. And, you know, there's a lot of research that goes into it it's gonna be hard
to sort of dive into all of it but hopefully I've motivated you enough to read this article
the article is great it's not 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 it's pretty fascinating in my head I'm trying I's trying to walk people through how that all works.
It's pretty fascinating.
In my head, I'm trying to figure out an easy way to explain it.
You really can't.
You can imagine how hard that problem is.
Part of it has to do with, 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.
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 gets canceled. Like Amazon has to revert, has to undo that purchase.
But you get it, you're in.
And so then 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 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. the person right away might not even get to them at all and article is part one of a series that
kind of walks through all of that so yeah i guess this is the 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 about at the level you sort of suggested
that there's latency and drop dropped messages uh 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
yep yeah exactly yeah so they made paxos and uh the original so zookeeper is 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 it can't be that big.
But it's all kept up to date.
And in the beginning, they used Paxos. But the issue with Paxos is it's, you know, when you deal with the real world, like theoretically, it's great.
But once you go into the real world, the latency and networks that can drop out and things like that, it just had huge limitations.
Like you would just never reach consensus.
And so you have to have some hacks.
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.
Cool.
My next, I guess I sense a little bit of a theme to this week's, this month's articles.
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 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 and indicates
like things so when you go to a site like coursera or edx or one of the other what is it moocs 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 and I was like,
ooh, 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 there,
but I'm not clear I'm learning anything.
And then other times like, ooh, this is really well done.
So I think this is a good starting point
for trying to filter those down to things
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 Nandgate to Tetris is on here as a course. There's jazz improvisation from the
Berklee College of Music. Oh, that only had one citation. Okay, well, that's not that popular,
I guess. Learning how to learn, quantum information science 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 uh cool courses
to check out if that's something you're into cool that sounds awesome so is this is this like a meta
like a like an index of mooks so it's like at the end it's gonna point to one of these things this is a new trend i guess i don't know exactly what it is but the uh like awesome lists or whatever like 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 like resources i would view
it kind of like that yeah yeah 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. Um, you know, we have had over the years, many people email us,
um, asking, um, us to basically talk about something that they're interested in. Um, and, and they wanted to sort
of sponsor that discussion. Right. Um, 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. Um, um,
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, we won't do a sponsored discussion,
but why don't you come on the show
and talk about, 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.
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're, that, you know, we see
that 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. And so, you know, 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?
I've never gone to a conference
that wasn't only a part of my company's conference.
Really?
Wait, seriously?
Yeah.
Wow.
So you've never gone to like,
I don't know,
like just a generic conference.
Like C++ conference, CppCon
nope never gone to that. Or just like
a conference that had like
yeah SIGGRAPH. You ever gone to SIGGRAPH?
Nope. So I've never gone to like a research
conference. I've never gone to
no I just I was thinking about that
I've never done it before. What about like a trade show?
Like if you worked on a product. Nope.
A product. Really? Okay.
So I mean I've gone to 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 before yeah right that makes sense okay i have been to a lot of conferences
i'm a conferenceaholic um and i've gone to everything from actually i, just this month, I went to the Spark AI Summit.
I'll be going to a conference at Netflix on Friday.
And there's even another one.
Oh, yeah, there's a VMware AI Summit.
Anyways, I go to a lot of conferences.
It's cool to talk to people, see what they're doing.
There's typically 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 about $750.
Most people can get their company to kind of cover them.
In my case, yeah, 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's gonna be folks from Google, like like Holden Carew is going to be there from Google.
Julian Simon is going to be there from Amazon.
There's gonna be a lot of folks there.
Definitely 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, you know,
their amazing system they built
and 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 um but
this conference is all open source so everything somebody says um you can just download it off the
internet and try it yourself which is pretty cool all right and with that time for it is time for book of the show my my book of the show is uh
it's a little bit uh embarrassing but uh i i've been listening to oprah super soul podcast um i'm
definitely not the stereotypical oprah um um subscriber but um this actually, I was flipping through the news on, I use an app 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 of picked up on that.
You know, their algorithms or whatever have 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, OK, let me check this out.
So this is the Oprah like from TV.
Oh, yeah, yeah.
This is the Oprah.
Apparently, she has a number of podcasts uh i found out later the super soul is just the one that i happen to be recommended
in this article um and it's it's uh it's it's her just interviewing um um people who are kind of
inspirational speakers and and thinkers and so like all the stereotypical inspirational speakers have an episode. So like
there's a Tony Robbins episode, there's a Joel Osteen episode. There's a, you know, basically
like pick any inspirational speaker that's really prominent and they have an episode on this,
this thing. There's, there's like probably 30 or 40 episodes and yeah, I've been listening to them.
They're pretty fun. I mean, it's, it's really fun to hear a bunch of people's perspective um and some of the stories are really powerful
um so i've been having a lot of fun with it i do have a set of books queued up
um that i have to get to and so i'm probably going to do that this this coming month
but i definitely binge listened to uh to these the super soul podcast last month
are the production values pretty high
on the podcast oh yeah i mean this is yeah extremely high i mean it's very well edited
um there's no downtime they they cut out you know even like from the uh 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 uh it's not like a
joe rogan type thing where you get every second um you're getting just the best let's say 30 minutes
out of a what might be like a two-hour interview so i've noticed there's some new podcasts coming
out and i 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 um but or and i don't like editing the podcast um so the
i've noticed there's a bunch of uh things where they do like they'll talk to various people and
like have interviews and like cut like 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 uh or watched
one time when i think elon musk was on because it was in the news And so, yeah, it's a very sort of like much similar to our podcast.
Like there is sort of 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 um
and i find i i guess this is becoming like a thing man we were like podcasts are hot again
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 it's happened a few times yeah this this is the third wave of podcasting. It feels like it's happened a few times. Yeah, this is the third wave and here we are, which is pretty cool.
Well, I don't have a podcast to recommend, but I do have a book.
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 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 uh
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,
uh,
uh,
storyline,
um,
some,
some people sort of manifest those powers from those sort of like people that
came before them.
And so,
um,
in 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.
Um,
and it's, so it's sort of like a magical fantasy book um but i i really enjoyed it there it's it's pretty different to a lot of the other books i've read but doesn't 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 uh 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 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 give it a recommendation.
Not five stars for me, 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 guess i haven't finished that so the ice is expanding or contracting
uh sorry the the band is getting narrower so the ice is expanding so their sun is dying
their sun is dying and their world is becoming colder oh interesting 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,
but I liked it.
And I listened to that on Audible
because my commute is long.
And 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 see that my book is gonna 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 to it. No, I'm not even kidding.
This is so bad. So, 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.
Oh my gosh.
Well, I mean, at least you're you're not trying to download it while you're in the car halfway
through.
Yeah, that would be distracting.
Probably.
I wouldn't recommend that.
Yeah, that's that.
That's not good times.
That's and if you 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 dot com slash programming throw down also help us out on patreon um you can go to patreon.com slash programming
throwdown and help us out on there we uh we've been able to get um you know a decent amount of
advertising out on on on um on different platforms to try to get more people interested in the show
and things like that and it's actually really um 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 um um and and you know 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 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 a boost, 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, 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 this DA, and I wanted to execute it as quickly as possible.
And it's kind of complicated. I mean, you could always pull, so you could sleep the processor for,
let's say, a millisecond, and then you could check, see where you're at. But that's kind of
slow, and this 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 promise for B processor C promise for D
and when when let's say a finished then it set that promise to true for a and
then also set the promise to see for true set to the promise of 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, then 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 has to be doing some type of polling,
but it's extremely, extremely fast.
No, no, no they're letting the
operating system actually has support at like the os level so it doesn't have to pull it actually
sleeps the process until it gets signaled to wake up 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 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 or you're calling like select is how that works like it goes to
sleep and says like 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 oh that's how it makes
sense it's even better than sleeping yeah so so uh yeah check out this library um there's a lot
more than just features um but but uh that was the one
that just happened to use right now um but yeah i thought it was really cool and uh and if you're
doing any c++ i highly recommend it wait so are you doing c++ now so yeah basically actually uh
shameless plug um 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
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 this serving library
that you could run on a phone you could
run on um you know website on whatever you want and so uh i'm kind of helping out with that hey
that's pretty cool um so the other thing is i said i have used futures in java so um i do actually
it takes a while to get used to the sort of that paradigm but 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 um and then
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 natural yep yeah totally did like that um my tool of the show
is again a game because apparently it's the only thing I'm good for.
And this one is one I found very recently, Golf Blitz.
So a word of warning, this is a free-to-play game.
So if you can't deal with that, I'm sorry.
Well, how do they make you suffer?
No, okay, so here's the thing.
So two things.
One is it's a very casual game.
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 pay attention to it all i know is that you play uh with three other
people online and i normally don't like online games but you basically are hitting a golf ball
um and there's crazy courses where uh it's a very 2d thing which is a common trope i guess
has happened before the 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 um the the courses resemble sort of like
roller coaster kind of like crazy crazy setups this isn't 2d yeah oh because it sounds like a
3d thing with all the physics or whatever yeah but 2d um okay
sorry but when you hit the ball it goes up right yeah oh you're saying but like all the graphics
are 2d yeah so 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'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 hole okay all right and so it's like the blitz part but there's
a sort of a cool down things 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 be strategic and so you know there's some some strategy goes into
it and they try to match you with people who are about the same experience level as you um but
anyways i played it 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 uh what i, I don't even remember now,
like eight points to win or something.
To win that collection of matches.
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 play one iteration of this,
which is a really good amount of time for me.
Like, oh, 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 pub g 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 exactly and so i
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 is free to play it is on
both ios and android though 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 use that name. That's fine. That's good.
Yeah, no. In real life, that's just a...
That's what their real name is.
It's a security card. Yeah.
So he asked us to 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, you know, this is one of those things where,
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 a little bit can actually go a long way.
Like having a decent terminal emulator set up,
a decent shell, learning like the very basic keystrokes.
Let's say you want to do like a find replace,
like being able to learn the keystrokes back
can actually help a lot in productivity.
And with that said, 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 go to the quick launch and you hit terminal.
On Linux, same thing.
And a program pops up where you can enter some commands.
That program, so that thing that renders
that border, it's rendering the blinking cursor, that's the terminal emulator.
What you see on the surface is a terminal emulator. Now when you hit
let's say L on your keyboard, 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.
Some of them even have 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 screen is interactive.
And 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 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, enter,
the shell has to go and find the ls executable, run it,
get some kind of output,
and then it will send that back to the terminal emulator,
which will render it on the screen.
Does that make sense, Patrick?
Yeah, I actually didn't quite
know that, but that makes a lot of sense. Okay, cool. 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 just echo that L back to the person
because 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.
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, A-N-S-I.
I think, I don't know what that acronym stands for,
but ANSI is, think of it as like the protocol.
So for example, if you do,
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 is, oh, man.
I don't know what it is off the top of my head.
65 or hex 41.
Oh, okay.
But there's a number of codes that don't map to anything, right?
And so I think...
So hex 20 starts the printable command starting with space.
Ah, okay. There you go.
So before that, 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
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 row three,
even if you might be on row 30,000 or something like that.
Well, I guess your screen's 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 sorry, 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, 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, OK, 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 if you're 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 you're just in command.exe,
and all of a sudden an image shows up.
It's actually doable.
And yeah, a bunch of cool things that are 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 an ass an ansi code to ring the system bell or to change the color to red or
something like that and uh so that's that's why it's usually bad news usually your terminal is
just hosed if you do that um so that's in a nutshell how that that all works do you have
any questions, Patrick?
Does that make sense?
So the terminal emulator,
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 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 the idea is like I typed the letter L
and 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 this,
this location or whatever.
And yeah,
exactly.
I mean,
that's the history of it.
Yep.
And so,
so that history of all,
and it's 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 running process.
Yeah, exactly.
There you got it.
Yeah.
And so the terminal emulator invokes the shell as the first thing it does
if that's what you have your environment set up to do.
So you set what shell you want to run,
and it runs that program as the first thing it does.
Yeah, exactly. you set like what shell you want to run and it runs that that program as the first thing it does yep yeah exactly so the first thing terminal emulator does is it forks um it forks that uh
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 um and then yeah just through through inter-process
communication it's going to send those letters to the shell and it's going to get back, um, whatever the shell wants
to send it.
Okay.
So the terminal, I mean, there's like basically all for like handling input and output and
rendering the like results.
That's right.
And it's also a shell manager, like tabs and all of that.
Oh, sure.
So, okay.
Yeah.
So it has many different shells.
It has to know which one is active based on if you
click over or if you, what is it on Mac? I think it's command shift bracket moves you over to the
next tab or something. And so that the terminal emulator has to intercept certain keystrokes
and has to know that that's actually for me, that's not for the shell and all of that.
Okay. So when you, how does it interact 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 sense like what is it so yeah yeah 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 in the shell,
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, now your operating space is 100 characters by 40 characters.
So the way Tmux works is Tmux knows that size.
And so 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.
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 called control center which is actually a completely different app it's just uh made by the same person who made tmux um and and if you have tmux control center that only works with iterm2
the terminal emulator and that actually um uses again uses this ansSI system, ANSI escape code system,
to send special commands that only iTerm2 understands.
And 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, so jumping into terminal emulators,
like some of the popular ones, you know, 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 going to 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 kind of highlights,
but it does this weird box highlighting.
Have you seen this?
No.
So 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 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.
They really, someone kind of, I mean, maybe 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, 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 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, Patrick? Yeah, I do use iTerm2. 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. 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. It's built on
Electron and all of that. So that seems to be where desktop apps are headed. So keep an eye
out on Hyper. I think the website's hyper.js.
Sorry, that's the name of it.
I think the website might be hyper.is, I think.
But if you 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 that.
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 talked about the 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 the command
line so if you 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 the if you had a
like really terrible shell it wouldn't know how to do that and then also like as simple as that
sounds like i was thinking about this uh you know kind of earlier there's actually a lot that goes
into that so um 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 i 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 the 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 born again shell,
which was the successor to that, just the shell SH or the born shell.
And so there was a collection of these kind 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.
Well, but there was SH and CSH.
That's what I was going to say.
So 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 um posix sort
of like guidelines for how to do stuff um but like how to write a for loop would be different
between them how environment variables work would be 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 it sends all the ascii characters 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
nzsh and a lot of others there's this vertical line the pipe symbol and then you know you did the word count program wc and then dash l
for count the number of lines you know the the handling of executing the one command taking its
output from the sort of the 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. But one of the things is, I believe it's how environment arrays in environment variables is different between the two.
And so if you have a script that worked in Bash and you try to run it in ZSH,
how they store arrays isn't a just SH shell level feature, but it's like a Bash feature that people get used to.
And if you try to run it in ZSH, it won't work.
And you can run into incompatibilities between these two 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 the dynamic libraries live so on a mac os that would be dialibs on
linux it'd be so some windows It'd be SOs 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 like setting up that environment is the job of the shell. Yep. And so that totally,
oops, that command prompt that you see, um, is, 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 talk 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 fuzzy matching
is so much better yeah i love the fuzzy matching and also like in in 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 just to give an example of this let's say
you know on linux it's all case sensitive so let's say you have a folder called, you know, my picks and P is capitalized.
And so you do LS, my picks, and you don't capitalize the P.
You do MYP and then hit tab.
It won't do anything because there's nothing.
There's no folder like that.
I know.
Sorry.
With the fuzzy matching, it will actually just match it.
But now let's say you you do something where the fuzzy matching matches it, but it's not quite what you wanted. So let's say you have my pets and my picks and you do M.Y.P. You hit tab and you get
my pets. 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 menu.
And that's configurable.
And, you know, people have very elaborate configurations and not elaborate configurations.
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 more time sort of like making it,
tricking it out and making it look cool
than actual like functionally improving what they're 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 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 it.
Or try to figure out how to do it in C++, I guess.
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, 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
I've done that too
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 it like the shebang, right?
Like pound, pound exclamation point.
And then the program that should execute
to launch the script.
And if you do sort of slash bin slash sh
instead of like bin slash bash,
and actually make sure your script is compatible
with the sort of just the sh shell the the kind
of simplest shell then you have more likelihood that it's going to be portable to other things
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 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 possible they don't have that installed
because it doesn't come installed on all systems.
Yeah, that's true.
Yeah.
Yeah.
But that's easier than a person runs it
and they get some really bizarre error.
Yeah, I've had that happen a lot.
Most people don't actually specify.
They just name it dot sh and they don't actually uh 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 uh
i think it's a default on mac os i believe it's the default on most Linux distributions. We talked about ZSH with the OhMyZSH sort of like configuration is really nice.
The other one I know some amount of people around me use is Phish.
Now, Phish 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 it 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 Phish,
you're often going to be having to make changes yourself
to get it all to work
because it is far less compatible than the Bash and ZSH.
But the people who use it just say it like is totally
worth it i've never stuck with it long enough to try so i 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 it's
like 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 um i also
know some people who absolutely swear by it so it might be worth trying 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 um it's really good to have shell check. So shell check is, uh, a, a program, which it's like a static analysis tool for shell
scripts.
Um, so you can get it as like a Emax, um, package.
Um, most, you know, if you're using Visual Studio code, there's a, there's a plugin.
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 handling file names. And, you know, most of the time it's okay, but
you want to be robust, especially if the file names are programmatically generated.
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 causing some issues.
So for example, you try to remove the file,
but it's actually if the file is like JSON-R,
you remove the file and then it interprets the dash R
as a switch, and then it removes everything in that directory.
And there's just weird things that can happen there.
And so you have to be good about sort of escaping the strings correctly and things like that.
And shell check 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.
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 shell check
to just make sure it's doing the right thing.
I didn't know about that.
I am going to be doing that, trying that out tomorrow.
Cool, yeah, you can shell check your entire repo.
I bet you'll find hundreds of issues.
I don't think I'm gonna like what I find.
Yeah, no, I mean, it's only,
you have to have special characters in the file name,
which is very rare.
Actually, dash is not that rare.
Dash can easily happen.
But some of the other ones are pretty rare, like star, asterisk, and stuff like that.
But yeah, those are terminal and shell.
So double step.
I hope you enjoyed this.
This is a great suggestion, actually.
Thank you for suggesting this.
We had a set of, I mean, we have a list of ideas,
but that one was just immediately really useful,
especially it was timely because the Windows Terminal
was just announced May 2nd.
So thank you for that.
And thank you all for listening,
supporting the show and all of that.
If you're new, welcome.
This was a good episode to join the
to listen to for the first time and we'll catch you all next month
the intro music is axo by binar pilot programming throwdown is distributed under a creative commons
attribution share alike 2.0 license you You're free to share, copy, distribute, transmit the work,
to remix, adapt the work,
but you must provide an attribution to Patrick and I
and share alike in kind.