Declarative programming: Difference between revisions

Content deleted Content added
same thing said twice with different refs. Deleted one instance but kept ref
Subparadigms: make main article links more prominent using {{main}}
Line 30:
 
===Constraint programming===
{{main|Constraint programming}}
[[Constraint programming]] states relations between variables in the form of constraints that specify the properties of the target solution. The set of constraints is [[solver (computer science)|solved]] by giving a value to each variable so that the solution is consistent with the maximum number of constraints. Constraint programming often complements other paradigms: functional, logical, or even imperative programming.
 
===Domain-specific languages===
{{main|Domain-specific language}}
Well-known examples of declarative [[___domain-specific language]]slanguages (DSLs) include the [[yacc]] parser generator input language, [[QML]], the [[Make (software)|Make]] build specification language, [[Puppet (software)|Puppet]]'s configuration management language, [[regular expression]]s, [[Datalog]], [[answer set programming]] 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]], [[XAML]], [[XSLT]] or other [[user-interface markup language]]s are often declarative. HTML, for example, only describes what should appear on a webpage - it specifies neither [[control flow]] for rendering a page nor the page's possible [[human-computer interaction|interactions with a user]].
Line 40 ⟶ 42:
 
===Functional programming===
{{main|Functional programming}}
Functional programming languages such as [[Haskell (programming language)|Haskell]], [[Scheme (programming language)|Scheme]], and [[Standard ML|ML]] evaluate expressions via function application. Unlike the related but more imperative paradigm of [[procedural programming]], functional programming places little emphasis on explicit sequencing. Instead, computations are characterised by various kinds of recursive [[higher-order function]] application and [[Function composition (computer science)|composition]], and as such can be regarded simply as a set of mappings between [[Domain_of_a_function|___domain]]s and [[codomain]]s. Many functional languages, including most of those in the ML and Lisp families, are not [[purely functional programming|purely functional]], and thus allow the introduction of [[side effect (computer science)|stateful effects]] in programs.
 
Line 47 ⟶ 50:
 
===Logic programming===
{{main|Logic programming}}
[[Logic programming]] languages, such as [[Prolog]], [[Datalog]] and [[answer set programming]], compute by proving that a goal is a logical consequence of the program, or by showing that the goal is true in a model defined by the program. Prolog computes by reducing goals to subgoals, top-down using [[backward chaining |backward reasoning]], whereas most Datalog systems compute bottom-up using [[forward chaining |forward reasoning]]. Answer set programs typically use [[Boolean SAT solver |SAT solvers]] to generate a model of the program.
 
===Modeling===