What Is Functional Programming?

In this lesson, you’ll learn that functional programming is a programming style that avoids side effects by performing computation with the evaluation of functions and relying heavily on immutable data structures. By using this programming style, you can reduce the liklehood of bugs and make sure that your programs are easier to maintain.

You’ll also look at an example data set that you’ll later use to get a concrete idea of how you can choose data structures when using a functional programming approach.

00:00 All right. In this first part of the tutorial, I want to talk a little bit about what functional programming is. Then, we’re also going to talk about how we can represent different data sets using a functional programming style, using immutable data structures, and why that would be a good idea and the benefits you can get from that. So, functional programming—what is that?

00:24 Well, it’s a programming technique that avoids side effects in your programs by

00:32 performing computation, mainly through the evaluation of functions, and it’ll rely heavily on immutable

00:41 data structures as well. So, I know that was a mouthful and I hope in the course of this tutorial, things will become a little bit more clear, but basically, functional programming is a programming style—just like object-oriented programming—that has the potential benefit that it can reduce the likelihood of bugs in your programs, and it can potentially make them more maintainable, as a result.

01:05 So admittedly, the whole concept is a little bit difficult to pin down because when we talk about functional programming languages, a lot of times, you know—a modern functional programming language would maybe be Haskell—and it’s a little bit hard to pin down what really makes a programming language functional or not—or a coding style functional or not—versus some of these additional features that these modern functional programming languages support.

01:31 So, the definition I’m personally going to stick to in these tutorials is that, well, functional programming is a programming paradigm, a style of programming, where we mainly use immutable data structures and we try to avoid side effects by doing all of our computation using the evaluation of mathematical functions.

01:53 That’s based on the definition that Wikipedia uses, which I think is pretty general. And I think that’s good because it leaves out all of the extra stuff that you would maybe think is part of functional programming, like the advanced typing systems in languages like Haskell.

02:10 So, just to give you an idea of what we’re going to be focusing on in these tutorials, if you feel like, “Well, what’s this guy talking about? I need to see some code,” then we’re going to get to that in a minute. Because, really, I think this is the best way to learn this stuff, anyway. It’s usually not much help to just, you know, try and understand these concepts from an abstract perspective just by reading about them, but you need some stuff to play with.

02:33 At least, that’s how I learn these things. I always want something that I can engage with and that I can work with. All right. So, to illustrate some of these concepts and to teach you about some of the core functional programming principles and how you can apply them with Python, I was thinking of a little data set that I wanted to use.

02:54 The data set I want to use in these examples is this list here of scientists that worked in different fields. They all have a Nameyou can see here, Ada Lovelace, Emmy Noether. They worked in different fields: math, physics

03:11 all right—physics, right.

03:14 They were born in different years. And then some of them, they won Nobel Prizes. So, it’s just a simple list here with some interesting properties that we can work with, just so we have something, you know, some data set that we can look at and that we can then work with in a functional programming style. Well, I have this beautiful table here.

03:35 It’s actually a Markdown syntax, so this would render nicely if I wasn’t viewing it inside my editor. But, of course, the question is—okay, I have this list of things.

03:44 This is maybe something that I extracted somewhere, somebody typed that into an Excel sheet for me. How do I get this into my Python program? And how do I represent this exact same data inside my Python program?

03:57 This is what we’re going to focus on next.

Avatar image for Kevin Dienst

Kevin Dienst on July 15, 2019

I appreciate that you listed numerous successful female historical figures whom had a major impact on their respective fields in this tutorial. It may seem minor, but recognizing the contributions of women in STEM is essential; even in a small video about functional programming. ;-)

Become a Member to join the conversation.