Declarative programming-表述编程语言

Posted zzfx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Declarative programming-表述编程语言相关的知识,希望对你有一定的参考价值。

表述编程语言是说明性的东西;而不是具体的执行方案。

通常他的执行由解释器进行。

In computer sciencedeclarative 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.[1]

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[2] (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.[3]

Common declarative languages include those of database query languages (e.g., SQLXQuery), regular expressionslogic programmingfunctional programming, and configuration management systems.

 

Subparadigms[edit]

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

Constraint programming[edit]

Constraint programming states relations between variables in the form of constraints that specify the properties of the target solution. The set of constraints is 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[edit]

Well-known examples of declarative domain-specific languages (DSLs) include the yacc parser generator input language, QML, the Make build specification language, Puppet‘s configuration management language, 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 HTMLMXMLXAMLXSLT or other user-interface markup languages 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 interactions with a user.

As of 2013 some software systems 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 parameterised calls to web services using representational state transfer (REST) and SOAP.

Hybrid languages[edit]

Makefiles, for example, specify dependencies in a declarative fashion,[5] 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[edit]

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.

 

https://en.wikipedia.org/wiki/Declarative_programming

以上是关于Declarative programming-表述编程语言的主要内容,如果未能解决你的问题,请参考以下文章

Python 学习笔记 - SQLAlchemy(下)

在 SQLAlchemy 中使用 declarative_base 时如何绑定引擎?

Declarative Effects --- redux-saga

声明(Declarative)式与命令(Imperative)式

编程范式:命令式编程(Imperative)声明式编程(Declarative)和函数式编程(Functional)

QtScript, QML, Quick1, Quick2, Declarative 之间的关系