Functional Programming (FP)

A programming paradigm where programs are constructed by applying and composing functions.

Functional Programming (FP) is a paradigm where programs are constructed by applying and composing functions. Functions are first-class citizens—passed as arguments, returned from functions, stored in variables.

Core principles:
1. Pure Functions: Same input always produces same output, no side effects
2. Immutability: Data never changes after creation
3. First-Class Functions: Functions are values
4. Higher-Order Functions: Functions taking or returning functions
5. Recursion: Preferred over loops

        graph LR
  Center["Functional Programming (FP)"]:::main
  Rel_object_oriented_programming["object-oriented-programming"]:::related -.-> Center
  click Rel_object_oriented_programming "/terms/object-oriented-programming"
  Rel_procedural_programming["procedural-programming"]:::related -.-> Center
  click Rel_procedural_programming "/terms/procedural-programming"
  Rel_agile_methodology["agile-methodology"]:::related -.-> Center
  click Rel_agile_methodology "/terms/agile-methodology"
  classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
  classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
  classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
  classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
  linkStyle default stroke:#4b5563,stroke-width:2px;

      

🧠 Knowledge Check

1 / 1

🧒 Explain Like I'm 5

Imagine a math [function](/en/terms/function) like f(x) = x + 2. You put in 3, you always get 5. Functional programming means your code works like math—reliable, no surprises, and you can combine simple functions to build complex ones!

🤓 Expert Deep Dive

Core concepts include immutability, first-class functions, higher-order functions, and lazy evaluation. Popular in systems requiring high concurrency and reliability (e.g., Haskell, Elixir, or JS with libraries like Ramda).

📚 Sources