Declarative programming

In computer science, declarative programming is a programming paradigm (a style of building the structure and elements of computer programs), that expresses the logic of a computation without describing its control flow - wikipedia

Many languages that apply this style attempt to minimize or eliminate side effects by describing what the program must accomplish in terms of the problem domain, rather than describe how to accomplish it as a sequence of the programming language primitives (the how being left up to the language's implementation). This is in contrast with imperative programming, which implements algorithms in explicit steps.

Declarative programming often considers programs as theories of a formal logic, and computations as deductions in that logic space. Declarative programming may greatly simplify writing parallel programs.

Common declarative languages include those of database query languages (e.g., SQL, XQuery), regular expressions, logic programming, functional programming, and configuration management systems.

# Definition

Declarative programming is often defined as any style of programming that is not imperative programming. A number of other common definitions attempt to define it other than simply contrasting it with imperative programming. For example - wikipedia

- A high-level program that describes what a computation should perform. - Any programming language that lacks side effect (computer science)|side effects (or more specifically, is referential transparency (computer science)|referentially transparent) - A language with a clear correspondence to mathematical logic.

Declarative programming contrasts with imperative and procedural programming. Declarative programming is a non-imperative style of programming in which programs describe their desired results without explicitly listing commands or steps that must be performed.

Functional programming and logical programming languages are characterized by a declarative programming style. In logic programming, programs consist of logical statements, and the program executes by searching for proofs of the statements.

In a pure functional language, such as Haskell (programming language), all functions are pure function, and state changes are only represented as functions that transform the state, which is explicitly represented as a First-class citizen object in the program.

Although pure functional languages are non-imperative, they often provide a facility for describing the effect of a function as a series of steps. Other functional languages, such as Lisp (programming language), OCaml and Erlang (programming language), support a mixture of procedural and functional programming.

Some logic programming, such as Prolog, and database query languages, such as SQL, while declarative in principle, also support a procedural style of programming.

# Subparadigms

Declarative programming is an umbrella term that includes a number of better-known programming paradigms - wikipedia

# See also