Imperative and declarative programming are similar to the imperative and declarative moods in English writing. The imperative mood is basically for issuing commands like "sit down" or "be quiet". The declarative mood indicates what is occurring, without strictly defining the steps to make that action occur ("John is walking to the store" rather than "left foot, right foot, left foot, ...").
Imperative programming tends to be low-level, specifying exactly what should be done, step-by-step. Declarative programming tends to be higher-level, specifying the outcome without necessarily dictating how that outcome should be achieved.
Imperative and declarative programming are similar to the imperative and declarative moods in English writing. The imperative mood is basically for issuing commands like "sit down" or "be quiet". The declarative mood indicates what is occurring, without strictly defining the steps to make that action occur ("John is walking to the store" rather than "left foot, right foot, left foot, ...").
Imperative programming tends to be low-level, specifying exactly what should be done, step-by-step. Declarative programming tends to be higher-level, specifying the outcome without necessarily dictating how that outcome should be achieved.
An example imperative snippet:
An example declarative snippet:
This got me paranoid for a sec 😅
I'm so used to
i
😂Yeah I use double-indices like this because it makes it easier to ctrl-F for them!