This is an introduction to a series on functional programming in data engineering using Python. Here I lay out some of the fundamental concepts and tools found in functional programming using Python code.
What is functional programming?
Functional programming is a declarative type of programming used to build bug-resistant programs and applications through the use of functions.
In other words, it’s a computing paradigm that emphasizes the use of pure functions and immutable data structures for mitigating side effects instead of specifying the steps on how to perform tasks (imperative programming).
What is a function?
A function is an object that turns inputs into outputs.
You can have functions that perform simple operations where they simply convert inputs to outputs. You can also have more sophisticated functions that are linked with other functions in a complex system. In such cases, functions can be:
- An input (parameter for another function)
- An output (result from another function)
Also, functions:
- are treated as first-class citizens (first-class functions)
- can be passed into other functions as arguments or returned from other functions (higher-order functions)
- can be connected with other functions to form new ones (function composition)
- should be designed to work with other functions (reusability)