Declarative vs. Imperative Programming
Last updated
Last updated
Programming can broadly be categorized into two paradigms: imperative and declarative.
Imperative programming expresses how problems should be solved, through the specification of algorithms which contain step-by-step instructions. State is updated by executing these instructions (e.g. fetch this data, then perform this operation, then this one).
Declarative programming describes what a program should accomplish, rather than how. A declarative program only needs to specify the expected result and core logic, without having to direct the program's control flow.
Every general-purpose blockchain since Ethereum has used the imperative programming model, and it remains the prevailing paradigm for framing problems in the blockchain space. Because imperative blockchains rely on the linear execution of code to achieve state changes, the sole method for interacting with them is via imperative instructions (e.g. transactions and smart contracts).
Meanwhile declarative programming, while well-understood in the field of computer science, has thus far been neglected as a paradigm for blockchain architecture.
However, we are now seeing a wave of interest in declarative approaches due to the many benefits the paradigm offers.