Comparison
AbstractionvsDeclarative vs imperative
Abstraction
you stopped caring which of the three implementations you had, and the code got shorter in every caller.
A name for a capability that hides which particular thing provides it, so callers depend on the promise rather than the machinery. The word is used loosely for both the act — pulling a common shape out of two similar things — and the artefact, the interface or type that results. The cost is that every abstraction is a bet that the two things really are the same, and the ones that turn out wrong are more expensive to undo than the duplication they replaced.
Full entry →Declarative vs imperative
one version says what the result should be and the other lists the steps, and only one of them can be optimised for you.
Imperative code specifies the steps; declarative code specifies the outcome and leaves the steps to something else — SQL, a build tool, a UI framework, a reconciliation loop. The gain is that the executor can change strategy without you rewriting anything; the loss is that you cannot see what it is doing when it is slow or wrong. Nearly every abstraction argument in this corpus is a version of this trade.
Full entry →