Declarative Programming
Declarative programming describes what the result should be rather than specifying the step-by-step procedure to compute it. SQL, HTML, CSS, configuration languages, and logic programming are declarative: you state constraints or desired outcomes and let the runtime determine execution.
itSoftware engineering | OpenSkills.info
Intro
Declarative Programming
Declarative programming describes the result you want. You express facts, rules, relationships, constraints, or a desired state. An engine chooses how to produce that result.
Imperative programming describes a sequence of operations. You control more of the path from the starting state to the result. The distinction is about where control lives, not which syntax a language uses.
You already meet declarative programming in common tools. A SQL query describes a result set. A CSS rule describes which properties apply to matching elements. A Make rule connects a target to its prerequisites. A Terraform configuration describes managed infrastructure. A Kubernetes configuration describes objects that a control system should maintain.
The central trade
Continue the course
This section is part of the paid course.
See pricing to subscribe, or log in if you already have access.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://www.haskell.org/onlinereport/haskell2010/
Supports
- Haskell expressions, function definitions, pattern bindings, types, and modules
- Expression-led functional programming as a declarative form
- https://www.postgresql.org/docs/current/tutorial-select.html
Supports
- SQL SELECT lists, table lists, Boolean qualifications, sorting, and duplicate removal
- Queries that specify result properties without fixing a physical access path
- https://www.postgresql.org/docs/current/using-explain.html
Supports
- Query plans, plan nodes, cost estimates, scan strategies, and runtime inspection
- Execution cost depending on engine plans and data access rather than query length
- https://www.w3.org/TR/css-cascade-5/
Supports
- CSS declarations, origins, importance, cascade layers, specificity, scope, and order
- Rule resolution that assigns property values to elements
- https://www.gnu.org/software/make/manual/make.html#Rule-Introduction
Supports
- Make rules composed of targets, prerequisites, and recipes
- Engine decisions about which targets require rebuilding
- https://developer.hashicorp.com/terraform/language
Supports
- Terraform as a declarative language for resources, expressions, and dependencies
- Operation ordering from implicit and explicit relationships rather than file order
- https://developer.hashicorp.com/terraform/intro
Supports
- Desired infrastructure state, resource graphs, state tracking, and change selection
- Version-controlled and reusable infrastructure configuration
- https://developer.hashicorp.com/terraform/cli/commands/plan
Supports
- Previewing proposed infrastructure changes before applying them
- Comparing configuration with prior and remote object state
- https://kubernetes.io/docs/tasks/manage-kubernetes-objects/declarative-config/
Supports
- Declarative creation and update of Kubernetes objects from configuration files
- Diff, apply, live configuration, merge behavior, and management tradeoffs
- https://kubernetes.io/docs/concepts/architecture/controller/
Supports
- Control loops that compare desired and current cluster state
- Repeated action that moves observed state toward desired state
