Declarative programming(English: Declarative programming)Programming Paradigm, andImperative programmingOpposite.It describes the nature of the goal and makes the computer understand the goal, not the process.Declarative programming does not need to tell the computer problem domain, thus avoiding the attendant side effects.And imperative programming requires algorithms to clearly point out how to do each step.
Declarative programming is often seen asformal logicThe calculation is regarded as deduction.Declarative programming greatly simplifiesParallel computingSince 2009, the difficulty of compiling has attracted much attention.
Declarative language packs include database query languages(SQL,XQuery),regular expression , logic programming, functional programming and configuration management system.
Declarative programming throughfunction、Inference ruleorterm-rewriting (term rewriting) rules to describe the relationship between variables.Its language runtime(compilerorinterpreter)A fixedalgorithmTo produce results from these relationships.
Declarative programming is often defined as divisionImperativeOutside of the programming paradigm.At the same time, there are some other definitions that do not simply compare declarative programming with imperative programming, such as:
Declarative programming tells the computer what to calculate instead of how to calculate
Noneside effectOr, more precisely, anyReference transparencyProgramming language for
Any programming language with strict computational logic
Some of these definitions coincide.
Subprogramming paradigm
Announce
edit
Declarative programming is a big concept, which contains some well-known sub programming paradigms.
Constrained programming
stayConstrained programmingIn, the relationship between variables is described in constraints, which defines the scope of the solution of the problem.These constraints are then solved by the application program to obtain a value for each variable and satisfy the most constraints.
Constrained programming is often used as a complement to functional programming, logical programming, and even imperative programming.
Domain specific language
Some famous declarative expressionsDomain specific language(DSLs) includingyaccParser, Compile description language Make,PuppetManagement configuration language,regular expression andSQLSome subsets of (such as Select queries).DSLs are sometimes very useful and do not need to beturing complete This often makes it easy to express it in a pure declarative way.
Many text markup languages such asHTML、MXML、XAMLandXSLTOften declarative[1]。
Functional programming
Functional programming, especiallyPure functional programming, trying to minimize the side effects of the state, so it is considered declarative.Most functional programming languages, such asScheme、Clojure、Haskell、OCaml、Standard MLandUnlambda, side effects are allowed.
Logical programming
Logical programmingLanguage such asPrologDeclare the relationship and ask questions about the relationship.Like functional programming, many logic programming languages allow for side effects.