Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Declarative programming
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Subparadigms== Declarative programming is an [[umbrella term]] that includes a number of better-known [[programming paradigm]]s. ===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 languages (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]]. {{As of | 2013}}, some software systems{{Which|date=July 2020}} 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]], may include abstractions of SQL database syntax or parameterized calls to web services using [[representational state transfer]] (REST) and [[SOAP]].{{Citation needed|date=July 2020}} ===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. ===Hybrid languages=== {{see also|Multi-paradigm programming language}} Makefiles, for example, specify dependencies in a declarative fashion,<ref>{{cite web |url=http://phoenix.labri.fr/wiki/doku.php?id=an_overview_on_dsls |title=An overview on dsls |archive-url=https://web.archive.org/web/20071023021126/http://phoenix.labri.fr/wiki/doku.php?id=an_overview_on_dsls |archive-date=October 23, 2007 |url-status=dead}}</ref> 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 (programming language)|C]]). ===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=== {{Main|Mathematical model}} Models, or mathematical representations, of physical systems may be implemented in computer code that is declarative. The code contains a number of equations, not imperative assignments, that describe ("declare") the behavioral relationships. When a model is expressed in this formalism, a computer is able to perform algebraic manipulations to best formulate the solution algorithm. The mathematical causality is typically imposed at the boundaries of the physical system, while the behavioral description of the system itself is declarative or acausal. Declarative [[modeling language]]s and environments include [[Analytica (software)|Analytica]], [[Modelica]] and [[Simile (computing)|Simile]].<ref>{{cite web |url=http://www.simulistics.com/tour/declarative.htm |title=Declarative modelling |publisher=Simulistics |access-date=15 August 2013 |archive-date=11 August 2003 |archive-url=https://web.archive.org/web/20030811073949/http://www.simulistics.com/tour/declarative.htm |url-status=live }}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)