logo

What is Functional Programming?

Functional programming is a style where you build programs by composing functions. Instead of changing data, you create new data from existing data.

Key principles:

  • Pure functions - Same inputs always give same outputs, no side effects
  • Immutability - Don't modify data, create new versions
  • Functions as values - Pass functions around like any other data

Python isn't purely functional, but it borrows many functional ideas. Functions like map(), filter(), and reduce() come from the functional world.

Why bother? Functional code tends to be easier to test, easier to parallelize, and often more concise. It's especially powerful for data transformation.

You don't have to go all-in. Even using a few functional techniques makes your Python cleaner.

I explain functional thinking in my Functional Programming course.