Declarative Programming Techniques

Declarative programming is important because of two properties:

(Van Roy and Haridi 2004, 111 chap.3)

Definitions

Component

Let us define a component as a precisely delimited program fragment with well-defined inputs and outputs. A component can be defined in terms of a set of simpler components. For example, in the declarative model a procedure is one kind of component. The application program is the topmost component in a hierarchy of components. The hierarchy bottoms out in primitive components which are provided by the system.

(Van Roy and Haridi 2004, 112 chap.3)

Recursive Function Definitions

The basic technique for writing declarative programs is to consider the program as a set of recursive function definitions, using higher-order programming to simplify the program structure. A recursive function is one whose definition body refers to the function itself, either directly or indirectly. Direct recursion means that the function itself is used in the body. Indirect recursion means that the function refers to another function that directly or indirectly refers to the original function.

(Van Roy and Haridi 2004, 113 chap.3)

Higher-Order Programming

Higher-order programming means that functions can have other functions as arguments and results.

(Van Roy and Haridi 2004, 113 chap.3)

What is Declarativeness?

A Classification of Declarative Programming

The first level of classification is based on the expressiveness.

  • A Descriptive Declarativeness: The least expressive.
  • A Programmable Declarativeness: As expressive as a Turing Machine. there are two fundamentally different ways to view this category.

Specification Languages

References:

Van Roy, Peter, and Seif Haridi. 2004. Concepts, Techniques, and Models of Computer Programming. MIT press.

Backlinks: