Skip to content
BENIBIX Learn

Functional Programming

Development🧭 Programming ParadigmsFunctional Programming

Also known as FP, Functional Style

Code that hands back new values from small functions. Nothing changes in place.

Think of it like

Think of it like a juice press. Put in apples, get out juice, and the press never changes.

Example

Lucy turns a list of prices into prices with tax using map. The old list stays as it was, and a new list comes back.

Why it matters

Code that changes nothing outside itself is easier to test. It is also safer when many things run at once.

Definition

Functional programming builds programs out of small functions. Each takes inputs and gives back outputs. A function in this style does not change anything outside itself. Data is not edited in place; you make a new copy with the change. Functions can be passed around like any other value. Haskell is built on it, and JavaScript and Python let you use it.

Common mistake

Thinking it means no state at all. Real programs still save files and show screens; the style keeps that work in a few places.

Key takeaways

  1. 1
    Small functions. Inputs in, outputs out.
  2. 2
    No changes in place. Make a new copy instead.
  3. 3
    Functions are values. Pass them around freely.

Compare