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
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
Last updated