Skip to content
BENIBIX Learn

Declarative Programming

Development🧭 Programming ParadigmsParadigm Basics

Also known as Declarative Code

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

Think of it like

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

Example

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

Why it matters

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

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 code

sql
SELECT name FROM orders WHERE total > 50;
This says which rows are wanted, not how to find them.

Common mistake

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

Key takeaways

  1. 1
    Say what. Not how.
  2. 2
    The tool decides. It picks the steps.
  3. 3
    Shorter code. Often easier to read.

Compare