|
In computer science, declarative 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. Many languages applying this style attempt to minimize or eliminate side effects by describing ''what'' the program should accomplish in terms of the problem domain, rather than describing ''how'' to go about accomplishing it as a sequence of the programming language primitives〔(Declarative language ) in The Free On-line Dictionary of Computing, Editor Denis Howe.〕 (the ''how'' being left up to the language's implementation). This is in contrast with imperative programming, in which algorithms are implemented in terms of 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. Common declarative languages include those of database query languages (e.g., SQL, XQuery), regular expressions, logic programming, functional programming, and configuration management systems. ==Definition== Declarative programming is often defined as any style of programming that is not imperative. A number of other common definitions exist that attempt to give the term a definition other than simply contrasting it with imperative programming. For example: * A program that describes ''what'' computation should be performed and not ''how'' to compute it * Any programming language that lacks side effects (or more specifically, is referentially transparent) * A language with a clear correspondence to mathematical logic. These definitions overlap substantially. Declarative programming contrasts with imperative and procedural programming. Declarative programming is a non-imperative style of programming in which programs describe their desired results without explicitly listing commands or steps that must be performed. Functional and logical programming languages are characterized by a declarative programming style. In logical programming languages, programs consist of logical statements, and the program executes by searching for proofs of the statements. In a pure functional language, such as Haskell, all functions are without side effects, and state changes are only represented as functions that transform the state, which is explicitly represented as a first class object in the program. Although pure functional languages are non-imperative, they often provide a facility for describing the effect of a function as a series of steps. Other functional languages, such as Lisp, OCaml and Erlang, support a mixture of procedural and functional programming. Some logical programming languages, such as Prolog, and database query languages, such as SQL, while declarative in principle, also support a procedural style of programming. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Declarative programming」の詳細全文を読む スポンサード リンク
|