WEBVTT

0:00:15.572 --> 0:00:23.040
<v A>Programming Throwdown Episode 156: Pearl and Regular Expressions. Take it away, Jason.

0:00:23.040 --> 0:00:31.384
<v B>Hey everybody. I'm sure most people have tried ChatGPT or at least have seen it, and what's that you know heard about it? Oh.

0:00:33.308 --> 0:02:32.480
<v B>My God, so everyone's heard about this by now. Even my parents are asking me about it and everything. So that's how it really reached everybody. And I was looking into it, and I thought this would be really cool if I could use it to scan my email, like I had a bunch of ideas. I also had some ideas of maybe scanning some internal documents at work, but then of course all of my ideas either involve running it a zillion times which I don't want to pay for, or running it at work, which is not a good idea. So yes, so I was looking around at open source and I came across this couple of options. There's one called GPT4All. It worked really well, amazingly well. I was really surprised because when the image thing came out, when DALL-E came out, the open source text-to-image stuff was not good at all, and it's still not really in a good place compared to the one from OpenAI. But this one is awesome, and you can download it onto your laptop or your desktop. It doesn't use that much RAM; it's quantized. You don't need a supercomputer or anything, and you just ask it questions, and it answers you, and it's pretty amazing. Like you just have it right there at your fingertips. I don't think it can run on a phone; I don't think it's that good, but it can run easily on most computers. The thing about GPT4All was when I went to like fine-tune the model, or train a new model, it didn't work. Basically, they have a bunch of config files that they didn't put into the repo, and it's just not in a place—yes, not in a place where you could really train it yourself. At least I couldn't figure it out. Also, I think the repo is—yeah, the repo is literally a week old, so it's not like it's really had a chance to go through its bases. So I found another.

0:02:32.480 --> 0:04:30.790
<v B>One called Stanford Alpaca, and that one had a better repo and also kind of explained how both of them worked. So I'll kind of walk folks through that real quick. If you remember from the ChatGPT episode, you take these large language models, you give the results to humans, the humans like rank them, and then you use reinforcement learning to tune the model to try to return things that people would rank highly. That's really expensive, right? You have to pay all these people to do that. So what these two projects did, which is really clever, is they basically just ask ChatGPT questions and then got their answer. And then they're basically trying to memorize ChatGPT's answers. So they start with a large language model, and they say, 'Oh, when I ask this, I expect that,' and that is ChatGPT's answer. Now, they don't like super overfit to that. So it's like memorizing, but they do that just to try to recover that sort of—like the ML term is bias, but like try to recover that niche that ChatGPT had, right? And it works really well. I was impressed with the Stanford one. You have to download the large language model. I got a bit torrent of it; it was 300 gigabytes, so it downloaded over the night. Yeah, I don't know even—I don't even know why I'm doing this on my personal computer. This is probably never gonna actually work. I think you need like some industrial-strength computer, but I'm going to try it out. The model downloaded over the night, having a chance to use it or anything, but yeah, it's very accessible, way more accessible than the image and video stuff, and I think that's just because text is such an easier medium to operate in.

0:04:31.819 --> 0:05:08.725
<v A>So is the idea like—I mean, I guess this stays like inference, like running it and asking it questions locally so that you don't have to send personal or company data up to the cloud? Okay, I get that. But is it accessible in the way where like I want to fine-tune it on something or have it think more thoughtfully? Like, I guess there's two things: like setting up that problem and how difficult it is to set up—fine-tuning or training data, and then the second thing is actually like do you need six GPUs and a bazillion gigabytes of GPU memory to be able to do those, or can you actually do it on your computer given enough time? Yeah.

0:05:09.636 --> 0:06:13.964
<v B>I mean, I don't know yet. Well, I'm going to have to figure it out. But part one—that asking questions thing is very accessible. Okay. But if you want to fine-tune it, like let's say you wanted to read your internal company wiki and then be in a position where you could ask it questions, like what are the repositories in my company? Like the Git repositories in my company—that is the part that I haven't got to yet. They did say that you need a GPU with like a ton of RAM. I don't remember the exact amount, but it was an insane amount of memory for a GPU. So yeah, I'm not totally sure what's the best way to fine-tune this. Like maybe you take this 300 gigabyte file and you put it on Amazon, and then you know borrow an expensive Amazon machine. Sure, but then that Amazon machine now needs to be able to read your company wiki. Yeah, I have no idea how this is going to work, but I do think that there's something really powerful here. So this.

0:06:13.964 --> 0:08:03.162
<v A>Is the—I mean, like I don't want to say killer because everyone has the next killer app for all of this, but if you could come up with a way of doing this very straightforward, having like internal search so this thing you mentioned. Maybe people aren't at big companies don't sort of have this problem or realize this problem. This is a problem I run into constantly. And you said just like what are our repositories? But listing them is one thing; it's just like there's 5,000 tasks you need to do, but you don't need to do all 5,000 routinely. Maybe your team or sub-team doesn't have that knowledge. So even just finding the team to ask, or maybe they've even gone ahead and put it on the wiki like 'Here's how you set up your account and do all this.' So just asking a question like 'How do I do Task A with Data Set B?' You can't go to Google and type that in because what you need is, like, you pointed out, you need to create an account at this—you know, go to this portal and fill in your information which will create you this role. Then you need to go to this web GitHub clone this GitHub repository and then run this command, and then your computer is authenticated. And you do this asking a person on that team if you could find the right team is actually super straightforward, but finding that team, getting them to answer your call, and then forcing them to like do that over and over again is very difficult. So everyone says, 'Why don't you put it up on a wiki?' They go, 'Well, we did. We put it on this wiki.' But like, you need to know the search terms to put into right what system exactly to find that. Like, it's a—it's a just very difficult subtle problem. And we tell folks on my team constantly, 'Oh, put this up on a web page; put this in a wiki,' and we do, and then we constantly field questions from other teams about like, 'Well, why didn't you put it?' And like, 'We did here.' 'Well, it's not in this form,' or 'it's not linked into this hierarchy,' or 'it's—and it's like, yeah, but how do I find out that you wanted it there?' Like, this is a very, very difficult problem, I would say for large companies.

0:08:03.904 --> 0:08:41.957
<v B>Yep, yep. Yeah, totally right. You know, I think another cool idea here is—you could make your own Alexa. I mean, it's not connected to the internet, so you know it can't do anything like that, but you could make a little Raspberry Pi with a camera—no, a speaker and a microphone—and then you could have a little Raspberry Pi on the somewhere in the living room, and you could say, 'Raspberry Pi, are humpback whales mammals?' or something, and it would just run this GPT4All, and it would just tell you what it comes out. You know, it'd be pretty.

0:08:42.902 --> 0:09:20.010
<v A>Cool. Do you know is it capable? So like one of the things that I actually just don't know, and I've not found a good way to look up, if I ask a question that it doesn't—does it need to already know it in the data it was trained on, or does it know how to reach out, get information, synthesize that, and then riff on that? So as an example, like what's the weather going to be tomorrow? It can't have trained on that, right? Like so it would need to know how to reach out to a service, interpret that, and give me—like does is it capable of doing that? Like it can't if it doesn't have internet access. So but if you gave it—does it know how to do that, or are we?

0:09:20.483 --> 0:10:55.420
<v B>Not there yet, not the open source one. So I think ChatGPT has like third-party apps, like plugins, that you could install. It's not totally clear to me how that works, like how does ChatGPT? So yeah, that's a good example. If you say 'What's the weather tomorrow?' how does ChatGPT know that it needs to query your weather plugin for that? Not totally sure. Like it might be kind of early days there where it's kind of hand-coded, like maybe you look for certain triggers in the query, like old school conversational AI stuff. Like yeah, the kind of stuff we used when we played Zork. You know, like that's probably what they're doing, and they're saying, 'Oh, you know someone asked—you know someone asked the question that has a lot of pluses and divisions in it. Let's send this to the Wolfram Alpha plugin or something.' But yeah, that would be amazing if somehow when you trained it so what you'd have to do to get this right is in the training data, you would have to have—you know, data for that particular plugin. So like right now they give let's say all of Wikipedia to the large language model. Well, maybe they would also give you 10,000 weather queries and then the answer to those queries isn't like regular tokens, like 'The weather is clear,' but it's actually like the answer is some special magic token that when ChatGPT sees that magic token, it knows it needs to ask the weather people for something.

0:10:55.420 --> 0:12:55.000
<v A>Reaching out to the internet feels like a good segue to my first news article. So we'll take this as a first time for News of the Show. My first article that I have is an open letter from—I guess the AI community at large. I mean, I won't name-drop like the specific people; it's not super relevant, but asking for a six-month pause in what they call 'giant AI experiments.' I don't know how you feel, Jason. Maybe you can go in a second, but just sort of reading this article—this isn't my sort of domain, so I guess I would be a layman here, sort of like thinking through the general societal implications here as opposed to the specifics of AI. But asking for a six-month pause in sort of making sure that we're ready and embraced for the impact of the societal changes—in the danger of some of this. I mean, famously, I guess Elon Musk, who had a lot of early ties for OpenAI but seems to now be saying he's not very associated with them and has some disagreements with them, which we won't take into here, but I think he sort of has famously always said that he's worried that there's a very real danger that general purpose AI would pose a danger to society and to humans. The exact nature of which seems to just slide from 'We can mock it for the silliness it does today' to like all of a sudden, you know, somehow all of us are—you know, it figures out how to launch the nukes and we all die, right? But I think this six-month pause is really interesting, just as sort of a thought experiment in my mind, which is like what does that amount to? What is the game theory of, you know, let's say somehow government steps in and enforces OpenAI as a U.S. company and a U.S. government, you know, to stop them? But what about other countries? Doesn't that—like they don't have it's a sort of like the kind of problem, and not to like the nuclear arms stuff, right? Like it's all the or climate change, you know, sort of.

0:12:55.000 --> 0:13:05.325
<v A>Policies. All of these things are can only be whether you agree with them or not; they can only be as effective as the sort of enforcement or number of people who voluntarily sign up, right?

0:13:05.494 --> 0:13:10.500
<v B>That's why it's called global right? Global warming because the whole globe has to participate.

0:13:10.590 --> 0:15:07.686
<v A>Yeah, this is very like what do they call? I guess it sort of gets into tragedy of the commons, like no single country cares enough to stop what they're doing. And in common, okay, this is a side topic. So on this one though, I think this is very interesting, and I was reading some analysis of it by Scott Aronson, who I didn't know—who's the person we've talked about before on the show? Who does a lot of talk about quantum computers and sort of like are the experiments you see coming out are they actually quantum computer or are they classical computers done in a quantum way, like? And sort of some of those nuances there and what that all means, and P versus NP. Anyway, so he talks about all these kind of things. I didn't realize he has been working recently at OpenAI on, you know, AI safety. Um, but he sort of said, in a personal response to some of this, he has some good questions, which is why six months, not six years or six weeks? Like what do we think is like the reason for six months? And just his analysis is like this is a group of people signing on, but everyone actually kind of wants something different. And he had—and I'll steal this story from him—he had an anecdote that he talked to someone he knew from academia who said they signed the letter. And he asked them and he's like, 'Oh no, I completely disagree with the letter.' He's like, 'But I did a bunch of research for, you know, ChatGPT-4, and I like the next, ChatGPT-5 comes out, it ruins my research.' Like, 'I just need six months because that's the time iteration cycle of like getting my papers out.' So it's kind of funny because why that person signed it? And why—I you know, I don't know anything about this. Like, 'Oh, Steve Wozniak signed, you know, this letter?' Like those two people probably have very different like reasons and incentives for signing such an open letter.' So this is an interesting sort of like news article. It's very pressured today for like, you know, all of these things we're saying. Is it—is it really the end? Is it the beginning? Is it a fundamental shift? Or is it another what? A personal 3D TV in your house for like, you know?

0:15:07.737 --> 0:15:18.199
<v A>It's just a fad and it's going to die out. VR is to be seen; we'll see what happens with that, but you know everyone's kind of like pontificating about what the implications of this all is. Yeah.

0:15:18.891 --> 0:17:16.720
<v B>I mean, I would, you know, when this show comes out, it'll be either on Tax Day or very close to Tax Day. So I think I would—I would probably sign it just so that I could get some tax reimbursement from all these professors who won't be working for six months. Like we should get some kind of a kickback. I think yeah. I mean, it's true the six months, you know, there's an interesting historical fact here, which is that countries that try to limit technology—it almost never works. Like I think the one that comes to mind is when China banned the steam engine back in the 1800s. They did it because they had kind of almost like a, you know, we have the taxi medallion system, right? You know, they had a guild for, you know, stagecoach, you know, and wagon transfers and all of that. That was gilded, and the steam engine would completely decimate all of those jobs. And so—so kind of like, you know, for automation reasons, they banned the steam engine. And some people say that it set them back like over a century because the steam engine was just so important to like the Industrial Revolution, which then caused like this like exponential growth in tech. I feel like yeah, that might happen again here. You know, if someone tries to ban this technology, then whoever bans it might end up having a really hard time, you know, recovering from that later. I feel like—I feel like the answer is almost never to pause or ban things but to then build more things. You know, the constructive solution is almost always the long-term solution. I mean, to your point, you know, the six month thing is by definition not a long—not a long-term solution. And so there was a—there was a Stanford, I think Stanford or Harvard, there was a

0:17:16.720 --> 0:17:52.808
<v B>researcher who, you know, using ChatGPT and a bunch of students submitted assignments. They wrote a classifier to classify whether it was written by ChatGPT or not. And so now like, you know, K through 12 teachers can run student reports through this classifier, and they'll say whether ChatGPT wrote it or how much of it—like what's the likelihood that ChatGPT wrote it? And the spread, right? Like did it write all of it? Did it write just one part of it? And so that I think that is really, you know, that entering that arms race is really, you know, the long-term solution. I'll just say.

0:17:53.652 --> 0:18:58.215
<v A>It and then drop it. But you're mentioning of banning the steam engine and setting things back is, I guess like unintended kind of consequences. And there's some analysis too about people sometimes again not to keep doing it but Elon Musk is always railing against short sellers on Tesla stock. And so there's like this equivalent with futures and options on various crops, and some by law are banned from having futures markets on them because they successfully lobbied that it would basically cause more volatility, but in retrospect actually look—there's more volatility in the ones without. Except then doubly look—there's like where and how the distribution is shaped is different. So like you get more very extreme price movements potentially in ones with options, but these sort of like average volatility I'm not a—I'm going to get my over my head here, but like the sort of like over time just the general volatility you see is reduced. It's this is very like it's hard in these like very dynamic systems to predict what small changes will do.

0:18:59.177 --> 0:19:12.407
<v B>Yep, yep, yeah. I totally agree. We'll have to see what happens. I mean, they're up to—what was it? Something like 2,000 signatures? Yeah, 1,800 signatures as of when we're recording, so probably when this comes out, they'll be up to 2,000.

0:19:12.930 --> 0:19:18.195
<v A>Hey, maybe people here it's like the like and subscribe because I'm just getting done. We're not advocating for you to go. Yeah.

0:19:19.225 --> 0:19:37.139
<v B>If you have to pick one, hit the subscribe button, hit the like button on this show. But if you want to do both, go for it. We'll post the link in the show notes. So related to this, I have an article from Vice that says 'AI will Smith eating spaghetti will haunt you for the rest of your life.'

0:19:38.918 --> 0:19:41.635
<v A>Haunt is not the right adjective or adverb.

0:19:42.242 --> 0:20:37.373
<v B>Yeah, it does stick with you though. So, you know, we all talked about DALL-E and we talked about on this show even DALL-E and images that take text and generate images. So you could type in, you know, a dog in a space suit on the moon, and it will generate an image like that. One thing I've done that's really interesting is you can type in things that are abstractions. Like I put in, you know, love wrapped in like swirls of happiness, and then like it's like really interesting to see what kind of images come out of that. But yeah, these are just images. So what's the next level? The next dimension that is time and video. And so someone has made the same kind of thing but with video. The thing about it is it's just you have to watch it. I mean, it can't really do it justice over the airwaves, but basically it just moves in ways that are not Euclidean that really freak you out, and

0:20:38.959 --> 0:20:51.720
<v B>It. You know, you look at the video. So someone put in Will Smith eating spaghetti. You look at the video, and it's yeah, it's definitely Will Smith eating spaghetti. I mean, it's completely unambiguous, but but it's just so odd.

0:20:53.252 --> 0:20:55.581
<v B>Oh man, what was your take when you first saw?

0:20:56.661 --> 0:22:47.513
<v A>That, I guess it's maybe it's like biased by if someone who shares a link tells you this is funny or that this is like horrifying. But it was like funny. And so then when I watched it, I'm like, indeed, this is like very funny. But as Jason pointed out, it takes a minute. In my opinion, it's like you said these concepts—it definitely like oh okay. Will Smith, the famous actor, if you know who he is, you'll recognize, you know? Or even if you don't know the name, you would probably recognize the person. But like it's not really the person, so it's definitely picked up on like the attributes that make Will Smith recognizable. But if you take like a screenshot like his face is distorted in very incorrect ways, so it's like preserving the recognizability but it's clearly not like stitching existing video or it's like hallucinating it right from like a I guess that's like the latent space of anyways. And so yeah, and there's definitely spaghetti, but like the method is very unclear. Like he's not really using his hands or a fork; it's like just going in. Like it's flying into his mouth. Like it has like the spagetti going through his mouth. Like it's amazing. It's just very like if you ask, you know, it's one of those things I always talk about. Like, oh, AI is so dumb, you know? It can't do it. Can't recognize a bird. My five-year-old can recognize a bird. But if you ever hide kids or look at like kid pictures—very interesting what they decide to draw and how they do recognize, like even to this day my kids are older, ask them like, oh, draw a picture of a person. Sometimes they're missing a neck. Like they don't understand like the like what makes a person a person. Or the famous one is—and I saw a clip where like I don't know if they did it often, but a news reporter asked a bicyclist who had just run one a like long race, like the Tour de France kind of thing, right? And they come up with a piece of paper. Hey, in 10 seconds, can you draw a picture of a bicycle? This is someone who spends like their life on a bicycle. Like, draw a picture of a bicycle. And it's actually very difficult for them to like put down.

0:22:49.167 --> 0:23:08.354
<v A>The features that, you know, two wheels and a handle are great, but the geometry, the makeup—and this is not like a person who's never seen one before—is someone who like tinkers hours, you know, weight savings, like all this stuff. And they just like can't kind of get it correctly. And this sort of the same thing here. Like it's trained on these things but it doesn't get it quite right.

0:23:08.860 --> 0:23:45.495
<v B>Yeah, have you ever tried to draw the layout of your house or your backyard for somebody like for, you know, a contractor or anything like that? It's pretty much impossible. Like, you know, it's like you get the general thing, like okay, there's a bedroom and the bedroom connects this other room, and yeah, the bedroom is like smaller than the living room, but then it's like the thicknesses of the walls and stuff. Your house isn't shaped like a rectangle. It's—yeah, yeah, it's like how thick the hallways are or how wide the hallways are, how thick the walls are in between the rooms. It's like we have zero concept of that in our in our mental model. Yeah.

0:23:46.457 --> 0:24:42.449
<v A>It reminds me of if you ever watch like a SLAM video, and when they close the loop. So like SLAM is Simultaneous Localization and Mapping. So they're taking some, you know, camera or LiDAR through rooms, and what you end up with is because it's not a hundred percent accurate in the reckoning that like rooms will be tilted and offset from each other. But then when you sort of like come at it via another path, it sort of snaps into place. And so I feel like what you're saying, it's like if you drew the flow of your house, like the graph connection is probably a hundred percent accurate, like which rooms connect to which rooms, right? But then you need like the shape and like some anchoring dimensions, and then you could probably like deform it into it pretty accurately. But they always say this, like people live hundreds of years in a house and don't realize there's a three-foot gap where like a million dollars is buried in the wall or whatever because you just can't like spatially sort of like tell distances accurately enough to know that there's like some missing space in your.

0:24:43.157 --> 0:24:45.199
<v B>Room. Yeah, that's totally right on.

0:24:46.009 --> 0:26:45.860
<v A>Completely unrelated. My next article, I guess it is images, so we got a theme going. Yeah. So this image is someone posted a robust image compression from an implementation from an old NASA paper. Um I think it was called ICER. Was what NASA had named it. Interestingly when NASA developed stuff—it's like it and I'm going to be very careful, it basically should end up in the public domain because it's paid for by the public, right? I think there are some caveats made for like things that would be military implications or security or sure. But so they develop an image compression, and one of the things that you say, oh okay, so it needs to be if NASA, right? You think like space probes and and um, you know, robots on the surface of Mars and that kind of stuff, so the bandwidth is very limited. And that is definitely true. And it's very interesting to read how these videos and pictures we see get transmitted over time with budgets and allocations, and it's not like you have low speed connectivity all the time. You have like bursts of low speed connectivity and then long gaps. And so sending back initial stuff and then refining it over time, which is very interesting. So the kind of cool part was this person who didn't have a, you know, as far as I can tell, like a ton of background in this wrote a C library for it that implemented this image compression where you can kind of give it a budget and it'll try to do the best they can. But the other thing they pointed out that that I found particularly interesting, probably just because of my background, is that being robust to like dropped packets. So we normally don't think about that. If you like take a JPEG image and you just like zero out one of the bytes randomly or forbid like delete the byte and shrink the file, like you're not going to get an image. You actually just won't get anything. It'll be—you're not going to get a crappy image; you just literally it won't parse. You'll have an error. Your library, your computer might crash. I don't even know what'll happen. Yeah, you know hopefully not. But you know it this is like literally nothing in it. It's just built for reliable assumptions that that all the data is preserved. There might be a checksum, right? So like maybe it'll know that it's not good and and not.

0:26:45.860 --> 0:27:05.520
<v A>Render garbage, but you're certainly not going to get out just like a blurry image. Um and so what I thought was really cool here is thinking about a way of transmitting images or videos, which are sequences of images, in a way where like you don't have any assumption about, you know, packets getting through. Of course, if none get through, you get nothing, but like sure, you know just randomly dropping one.

0:27:05.520 --> 0:27:13.109
<v B>I love the idea. This is like—this is really interesting. I guess like the more packets you get, the more clear it is kind of.

0:27:13.530 --> 0:28:22.499
<v A>Thing. Yeah, and I think it would be cool for if you imagine there's like really low bandwidth radio links. You can get for like—I think what is it? I think LoRa is one of them: L-O-R-A, long range radio, but the bandwidth is very low. So they normally just use for like sensor reading, text message. But it would be cool to say like if you set up a camera at an edge node where maybe you had poor radio connectivity and you wanted to put a camera there and you wanted to like send back an image, but your connection sometimes gets through and sometimes doesn't—doesn't have a ton of bandwidth. I think there's a lot of interesting opportunities there. And it's funny how how we take for gonna. I saw the other day you can go to the store for sort of animal watching, bird watching trail cameras, like get a security camera that you like strapped to a tree that has like a cell phone subscription and it'll like upload when there's motion. It'll like take a picture or a video and upload it over your, you know, cell phone connection plan that you buy, you know? It's not a full plan, but—and it's just like wow. And you just go to the store, right? I think you just go to the, you know, Best Buy or Walmart or whatever, and they have one of these. It's just like this is crazy to me how fast this sort of changed.

0:28:22.870 --> 0:28:37.298
<v B>Yeah, I love how it says this library was designed with embedded systems in mind but it should function on normal systems too. It's like saying, uh yes, it's designed for Perl but it'll work on normal languages as well. A little foreshadowing.

0:28:38.884 --> 0:28:40.150
<v B>The embedded stuff.

0:28:40.470 --> 0:28:57.666
<v A>There I think is the call out because it's not just the limited resources but also things like embedded systems sometimes don't even have dynamic memory allocation, and you'd be surprised how few off-the-shelf libraries will work if you say you're not allowed to run new or malloc.

0:28:58.645 --> 0:30:37.802
<v B>Yeah, that makes sense. Makes sense. All right. My news second news is called Dig This Vegas. There's a bunch of these. I found out there's one in Texas. I'm going to try and go, but basically these are kind of amusement parks where you get real-life construction equipment. So the one in Vegas, which a buddy of mine just came back from, they gave him an excavator, and they put a car—like a, you know, junkyard car on the ground, and he gets to just demolish it. And so like, you as part of this experience, they put you—I think you start in like a skid steer, and so you drive a skid steer through a track, and then they have a bulldozer, and you, you know, move some sand around all that, and then they put you in an excavator, and your job is to get to there's like yeah, your goal is like there's inside the car, there's a box, and you have to get that box by like tearing the roof of the car or throwing it around or something. And so and so they put you in this really heavy-duty equipment, and you get to have fun for like two hours and do crazy stuff. So I thought this was really cool. There's there's one over here in Texas. I'm going to take the kids at some point, but I got a real kick out of this. If you're ever in Vegas or there's one in Minneapolis, there's a bunch of them. If it's something that you'd be interested in, find out the locations and try it out sometime. It sounded really, really awesome. I haven't I don't have any firsthand experience, but the idea just immediately clicked with me. So looking forward to trying this at some point.

0:30:38.494 --> 0:30:41.140
<v A>You going to give the disclosure about that being a sponsored segment?

0:30:42.426 --> 0:30:58.154
<v B>No, yeah, they're not paying us, unfortunately. I wish they were. Yeah, maybe they should be. No, yeah, so this is totally unsolicited. Yeah, we don't we don't push any product here, so it's all legit. No.

0:30:58.322 --> 0:31:59.393
<v A>Just teasing Jason. I've seen something similar. I mean that one that sounds cool. I've seen a similar one where I was somewhere, and I guess it makes sense because it's a relatively cheap thing to do. They go to—I assume a thrift store. I'm just gonna hope that they buy like damaged or broken, you know, TVs things that don't work anymore, and then you pay, and they put you in like kind of like a jumpsuit, like safety goggles, and give you like a bat or a sledgehammer or an axe, and like we will give you a room, and in this room we're gonna have like, you know, dishes and a TV and like a sofa, and you can just like go at it, like smash them. Smash the—but they probably don't want you smashing the walls, but I assume they could build a fake wall if they wanted you to. Yeah, so you pay for 15 minutes to just like take a sledgehammer to whatever's in this room, and it's like wow. Apparently there's a—you know, malls today are having difficulties, so I assume like rent is pretty low, and so like they just put it—it's a very low overhead operation to grab a bunch of junk from somewhere and put it in a room and charge people to

0:32:00.000 --> 0:32:41.969
<v B>go smash it. Yeah, coincidentally I have a friend who's who's a physician or not is that the right word? Basically he's a surgeon. Sorry, that's what I was. Okay, I have a friend who's a surgeon and he works for a hospital in downtown Orlando. He told me that they got someone in who went to one of these things that you're talking about, and basically he swung the bat and it smashed the window of the car, and a piece of glass like flew up and like cut an artery in his neck or something. So I'm pretty sure lesson learned—they took I'm sure they take out all the glass now, but there was when this like first was a thing somebody got like really, really hurt. Just

0:32:41.969 --> 0:32:42.920
<v A>happened to be in

0:32:45.360 --> 0:32:49.360
<v A>Florida. Well, on that happy note, it's not time for a book of the

0:32:50.204 --> 0:34:45.600
<v B>show my book of the show is how to get in the hospital? Now my book this show is—it doesn't have to be crazy at work. So I found this book fascinating. It's from DHH, and that's what everyone calls them, but I'm going to look up the actual person's name here for posterity's sake: David Heinemeier Hansson and Jason Fried. So basically these are the two folks who made Basecamp, the co-founders of the productivity software Basecamp. So a bit of background here: Basecamp is completely bootstrapped, so there's no VCs, there's no strategic investors, there's none of that. And so you know that means there's zero pressure. It's not a public company, and so all they really have to do is make enough revenue to cover their expenses in terms of staying afloat as a company. So that gives them like a very different perspective. But you know the book is all about A Different Experiments that they have tried, you know, in management. You know, they tried doing unlimited vacation and they found out it was a terrible idea, and they tried this other thing, they tried our thing, and so it kind of like walks through their journey starting Basecamp. Similar to the last book I recommended from Tony Fadell, it is rather prescriptive. You know, I mean they're constantly kind of telling you what to do, what not to do, and so you always have to take that with a grain of salt. I loved the anecdotes. You know, they would talk about things that they did and what worked and what didn't. I mean all the things that they tried, even the bad ideas. They make total sense. I mean it seems completely reasonable to try any of these things, and so then hearing you know how they succeeded or failed, or what even the ones that succeeded—you know how they had to make changes over time—was fascinating. You know, I had a really great time reading it. I did finish the book a few weeks ago, so I read it cover to cover, and you know it's

0:34:45.600 --> 0:34:57.964
<v B>relatively like what's the word? Like homogenous. You know, like every chapter is kind of like a different story, but you know once you've read the first chapter, you kind of see the pattern, and so yeah, really good content. Recommend it.

0:34:58.707 --> 0:35:01.080
<v A>And you've now become immediately disgruntled with your current

0:35:03.600 --> 0:35:04.444
<v A>employer. The

0:35:05.727 --> 0:35:48.336
<v B>One that really stuck with me was the unlimited vacation because what they talked about is exactly what I would think would happen in that situation, which is you know some people will take like two, three, four weeks of vacation just like normal, and then you have a handful of people who will take no vacation ever because that's the type of mentality they have, and they get super burnt out. And so, you know, the nice thing about the unlimited vacation or disappears is that at some point someone's like working against their own interests by not taking it. So I thought that was pretty salient, but yeah, it was a great read all right.

0:35:49.240 --> 0:37:00.139
<v A>Awesome! I have to check that out. Yeah, I think you're right. I think a lot of this stuff seems like it would make sense, right? First time anyone hears about unlimited vacation—I'm not sure if I say anyone—a lot of people probably think that would be amazing. And then it's like, yeah, but do you realize if you just took, if all you did was take vacation, you're going to no longer have a job? Like, and it's very difficult, like you said, to how do you deal with the—I don't say—guilt? That's not the right. Like, how do you deal with some managers being like, 'Yeah, sure, you know, do whatever,' and other managers being like, 'No'? And so yeah, it does become very nuanced even with vacation. You have like how much is sort of socially acceptable to take at once. So most businesses either give you a set amount a year and it expires each year, or you get some each year and it kind of builds up, and then there's like a max. And you like you said you have to either take it or lose it, but there is still some like—I don't say—interaction, negotiation about like, 'Yes, you've earned four weeks of vacation because you haven't taken any for the last 18 months,' but like taking it all at once is still a big ask rather than taking one week at a time. And so I think there's a lot of difficulty in navigating the politics of that.

0:37:01.304 --> 0:37:34.564
<v B>Yeah, totally. I mean, one thing that is you know really controversial, but I stand by it, is that I feel like in many ways it is a zero-sum game. And so, you know, people will say, 'Well, we have this, you know, we at Company X have this performance rubric,' and if theoretically, you know everyone was a greatly exceeded expectations according to our rubric, then Company X would get everyone a greatly exceeds expectation and everyone would get a three times bonus. But, you know, is—

0:37:37.230 --> 0:38:27.518
<v B>it a coincidence that that never happens? Like, you know, do you really think it's a coincidence? Like there's always, you know, the same relative like pretty much distribution every single time. And even if that did happen, you know people want to get promoted, and there's the distribution of levels seems to stay the same all the time, right? So, so yeah, I do think that, you know, given that there are parts of it that are relatively zero-sum or we'll say low, low positive sum, then there's going to be a class of people who will just be as competitive as humanly possible, and what they'll like in the short term and in the long term, they'll get as this—earlier, like totally burnt out. And so it's yeah, it's really difficult. It's almost like it's almost like getting someone to take medicine, you know.

0:38:29.037 --> 0:38:31.146
<v B>It's like it's bitter, but it's really important.

0:38:32.192 --> 0:39:02.753
<v A>Mine is a fiction book which is The Prince of Fools by Mark Lawrence, which is the first in a series called The Red Queen's War. I haven't read the follow-up books, but this first book—I did read there was The Oh, I should have looked up The Silence, no, The Sisters. Oh man, why can't I think of the name? Anyways, I'd recommended books by Mark Lawrence before that were in a series, and so this is another series by them, and it's a pretty interesting take. It's sort of—it's not science fiction but more fantasy. Oh, definitely fantasy.

0:39:02.753 --> 0:39:05.993
<v B>Is when you're thinking Holy Sister or Gray Sister? Yeah, that's—

0:39:05.993 --> 0:39:09.486
<v A>One of them. Well, there's a series there that's all part of the same.

0:39:09.655 --> 0:39:11.697
<v B>Oh, you're right! There's Red Sister. Yeah, yeah, I—

0:39:11.697 --> 0:40:14.607
<v A>Can't remember the name of the series though that was what I was searching for. It failed me; didn't have my notes together. So The Prince of Fools is this Red Queen's War number one. They're introducing sort of a new world, this new concept. I think Mark Lawrence does a pretty good job of—of this sort of like setting a very interesting, not grim world, but kind of like things are are sort of like oppressive and problematic, and you don't kind of always understand why or what all is going on. And then as the story progresses, you sort of get that feeling of like learning more and understanding the way the systems work. And I think that's repeated here. So I'm looking forward to reading the rest of this series. But there are kind of like two main characters here that are an interesting dynamic because one is sort of like a privileged, spoiled person, and the other is sort of like a very gruff, like raised on hard times, kind of like a Norse warrior, and they kind of have to like end up going at things together and helping each other even though like normally they wouldn't be associated. And so I found it a really nice read and looking forward to reading the rest of the.

0:40:14.894 --> 0:40:19.956
<v B>Series? Nice. So is this a completely separate thread or did you have to read the Sister books?

0:40:20.074 --> 0:40:31.330
<v A>First, no. I asked—well, I haven't yet even seen any references to the other one. So got it. I don't think it's in the same universe. I think that's the way of sort of saying it. Yeah.

0:40:31.769 --> 0:40:42.974
<v B>That makes sense. Oh, very cool. Is this do you think this is a good one for people who are just getting into like, like I guess dark fantasy or epic fantasy? Oh.

0:40:43.058 --> 0:41:11.020
<v A>Oh, that's a good question. I don't know. This is hard. This is like asking—we answered this one—but it's still a hard one for me. Like what would you do today to get into programming? And it's like when I got right and today it's like very different, so it's hard. So I've been reading fantasy for a very long time, so I'm not sure that I'm called. I'd have to think. I'm sorry, I don't have a good response. Jason, no problem. Uh, good question. I just don't know how to answer it, you know. I.

0:41:11.290 --> 0:41:24.570
<v B>I think maybe, you know, one answer is is just, you know, any book that you pick up is going to be a good first book. So if you're out there and uh you're looking for, you know, a really good hobby, you know, this is uh this is a great way to get started.

0:41:25.904 --> 0:42:36.680
<v A>I would say that like having a book that pulls you in. And like regardless, you'll sort of make it through. Um I saw someone pointing out that there's a weird cultural thing and I don't know how global it is, but that people have this thing when they start a book that they feel they gotta finish. Like they want to finish it even if they don't like it. They won't start a new book until they finish the first book. And so like you get in this catch-22 where like it's hard to make it through this book, so therefore you're not reading as much. And they're like just very weird dynamic. Oh, and I was like, oh yeah, actually I do feel this way. Like when I start a book, I just really want to finish it. And someone was pointing out you should give it X pages or X hours of reading, and if you don't like it, just put it down. Don't finish it. Who cares? But I will say there have been some books that I really, really liked that took a long time to get into. That like, you know, a third of the book was—and I would love to critique them and say they should have done it differently or whatever—but it's sort of like you probably wouldn't have had the payoff if you hadn't gone through the stuff. So I don't know how I feel about that assessment, but I definitely do fall into the camp of like I don't—I want to finish a book. I don't like putting a book down even if I don't like it. I've only done it once or twice.

0:42:37.234 --> 0:42:39.749
<v B>Yeah, yeah. See, I'm the opposite. I have a bunch of unfinished books.

0:42:41.672 --> 0:44:40.980
<v B>So I mean maybe I think that there is a fault the other direction too where if I read a book and it's not really like holding my interest, then I'll just move on to the next book. And then uh part of it is if you check out a book from a library, then, you know, if you don't finish in time, it just goes back to the library. And that's I think a big cause of it. Well, if you like these books, you should definitely check out our affiliate links. So if you want to, you know, get into epic fantasy or you want to read about it, uh doesn't have to be crazy at work. Please go to our show notes and click the link that helps us out. That I don't exactly know how Amazon does it, but if you click the link, uh Amazon rewards us through some way of doing it, so we appreciate that. And if you don't want to go through or if you already have these books, you can support us through Patreon. Or even if you do have the books, you can always support us through Patreon. That is patreon.com/programmingthrowdown, and we appreciate everyone's support. Yes. Thank you to everyone. Yeah, with that, we have the tool of the show. My tool of the show is actually a piece of hardware what? Yeah, it's the Remarkable 2. It's really interesting. Again, we're not, you know, sponsored by them or anything, so this is totally organic, but uh it's very simple. All it is is an E-Ink display that has like, you know, a touchscreen and it's somehow set up so that the pen can write to it, but like your palm of your hand or your finger like don't accidentally mess things up, so they have some palm rejection. I think it's what's called—um, you can write really well. It's extremely responsive, and then on the back end, it can OCR your notes and turn them into text and everything. I haven't to be honest used any of those features, but uh the thing I really like about it is, you know, you can have very easy random access to all of your pages. So I used to use

0:44:40.980 --> 0:45:29.241
<v B>you know, hold it up even though we're an audio podcast. I'll hold it up anyways just for my own sake. I used to use, you know, these little composition books and so I have like a ton of notes in them—things I want to remember, things from discussions I've had. Um but then, you know, I'm kind of flipping pages, and uh this is just so much easier. So I have, you know, my notes. You know, I have each page in this kind of organized, and so if I want to go to another page, I just click on the name with the pen. I'm really digging it. Yeah, I mean, it's it's kind of pricey. I think it was—I didn't buy a cover or anything like that, but I still think it was something like four or five hundred dollars, but I'm getting a lot of use out of it constantly taking notes at work, and so you know, I feel like I am getting my money's worth. And overall, I'm just—it's a beautiful experience.

0:45:30.338 --> 0:45:41.999
<v A>You have any thought of um I saw Amazon released a Kindle version um the Scribe that sounds very similar? Do you have any like why one over the other one wasn't available when you bought the other?

0:45:42.353 --> 0:46:37.551
<v B>Yeah, it's a good question. The Kindle Scribe was pretty new when I was looking, and so, you know, it was a tough—it was a tough debate. I think ultimately I knew somebody who's really happy with the Remarkable, and so that's really what pushed me in that direction. I mean, part of it is uh if I'm going to read a book, it'll almost certainly be an audiobook, so that was another factor. Um I think if you—if you're a reader, the Kindle Scribe makes more sense. Like this thing, I think it—I think you can put PDFs on it, but uh it's not designed for that. It's not very convenient. So if you're going to read, I think Kindle Scribe might be a better option. I think it's a little bit cheaper too, but I haven't tried it, so I can't vouch for it. The Remarkable works really, really well, and definitely get the pen with the eraser, so uh it costs a little bit extra, but you know, I'm constantly kind of uh going through and erasing different lines or replacing them and everything nice.

0:46:38.260 --> 0:48:35.660
<v A>I didn't realize we could do actual tools. I'm just kidding for tool of the show. My tool of the show is a game. I checked—I don't think I've recommended it before, so here it is: Slay the Spire. This is not a new game; this has been out for many years now. Um but I actually got back into it. I was traveling and looking for something that was like uh easy enough to sort of use while I was traveling on an airplane or that kind of stuff. And this is a—I guess you call it a card game, but it's a card game that you wouldn't build physically, I guess. They might try to do a version of it, and uh you sort of—I guess it's a rogue-like game or a board game, and that as you progress through your journey, you can add cards to your hand. You can sort of figure out what you want to focus on. You kind of build up points, and then when you die, you can, you know, improve your character in some way. And I was having a really, really difficult time. Like I was actually like kind of put it down. I was playing it again and again. I just like I really sucked at it. So I like did a little bit of Googling for like some tips and realized like oh okay, there's a few main characters that you kind of like unlock, and actually the first one they were saying is much harder to feel progression about, and so they were recommending the second one. I picked up, you know, trying to play with the second character, and sure enough, like it clicked. I was like, oh, I understand a lot more. Part of these games is playing through them enough to understand like what's ahead because you're sort of right making choices, and if you don't know what's up ahead, it's like it's a sort of like—you talked about the book, you got to play it enough to understand the dynamics so that you understand like you can't just pick randomly and or whatever looks cool. You got to kind of focus for a direction, and it's hard to have a direction if you don't know like what the pacing is like or how often you can heal or these kinds of things. Anyways, Slay Spire probably most people have heard about it or played it, but um I enjoyed it, and um once you sort of like get into it, you can actually just like kind

0:48:35.660 --> 0:48:47.894
<v A>of play quickly, and you sort of like get to more the strategy and a little less the like, you know, okay what do I do on each turn? I'm looking at all my cards, you know, what they all say. You can sort of play them very quickly, and so the

0:48:48.889 --> 0:48:54.323
<v B>pace picks up. Oh, very cool. I've been getting into Hearthstone, which is somewhat similar although it's not episodic. Oh.

0:48:54.323 --> 0:48:57.192
<v A>Yeah, another oldie but a goodie. Yeah, wow. Yeah.

0:48:57.715 --> 0:49:17.982
<v B>Yeah, it's good times. I don't play with other people though because I'm not really competitive, but the single player is actually pretty fun. The nice thing about the single player is that you know that every level is pretty either neutral or in your favor, and you're not gonna get completely unbalanced cards.

0:49:18.960 --> 0:50:00.000
<v A>I played similar exactly to as you described Hearthstone a while, and I put it down. And I've not picked it up again. I don't think you can really play it offline, which to me is hard when like a lot of the times I can play is like when I'm on an airplane or whatever internet connectivity is getting better, but I thought there was still like a compulsion to get the reward loop unlock stuff to do at least some multiplayer gaming. Like, oh, you should go into a battle. You should at least try to win one a day or one a week or during this time frame. Yeah, you get these unlocks, and even though they probably didn't matter because like you said they're like pre-canned for a lot of the single players, I still felt like I was missing out, and so I dropped.

0:50:00.254 --> 0:50:08.995
<v B>It that makes sense. All right, on to Perl and regular expressions. What's your history with Perl? Like, have you used it for any projects?

0:50:09.231 --> 0:51:06.080
<v A>So when I was first getting into, I guess Unix-like operating systems, I felt Perl came like reasonably recommended, but it always kind of resisted it for the purposes of scripting and kind of got more into in the early thing just using Bash. And it always felt like using something that came with it was a little easier. And I was at the time a C programmer, and so anyway, so Perl sort of always floated on the periphery. And you know, yay old Patrick would go onto the internet dog pile and search, you know, like something and get a Perl one-liner, right? So rather than using sed and awk, someone would give me a Perl one-liner, and I would have no clue what it said, and I would run it. But always sort of like bounced around where people would talk about using Perl and kind of interacting with, but I just never sort of like got heavily into the development, but yeah, that was sort of my history right about you.

0:51:06.080 --> 0:52:19.439
<v B>it's about the same yeah i think you know i'd mainly use pearl as a a few kind of scripts to manipulate some text the big use case that i had for pearl is is where exactly where someone will come like i'll want to in a in a huge string or a huge like group of files i want to like replace foo with bar and all the files and then you can use said and and all that but sometimes it just there's certain things maybe and i think it's gotten a lot better but there was definitely a period of time where pearl regular expressions could do things that said couldn't and so it's like at some point you would try to do something that you read on the internet and it wouldn't work instead and you'd have to like go to pearl even actually pretty recent uh yeah the mac uh version of said the one that comes with mac or comes with free bsd oh this is yeah is like not doesn't have all the features and so you have to go and get compatible yeah yeah you have to get gnu said and then run g said and so so you know pearl doesn't have that problem like pearl has every version of pearl you know reasonable version of pearl has all the regular expression stuff when we

0:52:19.995 --> 0:54:19.880
<v A>were researching for this show. I tried like looking for evidence or proof, and I couldn't find any, but one of the things that I always sort of felt like—that the earliest example of, I don't want to say dependency management, that's too strong, but like having a programming language where it wasn't just what was sort of as shipped. That there was like and not even like Python talks about the concept of like batteries included, and you know having all these things. But today we think about Python, and no one that I know develops Python without like having using, I guess that's PyPy through Pip or some other, you know, distribution environment where they go out and pull down modules. Node even probably more so with the npm package manager. But I going all the way back to like my earliest memories again couldn't find any defense of it, but Perl had the CPAN, and the CPAN was like where you could go to get like the modules, the downloads someone else had written something that did a thing kind of like plugins, I guess, or you know today we kind of know these are very common, but that was the comprehensive Perl Archive Network. And it was a way for you know kind of like dynamically for you to grow the compatibility of your programming language and sort of pull down stuff that added capabilities or features or stuff that wouldn't have come out of the box. And again, I already kind of mentioned coming at this from like being a C programmer—even to this day, even in C++—this is still like not how things are done. Like in C++, you don't go like, 'Oh, let me run some command.' They do exist. It's just not the regular use of most C++ programmers, but like you can't just—I think Conan is an example. Oh, I'm gonna run this Conan command and download this other thing into my project and have all this other capability that's just not how it's sort of done. But it was cool that Perl had this, and I feel like this has become just the way it is today, but back when Perl and the CPAN were kind of in the zeitgeist, I feel like that

0:54:19.880 --> 0:54:21.411
<v A>was a pretty unique play. Yeah.

0:54:21.985 --> 0:54:39.164
<v B>Totally right. Yeah, I think I think that was one of the great contributions of Perl was you know that it kind of created this network effect. Yeah, I think that culminated with GitHub where now you can create a project on GitHub. Everyone's looking on GitHub for projects, and you know it kind of creates this whole network.

0:54:39.653 --> 0:55:15.681
<v A>I was noticing the other day on like the GitHub thing is how much easier it is to find snippets of code. We had open source projects before, right? Now, like you know I'm an old person, but you would go to like remember like SourceForge, but like SourceForge, but it had like—was that an SVN repository? I don't even remember. And you would sort of like you could clone it. Well, that's not what it was called. Download it and then look at the source code. But who did that now when you search on GitHub? Like the source code is just right there, and you can just click. You can get some snippet. You can figure out how to do something, right? Like Stack Overflow. I feel like it's just crazy how much different it is than kind of the way it used

0:55:16.457 --> 0:55:50.089
<v B>to be. Yeah, yeah, totally. Oh, the other thing that has always kind of stuck to me about Perl is how Amazon.com is built on Perl. And I would talk to people who work at Amazon, and they would say, 'Yeah, it's just—it's a you know, I mean obviously you know the database is not written in Perl or something, but like you know the back end front end web stuff is all in Perl.' And that blew my mind because you know it's really an outlier. But yeah, I think I'm sure Amazon hires just tons and tons of Perl people even to

0:55:50.950 --> 0:56:02.526
<v A>this day is that like the Facebook runs on PHP, but it's sort of like a heavily—often heavily modified whatever. Or do they really just like bog standard Perl? Do you know they've

0:56:02.880 --> 0:57:43.810
<v B>got to have something right. They've got to have something because at that scale, you know, even if you make the compiler one percent faster, that probably saves them enough money to justify, you know, some engineer working on that full time. But yeah, I think the syntax is still very Perl-like. So yeah, I mean getting back to our use case, you know, I primarily—so Perl has this thing they call it Perl-Pi. It's actually Perl, you know, dash P dash I dash E. You could just string them all together. And I'm gonna try and see if I get this right. I think the Pi was interactive. I don't remember exactly what it was, but basically, you could do Perl-Pi. You give it a regular expression, and then you give it a directory, and it will just execute that on the whole directory. So you could do it's similar like `sed` and `awk`. You can do a Perl-Pi, you know, substitute, you know, foo with bar on this directory, and it'll just go through and just take care of that for you. And I felt like, you know, definitely back in the day, that was extremely powerful and useful. Like imagine, you know, you have—let's say you have some text content, maybe it's coming out of your `top` command or something, and it's showing you your processes and what CPU they're using, and you have a log of this, and you want to put it into Excel. So you want to create like a comma-separated value. So you want to take, uh, you know, these—maybe it's tab separated—you want to make it comma separated. Perl-Pi will just knock that out for you very quickly. And you have said to not could do that too, but it has the issues we talked about earlier.

0:57:44.181 --> 0:58:26.554
<v A>I didn't realize it was three different commands just squished together like a P flag and I flag and an E flag. It just happens to just feel like a word. So today I learned. But yeah, very powerful. And I think like this thing that you're pointing out, which is inextricably kind of linked in with Perl and its history—at least in my mind—but I feel like most people I talk to, mine is no one talks about Perl without talking about regular expressions. Like that is the like even these use cases we're sort of saying—well, not the Amazon one, but the other ones Jason is pointing out—is all about like regular expressions and pattern matching and replacing and that kind of workflow. Yeah.

0:58:27.044 --> 0:58:49.065
<v B>Totally. And so that's that's one, you know. Perl really popularized regular expressions, but I would say, you know, in the long run, the regular expression is is is really the lasting legacy, and it's extremely powerful system that every engineer should learn and get familiar with. So,

0:58:51.107 --> 0:59:04.506
<v A>for those who don't know or haven't ever used a regular expression before can you maybe like go is that even like a possible like the 30 000 but like what is a regular expression why do we have that as a named

0:59:05.333 --> 1:01:03.200
<v B>Yeah. I think that so find replace is obviously really important. You know, simple example: let's say you created a variable or a function name—is even a better example. You created a function a while back, and the function was something like `replaceCircleWithSquareFloat` or something is the name of your function. And then later on, you find, oh, you know, I actually want to use doubles. I want to replace all the floats with doubles in my program. So I want to change this function name, but I also need to change all the places who are calling this function. So, you know, if your function name is unique enough, you could say, you know, just go in your text editor and say 'go in all the files' and replace, you know, find `circleWithSquare` replace with `circleWithSquareFloat` with replace `circleWithSquareDouble`. And so it goes to replace all those strings. But sometimes, you know, when you're in the habit of doing that, especially for refactoring, you can get busted. Like imagine if your function name was, you know, `squareRoot`. Then you're like, 'Okay, I'm just going to go through my whole hard drive and replace square root or even this project' or replace `squareRoot` with something else.' Like it's just going to be total pandemonium, right? You know. But if you could do something a little bit more advanced, like maybe, you know, there's places where you have, you know, `squareRoot` in a comment, or there's places where you have `squareRoot` that's a variable name, so I want to say like let's actually look for `squareRoot` with an open parenthesis. And so like you start getting more and more complicated, you know, find replace type things. Like another example is maybe I want to find like contiguous sections of whitespace and replace all of it with a comma. So if I have, you know, 'Patrick space space space space space Wheeler,' I don't want to have like ', , , , ,' I just want to have one comma for that whole block, right? So you can imagine like a whole bunch of scenarios like this.

1:01:03.200 --> 1:01:19.354
<v B>And you know regular find replace just can't—can't do it. And so regular expressions were designed to do kind of text processing, you know, more advanced text processing that we can't just simply do is find replace.

1:01:19.810 --> 1:02:46.429
<v A>Yeah. So I guess if like if I riff on that, it's if you go in your text editor and you, you know, special key F—whatever that is on your Control or what is it, Command in macOS—and you find something, it is like doing substring matching, right? So it's looking for like a contiguous set of characters. So one space or two spaces or A then the letter B. But what Jason is calling out is sometimes that's not powerful enough because as an example, if you wanted to eliminate a word in a comment and you don't know where in the comment it takes place, and let's say I'll use the example of C++, and we know that we use the backslash backslash at the start of the comments in our project. Then what I want to say is I want to find `//`, but then I want to skip to anywhere in that line where the word, you know, 'foo' is, and I want to replace it with the word 'bar'. There's no way for you to do like Control F or Control R for find and replace. There's no way for you to specify in the normal default behavior of most of those to say, look here at the beginning of the line, skip some stuff, and then match this. Like that kind of matching isn't supported. So a lot of them do have the option of going into a regular expression mode where you can kind of write this, and that's a useful feature. But as Jason is pointing out, you need a special grammar or a special language for describing these more complex operations. Yeah.

1:02:46.902 --> 1:04:33.960
<v B>I actually want to interject like one kind of story here. When I was a junior engineer, I would get really, really frustrated when people would ask me to refactor things in pull requests. They would say like, 'Change the name of this function,' or, you know, 'indent in this way' or whatever.' And the reason why I was getting so frustrated is because it took me a ton of time, you know, and especially if somebody said, 'Oh, like actually, I liked it.' So this happened to me one time where they said, 'Oh, actually, I liked it better the other way.' It had to do with there was a variable that was plural. And so they wanted me to make it plural. So let's just say, make it simple. Like instead of `apple`, they wanted me to make it `apples`. And then when we actually looked at how it was used, they decided, 'Oh, no, I actually want to make it apple.' And so I, you know, not knowing regular expressions, was taking me hours to make this change. And I was getting really frustrated. And it made me kind of frustrated at the whole refactoring thing in general to the point where I was kind of like, 'Look, you know, this is like—I guess I'll put my researcher hat on. Like, look, you know, the code works. The numbers are like statistically accurate. Like, I don't care what the variable name is, `apple` or `apples`, right? But, you know, really, I do care about the code quality. It's just that I didn't have the tools to do that efficiently. And so I care about the code quality if it's going to take me five minutes or 10 minutes. I don't care about the code quality if it's going to take me a whole day or three days, right? And so I learned regular expressions way, way too late. And so I guess it's a public service announcement. You know, learn regular expressions. You'll end up writing much better code as a result.

1:04:33.960 --> 1:05:44.620
<v A>So one of the things about regular expressions that I never got into, but I always find interesting is there is like a formalism built out around them where, you know, we're describing very common end programmer operations where you want to run something, but sort of building parsers and the language and the grammars of all this—I don't think we're going to necessarily talk about here—but I just point out to people that that is like a thing that you will run into or hear people talking about various ways of kind of doing these. Or if you're ever going to write a domain-specific language or some sort of thing where you're not just writing sort of a text input, but actually like something that helps script or run some of your programs, you'll kind of run into a lot of the more academic approaches, and regular expressions are sort of an end-use implementation of which there are a couple of flavors. There's like a Unix flavor and the Perl flavor of exactly like what the special characters are, but it's part of this larger academic grammar for sort of actually doing these kinds of operations like pattern recognition and matching.

1:05:46.100 --> 1:07:44.580
<v B>Yep, yep. Another thing that regular expressions does really well that's hard to get anywhere else is the grouping and the backreferences. And so the way this works is, you know, if you're also replacing—so if it's a find and replace—you might find a certain, like actually Patrick, your example was pretty good. Like you might say, 'Okay, find a line where it starts with, you know, a couple of slashes.' And so I think there's what is it? The caret sign. I think the caret. So another thing about regular expressions is there's a ton of special characters. And, you know, you can escape them out to treat the regular characters, but if you don't do that, they mean something completely different than, you know, look for a caret. So if you see the caret symbol, it actually means, 'You only match if it's the beginning of the line.' So you might say, you know, `^//.*`. And so dot means it could be any character. Star means any number of any characters or any number of whatever came before. And then, you know, foo, right? So I'm looking for, you know, a string that starts with the slashes, so it's a comment, and then has something else, and then that outputs 'foo'. Now, if I want to replace that with something else, right? If I want to replace 'foo' with 'bar', right? I need to keep all that other stuff. Like if I just say, take that expression and replace it with 'bar,' it's going to destroy the slashes and the dot star. Like my whole comment's going to be destroyed leading up to 'foo,' and I'm just getting up with 'bar.' And then when I run that, it's going to compile error because I lost the slashes, right? So you can create what's called a group. So you can say, look for something that starts with the slashes and anything, you know, a wild card, and call that Group 1, and then look for 'foo' after that. And then I want to replace that with Group 1, whatever that was, and then 'bar.'

1:07:44.880 --> 1:07:54.359
<v B>That's the backreference. And so you can do these like really intricate find replaces using regular expressions, and that ends up being extremely powerful.

1:07:55.319 --> 1:09:34.340
<v A>I think also like the common—you were talking about refactoring, but like the common thing is like, if the thing you're trying to find and replace is like a substring of some other common thing in your code base, I think this is where the regular expressions really help. As Jason's mentioning, like capturing that, like 'I'm looking for this only at the start of a word.' So it needs to follow a whitespace or it needs to be before an open paren. But then also sometimes if you are trying to like apple to apples—is a good example. Is that idempotent? What is the phrase where it's like, if you replace 'apple' with 'apples' and you run that twice, you will get a lot of occurrences where you get 'apples s,' like 'apple s,' because 'apple' is a subset of the word 'apples.' And so this is where it's really powerful, but also these backreferences and capturing this group of texts, allowing you to repeat stuff. So whatever you found after this, like capture it and then like put it back twice. Like I want to repeat that thing or I want to put it as part of some other something. So if I wanted to—I wouldn't encourage you to do that. But like if you were thinking about switching like from snake_case, right? Is that right? Where it's the underscores to camelCase. So it's like if it's a start of the group or an underscore, then whatever's next. Like imagine trying to do that like Jason described. It would take you hours and hours to like search your whole code base for underscores, ignore most of them, find the ones where they're variable names, like do these fixes. I'm not saying doing that with regular expressions would also be really easy. That's probably could be reasonably tricky if you don't know what you're doing, but it would be at least, you know, approachable.

1:09:35.660 --> 1:11:17.540
<v B>Yep, yep. And there's definitely times where I've been able to use some clever regular expressions and it is indistinguishable from magic or maybe indistinguishable from hours of labor. There was one case in particular where we were using PyTorch, and PyTorch has a build system called Bazel for building code. And so we're using Bazel, and PyTorch has Bazel as well, but the Bazels like didn't quite match, right? There were some differences, and you ended up having to, basically, I ended up having to rename like pretty much anything that had PyTorch in the build files. I had to kind of give it a prefix so that there wasn't a collision with this other thing. And so, you know, using some clever regex, I was able to do that, and it ended up being a, you know, 65,000 line PR, but in the PR description, I just put the regex. And so it's just like, and I purposely made a PR that all it did was this regex. That way it's not like mixed in with real work, right? Yeah. And I mean, to do that by hand, right? 65,000, it would have been just intractable. We would have had to find another way around it. So, so regexes are super powerful; highly recommend people learn them. And, you know, one really good way to do that is through these—have you seen these Patrick websites where, you know, you can put in sample text and regexes and in real time on the website, it'll show you the matches and the references and everything.

1:11:18.500 --> 1:11:26.700
<v A>Oh, I've seen one that was like a tutorial, but this one that you're—you've got here in the show, this is awesome. This is like Godbolt, but for regular expressions. Oh, this is awesome.

1:11:27.400 --> 1:11:28.280
<v B>Wait, it's like what?

1:11:28.980 --> 1:11:50.620
<v A>Oh, no, do your thing. It'll make sense. I'll tell you at the end. Godbolt is like, you put in like a C or C++ and they'll run it through a compiler and show you like the internal workings of it, like whether it's succeeded or not, doing the decompiling. Yeah. Like you can check how loop unrolling does or doesn't work given different compiler versions or pragmas.

1:11:51.000 --> 1:11:52.460
<v B>Oh, that is super cool.

1:11:52.680 --> 1:11:54.780
<v A>It settles a lot of debates about what's faster.

1:11:56.240 --> 1:12:08.340
<v B>That's awesome. Yeah, I'd never heard of that. That's really interesting. Is it called? It's called Godbolt? Godbolt. Yeah. Okay. I just T-I-L: Today I learned. Sorry.

1:12:08.840 --> 1:12:09.840
<v A>That's a complete deception.

1:12:10.480 --> 1:13:45.100
<v B>So, yeah, so Reddick Explorer, the way it works is, you know, you put a sample and—you know, oh, by the way, one thing we didn't mention is you can even do multi-line matching. So, you know, even if you have something really complicated that's multi-line, you can get it done. It gets tricky, but it's doable. But you can put some sample text and then as you're writing your regex, you know, it's—this is just running in the browser. It's not copying anything to the server or anything. You know, while you're writing your regex, it's real-time showing you, you know, here's what you're matching. Here's what the groups are if you want to reference them in your replace string. And here's what the replace string looks like if you're doing a find replace. So if you're doing a find, it'll also, you know, tell you whether this line would have been found or not, or this part of this line. Extremely useful. I mean, one thing that, you know, we didn't quite talk about with regex and Perl is, or maybe, maybe I'll just say regex, it's extremely difficult to read. You know, reading a regex and trying to understand what it's doing is very, very hard. Typically, if I have a regex, I'll almost always put a comment in front explaining like what I was trying to do with this regex because otherwise it's like, you know, slash bracket, regular bracket, A, B, C, B, dash, Z, close bracket, slash, close bracket. It's like, it's almost like hieroglyphics. And so the nice thing is you can take any regex, put it into this website and then, you know, put some sample text and see what matches and start to triage.

1:13:45.620 --> 1:14:50.460
<v A>That's definitely good advice. Don't use regexes in your code to show up. Like, if you use them, like, describe them. I'm not saying don't use them; that might be a bit too far. But I read some codebase the other day that was using the ternary operator, you know, where you put a Boolean expression and then if it's true, you do the first thing, and if it's false, you do the second thing, and it's like a way of writing one-liners. It almost never is not replaceable with an if else. And so, it was very frustrating because it takes 30 seconds to read what it's saying instead of the, you know, five seconds of reading the if else statement, and they didn't write a comment; they didn't, you know, anything. It's like, 'Ah, why?' And regex is the same thing. Even if you know what you're doing, you also, if you want someone to review it—not saying what you think it does requires the person to decompile it in their head, determine if that matches what they think the code should be doing. It's an extra step. If you write what you think it's doing, then they can just check that it matches that and then proceed. And that's actually just like a much better approach.

1:14:51.420 --> 1:16:15.900
<v B>Yep. Yep. I've started even—I don't know if the one I linked has this. I'm pretty sure it does. But as you're going through, you can, or maybe there's a button somewhere. There's basically a button where you can share the state of your regex exploration. So, so if you put in some sample text and you put in, you know, a regex, you can click this button. You know, I do think clicking the button causes them to save the sample text. So if your—if your sample texts are like government secrets or something, it might not be a good idea, but you can click this, create like a shortcut URL, and then you could put that URL in the source code comments and say, 'Like, this is, this is the intent here.' That's even better because now it takes people straight to that—to that regex, and they can see the decompiled result. I've often gotten into the habit of putting either links to something like this or links to Wolfram Alpha. You know, you'll see this in code all the time where it's like, 'angle equals' and then it's like cosine divided by this times this and then, you know, to the power of that. And then, and then people are just kind of scratching their head. So if things like that, I'll put a link to Wolfram Alpha. Yeah, I think for—for, you know, big equate treat it. Maybe the salient point here is treat a regular expression like a complicated math equation and give the right context.

1:16:16.360 --> 1:16:20.059
<v A>Man, you got the life pro tips buried here down at the end of the podcast, man.

1:16:20.960 --> 1:16:22.820
<v B>Yeah, people got to stay till the end.

1:16:25.491 --> 1:16:26.900
<v B>They have to listen to, uh,

1:16:27.139 --> 1:16:29.760
<v A>Yeah, yeah, stay to the end. Great tips at the end.

1:16:30.320 --> 1:16:34.740
<v B>That's right. Yeah. Producer, please make a note of that. Let's make sure folks catch the end of it.

1:16:34.740 --> 1:16:37.139
<v A>Are you just talking to yourself now, Jason? Yeah. Okay.

1:16:40.099 --> 1:17:08.900
<v B>Oh man. Very cool. Well, this was awesome. Yeah. I think, you know, we covered a language that we've, we've—this was a user request. Actually, it was a multi-user request over the years. Tons of folks have asked us to talk about Perl. You know, I think you can't talk about Perl without talking about regular expressions. And so we were able to kind of cover both of those. I get almost a double header here. And, uh, you know, thanks everyone for listening, staying till the end. And we appreciate it. And thanks again for all your support. See you next time.

1:17:08.900 --> 1:17:22.679
<v A>Music by Eric Barndoller.

1:17:24.280 --> 1:17:42.460
<v B>Programming Throwdown is distributed under a Creative Commons Attribution ShareAlike 2.0 license. You're free to share, copy, distribute, transmit the work, to remix, adapt the work, but you must provide attribution to Patrick and I, and ShareAlike in kind.

