Transcript from the "Course Agenda" Lesson
>> Kyle Simpson: Let's talk about our topic today. What on earth is functional-light programming? Completely made up term that I came up with to try to describe what I hope is slightly more approachable, almost remedial, look at this much bigger and much more complex notion of functional programming. Some of you may be very, very familiar with functional programming already.
[00:00:30] And for those of you that are, for those of you that feel like you've cut your teeth on functional programming, you were a lisper back in the 70s or whatever. If that's you listening to the tame, I apologize that some of this may feel very remedial to you.
[00:00:44] But, I think we have a problem, because I think functional programming is one of the most powerful set of techniques that we have in programming, but I think it has been presented in a way that is completely off putting to most developers. And I think if you cornered somebody who has been steeped in the traditions in the academics around functional programming.
[00:01:04] If you really ask them to admit they would say, it was a pretty high barrier to entry. It's like a really, really powerful tool. It's like walking into a workshop and seeing a chainsaw with all kinds of fancy features on it and things like that. Maybe it's digital and has an LCD display, and you're like, I don't have any clue how to do that.
[00:01:22] I just got a piece of wood I need to cut and I have no idea how to use this thing. It's a high learning curve. So the workshop today, my goal is to try to get at some of those fundamental principles. Without wrapping any of it, in any of that sort of academic notational terminology, things like that.
[00:01:41] We're not gonna talk about monads. To be honest with you I'm not even fully sure I understand what a monad is. I can kind of fumble around with some of those sorts of things because I can't even tell you how many talks that claim to be the talk that's gonna teach functional programming.
[00:01:57] And I do not claim that this talk is going to teach you functional programming, this workshop is not going to teach you functional programming but it is going to teach you the basis upon which functional programming can be built from the observational perspective rather than from the academic perspective.
[00:02:14] That's why I call it functional-light programming. These are like walking into a workshop and saying, well, I don't understand that crazy complicated chainsaw thing. But I just have a tiny little piece of wood that I need to cut. Okay, here's the little handsaw. It's much much simpler, it's much more remedial.
[00:02:31] It doesn't take a lot of learning. You can figure out how to do this. The principles of a handsaw are the same principles upon which a chainsaw is build. But obviously, the chainsaw is much more complex because it's designed to handle much more complex problems. So what we're doing here is a start.
[00:02:47] It's not all of functional programming, but it's a start towards understanding where we need to go if we do want to be better with our functional programming practices. This represents my journey to understanding functional programming if I really have to boil it down. These are the sorts of things that, without ever understanding any of the terminology, I gleaned some of these concepts from programming and from looking at other people's code.
[00:03:09] And I'm just trying to simply lie some of that stuff out to help you gain a better understanding. So let's quickly look at what we're going to talk through over the next several hours. First, we're gonna talk about what pure functions are, and even before that we have to understand, obviously, what a not pure function is.
[00:03:25] So we're gonna look at the notion of not pure versus pure functions. We're gonna look at composition. Already starting to sound like a slightly fancy word, like a slightly fancy terminology. I promise I'm gonna help you understand what that word is. I chose that word as opposed to a number of other words that would make no sense at all.
[00:03:42] The famous quote about monads is like, they're just a bi factor in the category then they'll factor or some crazy thing like we're not gonna use any of that stuff. Okay, so don't get too scared with the terminology. Immutability, the notion that we have something that doesn't change.
[00:03:58] We treat it immutable, we can even make it immutable. So we're gonna look at what immutability is, just from a very basic sense. Closure. Closure is probably the most important programming concept ever invented. I know that's a big claim to make cuz there are a whole bunch of great programming concepts that have been created and we use lots and lots of great tools in our programming, but I would say that closure is the most core.
[00:04:24] The most important, the first place that we really need to grasp. So closure, we definitely wanna take a look just briefly, at understanding what that means and how we use that. Some of you may have already seen other courses and other books I've written on it. I go into that topic in much more detail, we're not gonna go into a lot of detail about it but just to present to you, the way that we use closure from the functional programming perspective.
[00:04:47] Recursion, is another one of those topics that has usefulness outside of functional programming, but is also very heavily related to functional programming. So I wanna have a basis understanding of recursion. Recursion is one of those things I know that is very easy to kinda scared of. I've talked to the students, the college students, recently, who have told me things like I just can't even possibly wrap my brain around recursion.
[00:05:12] And that's a shame. I'm saddened by that. I'm saddened by this notion that we can't figure out some basic way of explaining this. So this is my attempt to help you kind of get your brain a little more wrapped in that direction. Now we're gonna look at a set of things, these are going to build on higher order.
[00:05:30] So slightly higher order patterns on top of these basic fundamentals but they really are kind of the main takeaway from our workshop today. So we're gonna look at taking a list of values and performing a set of transformations on them. For those of you that have heard of functional programming before, transformation is done with maps, so we're gonna look at transformation and then look at the map.
[00:05:51] Then we're gonna look at exclusion, excluding items from a list. Paring down a list to a smaller set of items based upon some condition, that goes by the name of filter. Then we're gonna look at composing items from a list into either a smaller list or even down to a single value.
[00:06:10] Composing values together. Now, I don't mean composing lists together. We're not actually gonna take a very close look at that. But that's pretty straightforward as well because we can concatenate two lists together. So there are fundamental list operations that really don't necessarily show up a ton of times in functional programming.
[00:06:52] We're gonna find out that list iteration is actually an impure action. So from a purely theoretical perspective, functional programming they turn their eyes, turn their nose up at something like list iteration. So I just wanna show you the notion of list iteration, so that we understand why it's when we watch Sesame Street as kids, and they're like one of these things just doesn't belong.
[00:07:16] List iteration's gonna be that thing that just doesn't belong, but we need to understand the other things before we understand why. List iteration doesn't belong. So that's our set of topics that we're gonna go through. There are several exercises that we'll spend some time on and we will take some breaks throughout our discussion as well.