# Declarative and Imperative Knowledge

One key thing to write beautiful program is to increase the declarative knowledge by programming towards abstraction (such as class, function and variable) with imperative knowledge/implementation (such as IF statements and loops) encapsulated.

> The contrast between (mathematics) function and (programming language) procedure a is a reflection of the general distinction between describing properties of things and describing how to do things, or, as it is sometimes referred to, the distinction between declarative knowledge and imperative knowledge. In mathematics we are usually concerned with declarative (`what is`) descriptions, whereas in computer science we are usually concerned with imperative (`how to`) descriptions.

From [SICP 1.1.7](https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-10.html#%_sec_1.1.7)

> Declarative and imperative descriptions are intimately related, as indeed are mathematics and computer science. For instance, to say that the answer produced by a program is `correct` is to make a declarative statement about the program. There is a large amount of research aimed at establishing techniques for proving that programs are correct, and much of the technical difficulty of this subject has to do with negotiating the transition between imperative statements (from which programs are constructed) and declarative statements (which can be used to deduce things). In a related vein, an important current area in programming-language design is the exploration of so-called very high-level languages, in which one actually programs in terms of declarative statements.

From SICP [footnote](https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-10.html#footnote_Temp_32)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://nicologies.gitbook.io/awesome-programming-knowledge/writing-better-code/books/sicp/declarative-and-imperative-knowledge.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
