# Declarative Programming

> Writing code that says what you want, and lets the tool work out how.

**Field:** Software Development  
**Category:** Programming Paradigms  
**Also known as:** Declarative Code

## Think of it like

Think of it like ordering at a café. You say what you want, and the cook works out how.

## Definition

Declarative programming means writing code that says what result you want. It does not list the steps. The language or tool works out the steps for you. SQL is the best-known example: you ask for rows, and the database picks how to find them. HTML and CSS work this way too. It often makes code shorter and easier to read.

## Example

Lucy asks the database for each order over 50 euros. She never says how to find them. The database picks the way.

## Example code

```sql
SELECT name FROM orders WHERE total > 50;
```

This says which rows are wanted, not how to find them.

## Why it matters

Saying what you want leaves room for the tool to find a faster way than you would.

## Common mistake

Thinking declarative code has no steps. The steps are still there, just hidden inside the tool.

## Three principles

- **Say what.** Not how.
- **The tool decides.** It picks the steps.
- **Shorter code.** Often easier to read.

## Related terms

- [Imperative Programming](https://learn.benibix.com/term/development/imperative-programming)
- [Programming Paradigm](https://learn.benibix.com/term/development/programming-paradigm)
- [Structured Query Language (SQL)](https://learn.benibix.com/term/development/sql)
- [Functional Programming](https://learn.benibix.com/term/development/functional-programming)

## Told apart from

- [Imperative vs Declarative Programming](https://learn.benibix.com/compare/imperative-vs-declarative-programming): Imperative code lists the steps to reach an answer, one change at a time. Declarative code says what answer you want and lets the tool pick the steps.

---

Source: https://learn.benibix.com/term/development/declarative-programming
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
