Declarative programming
Encyclopedia
|
| Tutorials | Encyclopedia | Dictionary | Directory |
|
Declarative programming
In computer science, declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow.[1] It attempts to minimize or eliminate side effects by describing what the program should accomplish, rather than describing how to go about accomplishing it[2]. This is in contrast from imperative programming, which requires a detailed description of the algorithm to be run. Declarative programming consider 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 http://www.cse.unsw.edu.au/~pls/damp09/. Common declarative languages include those of regular expressions, logic programming and functional programming.
DefinitionDeclarative programming is often defined in a number of different ways:
These definitions are roughly equivalent. OverviewDeclarative programming is an umbrella term that includes a number of more well-known programming paradigms. Functional programming, and in particular purely functional programming, attempts to minimize or eliminate side effects, and is therefore considered declarative. Most functional languages, 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 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. Because the "how" is not required to actually be the steps followed at all, functional programming is still usually considered a form of declarative programming. 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. Like functional programming, many logic programming languages permit side effects, and as a result are not strictly declarative. Some well-known examples of declarative DSLs include regular expressions, CSS, 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, XSLT, SVG, or user interface markup languages are often declarative. HTML, for example, only describes what should appear on a webpage.
Makefiles, for example, specify dependancies in a declarative fashion http://phoenix.labri.fr/wiki/doku.php?id=an_overview_on_dsls, 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). See also
ReferencesExternal links
cs:Deklarativní programování de:Deklarative Programmierung el:????????? ??????????????? es:Programación declarativa fr:Programmation déclarative ko:??? ????? it:Programmazione dichiarativa ja:?????????? pt:Programação declarativa ru:????????????? ???????????????? sv:Deklarativ programmering uk:???????????? ????????????? zh:????? Source: Wikipedia | The above article is available under the GNU FDL. | Edit this article
|
|
top
©2008-2009 TutorGig.com. All Rights Reserved. Privacy Statement