 So, functional programming has a lot of ideas that sound really good on paper. And I'll get this out of the way now to be completely fair, some of those ideas are good. Most of those ideas are complete nonsense. And I'm going to show that by doing a sort of applied approach with functional programming. Let's make breakfast in as functionally pure way as possible. We're also joined by my doggo. He was apparently camera shy because he's been staring at me up until this camera went on him. Are you crying now? Okay then. Now, one thing functional programming teaches us is that you want your variable declarations or in this case, our ingredients as late as possible. And you want to evaluate those as late as possible. So, I'm going to be doing an omelet and we'll throw a few different things in here. Just whatever I can find in the kitchen that I don't mind using up ridiculous amounts of. You'll see why that happens. So, I have these just shitty ass pepperoni. We've got that and we need to heat it up. So, let's get a pan down. Hey, that'll be a fine amount. Another thing functional programming teaches us is that should never, ever change state. If you need to change something, you create a duplicate of it and, you know, do the modifications on that one. So, we need a duplicate of this. Where does this go? Well, they sort of teach you don't worry about it, the garbage collector will deal with that. He'd like to be. That's the garbage collector. This is either going the way of a how to basic video or it's time to actually normally crack some eggs. How to basic style videos coming later. Probably at the end of this, because I got a spare computer that I can completely obliterate, which I think could be kind of fun. But, no. We'll crack this normally. So now, I highly recommend adding a little bit of an acid to the eggs. Usually that's done in the form of cream of tartar, which I do have. Just a little bit of this stuff goes quite a long way. But remember, we can't modify that state. That's bad for some reason. So, we need a new one of those. There we go. So, we can add cream of tartar to one of these clones. What do we do with the old unmodified copy? That's an implementation detail you shouldn't worry about, but it gets dealt with by the garbage collector. But it doesn't stop there, guys. Adding an ingredient was one function. Whisking it up is a second function. That requires another copy. But, we're not done adding things to this, either. And I think you know what's happening with the clone again. Right into the implementation details you shouldn't worry about. But for this one, we can go and add in the second ingredient. But as I had said, that was a separate function. And we can't mutate state. We need to copy that again. And we've got our clone again. So, this one goes the way of implementation details. And this one, we can finally whisk this up. Now, I have conveniently already made the clone of this. Because, you know, can't change state. That's really bad. And we've got to let that finish cooking. This function has to complete. Well, that's going on. I thought it would be nice to add some cheese to the omelet. So, we need to grate this. But, guys, we have a problem. I can't do this in a functional way. This isn't something I can just make a copy of. So, changing this changes the global state. Oh, but, you see, functional programming does have a solution to that. It's called the monad. And, well, to be fair, monads are used for more than just this. We'll just encapsulate this in a monad. It doesn't matter anymore. We're going to change the state, but it's fine, because we're not going to change the state. Because reasons. And this should be getting pretty close to finished. So, now we want to add the cheese. Oh, right. We can't change that state. We have to... Everything you've seen up to this point has to be copied again. Or rather, I mean, really, the state of this has to be copied again. But, yeah. No, I'm not going to do that. This video has been cut down for you extensively, but I'm at, like, 23 minutes at this point. So, there's enough in the garbage collector. There's enough duplication of data just to avoid some global state change that is somehow bad. Nah. That was way easier than copying this whole thing, just to avoid a state change. I will do some more of these, each of them covering a slightly different point. Some of them are going to build up a top of this in a few ways, especially the one dealing with concurrency. You don't have to avoid global state to get an efficient concurrent program. The problem isn't global state. The problem is the approach. In fact, if you know enough about how Monads work, you still have global state. And encapsulating it doesn't make it not global. So, yeah. And that form introduces its own problems, anyways. But that's for another video. I'm going to eat this omelet. You, have a good day.