So what is functional programming?
Functional programming is all about separation of concerns, which object oriented programming does
as well, right?
It's all about packaging our code into separate chunks so that everything's well organized in each part
of our code.
And each part is organized in a way that makes sense based on functionality.
So when we say separation of concerns, we mean each part concerns itself with one thing that it's good
at.
We remember in our object oriented programming section how we had two classes to divide up attributes
and methods of, let's say, a wizard class and an Archer class.
And functional programming has this idea as well of separating concerns, but they also separate data
and functions.
That's how a functional programmer views the world.
Instead of combining methods and attributes, we separate them up because there are two separate things.
There's data and this data gets interacted and acted upon.
But we're not going to combine both data and functions as one piece in an object like we saw with object
oriented programming.
Now there is no correct definition for what is and isn't functional.
But generally functional languages have an emphasis on simplicity, where data and functions are concerned,
because in most functional programming paradigms we don't have this idea of classes and objects.
Instead, functions operate on well defined data structures like lists and dictionaries that we saw
rather than belonging that data structure to an object.
But at the end of the day, the goal of a functional programming paradigm is the same as object oriented
paradigm.
It's the idea of making our code clean and understandable, easy to extend.
That is, we can grow our code and make it better and better and have others come and extend our code.
It's easier to maintain.
It keeps our code dry so that we are not repeating ourselves as well as keeping our code memory efficient
because we're not storing information all over the place.
Now, when we come to functional programming, we have a very important pillar.
And unlike object oriented programming, where we have those four pillars of encapsulation, abstraction,
inheritance and polymorphism.
If you want to break things down in functional programming, it all comes down to this concept of pure
functions, and this is something that we're going to explore over the next couple of videos.
But the idea here is that there's a separation between data of a program and the behavior of a program.
So let's find out more about pure functions.
What do they mean?
What are they?