- Concurrent computing
- Relativistic programming
- Declarative (contrast: Imperative)
- Function-level (contrast: Value-level)
- Imperative (contrast: Declarative)
- Non-structured (contrast: Structured)
- Parallel computing
- Programming in the large / small
- Structured (contrast: Non-structured)
- Value-level (contrast: Function-level)
In computer science, declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow. Many languages applying this style attempt to minimize or eliminate side effects by describing what the program should accomplish, rather than describing how to go about accomplishing it. This is in contrast with imperative programming, which requires an explicitly provided algorithm.
Declarative programming often considers programs as theories of a formal logic, and computations as deductions in that logic space. Declarative programming has become of particular interest recently, as it may greatly simplify writing parallel programs.
Declarative programming is often defined as any style of programming that is not imperative. A number of other common definitions exist that attempt to give the term a definition other than simply contrasting it with imperative programming. For example:
- A program that describes what computation should be performed and not how to compute it
- Any programming language that lacks side effects (or more specifically, is referentially transparent)
- A language with a clear correspondence to mathematical logic.
These definitions overlap substantially.
Declarative programming is an umbrella term that includes a number of better-known programming paradigms.
In constraint programming relations between variables are stated in the form of constraints, specifying the properties of a solution to be found. The set of constraints is then solved by giving a value to each variable so that the solution is consistent with the maximum number of constraints.
Constraint programming is often used as a complement to other paradigms: functional, logical or even imperative programming.
Some well-known examples of declarative domain specific languages (DSLs) include CSS, regular expressions, and a subset of SQL (SELECT queries, for example). DSLs have the advantage of being useful while not necessarily needing to be Turing-complete, which makes it easier for a language to be purely declarative.
Many markup languages such as HTML, MXML, SVG, XAML, XSLT or other user interface markup languages are often declarative. HTML, for example, only describes what should appear on a webpage and does not specify the possible interactions with it.
Some software systems now combine traditional user interface markup languages such as HTML with declarative markup that defines what (but not how) the back-end server systems should do to support the declared interface. Such systems, typically using a domain specific XML namespace, include abstractions of SQL database syntax or parameterised calls to web services using REST and SOAP.
Functional programming, and in particular purely functional programming, attempts to minimize or eliminate side effects, and is therefore considered declarative. Most functional languages, such as Scheme, Objective Caml and Unlambda, however, do permit side effects in practice.
While functional languages typically do appear to specify "how", a compiler for a purely functional programming language is free to extensively rewrite the operational behavior of a function, so long as the same result is returned for the same inputs. This can be used to, for example, make a function compute its result in parallel, or to perform substantial optimizations (such as deforestation) that a compiler may not be able to safely apply to a language with side effects.
Makefiles, for example, specify dependencies in a declarative fashion, but include an imperative list of actions to take as well. Similarly, yacc specifies a context free grammar declaratively, but includes code snippets from a host language, which is usually imperative (such as C).
Logic programming languages such as Prolog state and query relations. The specifics of how these queries are answered is up to the implementation and its theorem prover, but typically take the form of some sort of unification. Like functional programming, many logic programming languages permit side effects, and as a result are not strictly declarative.
- Category:Declarative programming languages
- Comparison of programming paradigms
- Constraint programming
- Domain-specific language
- Functional programming
- Imperative programming (contrast)
- Logic programming
- ^ Lloyd, J.W., Practical Advantages of Declarative Programming
- ^ Declarative language in The Free On-line Dictionary of Computing, Editor Denis Howe.
- ^ http://www.cse.unsw.edu.au/~pls/damp09/
- ^ http://www.cse.unsw.edu.au/~chak/papers/diss.ps.gz
- ^ http://phoenix.labri.fr/wiki/doku.php?id=an_overview_on_dsls
- Frans Coenen. Characteristics of declarative programming languages. 1999.
- Olof Torgersson. A Note on Declarative Programming Paradigms and the Future of Definitional Programming. 1996.
Wikimedia Foundation. 2010.
Look at other dictionaries:
Programming paradigm — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concu … Wikipedia
Programming language — lists Alphabetical Categorical Chronological Generational A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that… … Wikipedia
Declarative — may refer to: Declarative learning, acquiring information that one can speak about Declarative memory, one of two types of long term human memory Declarative programming, a computer programming programming paradigm A type of sentence… … Wikipedia
Programming in the large and programming in the small — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computin … Wikipedia
Declarative Referential Integrity — (DRI) is one of the techniques in the SQL database programming language to ensure data integrity. Contents 1 Meaning in SQL 2 Product specific meaning 3 References 4 … Wikipedia
declarative language — programming language intended for declarative statements (statements that are for the compiler and NOT part of the actual program such as DDL) … English contemporary dictionary
List of programming languages by category — Programming language lists Alphabetical Categorical Chronological Generational This is a list of programming languages grouped by category. Some languages are listed in multiple categories. Contents … Wikipedia
Constraint programming — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computin … Wikipedia
Comparison of programming paradigms — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computin … Wikipedia
Data-centric programming language — defines a category of programming languages where the primary function is the management and manipulation of data. A data centric programming language includes built in processing primitives for accessing data stored in sets, tables, lists, and… … Wikipedia