DEV Community 👩‍💻👨‍💻

Discussion on: Functional Programming vs OOPS : Explain Like I'm Five

gmartigny profile image
Guillaume Martigny

Functional is based on functions and OOP (Object Oriented Programming) is based on objects. It's two distinct ways to write code. It's not the only two nor they are mutually exclusive. While OOP tends to replicate the real world with objects you act on, functional is way too abstract for a five year old. It's more like a flow of actions rather than objects interacting with each others.

Consider this recipe:


const crepe = step([
  () => [getFlour(300), getEggs(3), getMilk(60)],


const flour = new Ingredient("flour", 300);
const eggs = new Ingredient("egg", 3);
const milk = new Ingredient("milk", 60);

const crepe = new Recipe();
crepe.mix(flour, eggs, milk).cook();