In computer science Computer science or computing science is the study of the theoretical foundations of information and computation, and of practical techniques for their implementation and application in computer systems. It is frequently described as the systematic study of algorithmic processes that create, describe, and transform information. Computer science, declarative programming is a programming paradigm A programming paradigm is a fundamental style of computer programming. Paradigms differ in the concepts and abstractions used to represent the elements of a program (such as objects, functions, variables, constraints, etc.) and the steps that compose a computation (assignment, evaluation, continuations, data flows, etc.) that expresses the logic of a computation Computation is a general term for any type of process, algorithm or measurement; this often includes but is not limited to digital data. This includes phenomena ranging from human thinking to calculations with a more narrow meaning. Computation is a process following a well-defined model that is understood and can be expressed in an algorithm, without describing its control flow In computer science, control flow refers to the order in which the individual statements, instructions, or function calls of an imperative or a declarative program are executed or evaluated.[1] Many languages applying this style attempt to minimize or eliminate side effects In computer science, a function or expression is said to have a side effect if, in addition to producing a value, it also modifies some state or has an observable interaction with calling functions or the outside world. For example, a function might modify a global or a static variable, modify one of its arguments, raise an exception, write data by describing what the program should accomplish, rather than describing how to go about accomplishing it.[2] This is in contrast with imperative programming In computer science, imperative programming is a programming paradigm that describes computation in terms of statements that change a program state. In much the same way that imperative mood in natural languages expresses commands to take action, imperative programs define sequences of commands for the computer to perform, which requires an explicitly provided algorithm In mathematics, computer science, and related subjects, an 'algorithm' is an effective method for solving a problem expressed as a finite sequence of instructions. Algorithms are used for calculation, data processing, and many other fields.
Declarative programming often considers programs A program is list of instructions written in a programming language that is used to control the behavior of a machine, often a computer as theories of a formal logic Mathematical logic is a subfield of mathematics with close connections to computer science and philosophical logic. The field includes both the mathematical study of logic and the applications of formal logic to other areas of mathematics. The unifying themes in mathematical logic include the study of the expressive power of formal systems and the, and computations as deductions in that logic space. Declarative programming has become of particular interest recently, as it may greatly simplify writing parallel programs Parallel computing is a form of computation in which many calculations are carried out simultaneously, operating on the principle that large problems can often be divided into smaller ones, which are then solved concurrently . There are several different forms of parallel computing: bit-level, instruction level, data, and task parallelism.[3]
Common declarative languages include those of regular expressions In computing, regular expressions, also referred to as regex or regexp, provide a concise and flexible means for identifying strings of text, such as particular characters, words, or patterns of characters. A regular expression is written in a formal language that can be interpreted by a regular expression processor, a program that either serves, logic programming Logic programming is, in its broadest sense, the use of mathematical logic for computer programming. In this view of logic programming, which can be traced at least as far back as John McCarthy's advice-taker proposal, logic is used as a purely declarative representation language, and a theorem-prover or model-generator is used as the problem-, and functional programming In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state. Functional programming has its roots in the.
Contents |
Definition
Declarative programming is often defined as any style of programming that is not imperative In computer science, imperative programming is a programming paradigm that describes computation in terms of statements that change a program state. In much the same way that imperative mood in natural languages expresses commands to take action, imperative programs define sequences of commands for the computer to perform. 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 In computer science, a function or expression is said to have a side effect if, in addition to producing a value, it also modifies some state or has an observable interaction with calling functions or the outside world. For example, a function might modify a global or a static variable, modify one of its arguments, raise an exception, write data (or more specifically, is referentially transparent Referential transparency and referential opaqueness are properties of parts of computer programs. An expression is said to be referentially transparent if it can be replaced with its value without changing the program . The opposite term is referentially opaque)
- A language with a clear correspondence to mathematical logic Mathematical logic is a subfield of mathematics with close connections to computer science and philosophical logic. The field includes both the mathematical study of logic and the applications of formal logic to other areas of mathematics. The unifying themes in mathematical logic include the study of the expressive power of formal systems and the. [1]
These definitions overlap substantially.
Subparadigms
Declarative programming is an umbrella term that includes a number of better-known programming paradigms A programming paradigm is a fundamental style of computer programming. Paradigms differ in the concepts and abstractions used to represent the elements of a program (such as objects, functions, variables, constraints, etc.) and the steps that compose a computation (assignation, evaluation, continuations, data flows, etc.).
Functional programming
Main article: Functional programming In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state. Functional programming has its roots in theFunctional programming, and in particular purely functional Purely functional is a term in computing used to describe algorithms, data structures or programming languages that exclude destructive modifications . According to this restriction, variables are used in a mathematical sense, with identifiers referring to immutable, persistent values programming, attempts to minimize or eliminate side effects, and is therefore considered declarative. Most functional languages, however, do permit side effects in practice.
While functional languages typically do appear to specify "how," a compiler for a purely functional programming language is free to extensively rewrite the operational behavior of a function, so long as the same result is returned for the same inputs. This can be used to, for example, make a function compute its result in parallel Parallel computing is a form of computation in which many calculations are carried out simultaneously, operating on the principle that large problems can often be divided into smaller ones, which are then solved concurrently . There are several different forms of parallel computing: bit-level, instruction level, data, and task parallelism, or to perform substantial optimizations (such as deforestation) that a compiler may not be able to safely apply to a language with side effects.
Logic programming
Main article: Logic programming Logic programming is, in its broadest sense, the use of mathematical logic for computer programming. In this view of logic programming, which can be traced at least as far back as John McCarthy's advice-taker proposal, logic is used as a purely declarative representation language, and a theorem-prover or model-generator is used as the problem-Logic programming languages such as Prolog Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics 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.
Constraint programming
Main article: Constraint programmingIn Constraint programming relations between variables are stated in the form of constraints, specifying the properties of a solution to be found. The set of constraints is then solved by giving a value to each variable so that the solution is consistent with the maximum number of constraints.
Constraint programming is often used as a complement to other paradigms: functional, logical or even imperative programming.
Domain-specific languages
Main article: Domain-specific language In software development and domain engineering, a domain-specific language is a programming language or specification language dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique. The concept isn't new—special-purpose programming languages and all kinds of modeling/Some well-known examples of declarative domain specific languages (DSLs) include regular expressions In computing, regular expressions, also referred to as regex or regexp, provide a concise and flexible means for identifying strings of text, such as particular characters, words, or patterns of characters. A regular expression is written in a formal language that can be interpreted by a regular expression processor, a program that either serves, CSS Cascading Style Sheets is a style sheet language used to describe the presentation semantics (the look and formatting) of a document written in a markup language. Its most common application is to style web pages written in HTML and XHTML, but the language can also be applied to any kind of XML document, including SVG and XUL, and a subset of SQL SQL , often referred to as Structured Query Language, is a database computer language designed for managing data in relational database management systems (RDBMS), and originally based upon relational algebra. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control. SQL was one of the (SELECT queries, for example). DSLs have the advantage of being useful while not necessarily needing to be Turing-complete In computability theory, a collection of data-manipulation rules is said to be Turing complete if and only if such system can simulate a single-taped Turing Machine. Classical Turing-complete systems include context-dependent grammars, recursive functions and lambda calculus, which makes it easier for a language to be purely declarative.
Many markup languages such as HTML HTML, which stands for HyperText Markup Language, is the predominant markup language for web pages. It provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes and other items. It allows images and objects to be embedded and can be used to create interactive forms, MXML, XAML Extensible Application Markup Language is a declarative XML-based language created by Microsoft which is used to initialize structured values and objects. It is available under Microsoft's Open Specification Promise. The acronym originally stood for Extensible Avalon Markup Language - Avalon being the code-name for Windows Presentation Foundation (, XSLT XSLT is a declarative, XML-based language used for the transformation of XML documents into other XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one. The new document may be serialized (output) by the processor in standard XML syntax or in another format, such as HTML or, SVG Scalable Vector Graphics is a family of specifications of an XML-based file format for describing two-dimensional vector graphics, both static and dynamic (i.e. interactive or animated) or other user interface markup languages A user interface markup language is a markup language that renders and describes graphical user interfaces and controls. Many of these markup languages are dialects of XML and are dependent upon a pre-existing scripting language engine, usually a JavaScript engine, for rendering of controls and extra scriptability are often declarative. HTML, for example, only describes what should appear on a webpage and doesn't specify the possible interactions Interaction is a kind of action that occurs as two or more objects have an effect upon one another. The idea of a two-way effect is essential in the concept of interaction, as opposed to a one-way causal effect. A closely related term is interconnectivity, which deals with the interactions of interactions within systems: combinations of many with it.
Some software systems now 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 XML is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards namespace XML namespaces are used for providing uniquely named elements and attributes in an XML document. They are defined in Namespaces in XML, a W3C recommendation. An XML instance may contain element or attribute names from more than one XML vocabulary. If each vocabulary is given a namespace then the ambiguity between identically named elements or, include abstractions of SQL SQL , often referred to as Structured Query Language, is a database computer language designed for managing data in relational database management systems (RDBMS), and originally based upon relational algebra. Its scope includes data insert, query, update and delete, schema creation and modification, and data access control. SQL was one of the database syntax or parameterised calls to web services using REST Representational state transfer is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The term Representational State Transfer (REST) was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation. Fielding is one of the principal authors of the Hypertext Transfer Protocol (HTTP) and SOAP SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks. It relies on eXtensible Markup Language as its message format, and usually relies on other Application Layer protocols (most notably Remote Procedure Call (RPC) and.
Hybrid languages
Makefiles, for example, specify dependencies in a declarative fashion [2], but include an imperative list of actions to take as well. Similarly, yacc The computer program yacc is a parser generator developed by Stephen C. Johnson at AT&T for the Unix operating system. The name is an acronym for "Yet Another Compiler Compiler." It generates a parser based on an analytic grammar written in a notation similar to BNF. Yacc generates the code for the parser in the C programming specifies a context free grammar declaratively, but includes code snippets from a host language, which is usually imperative (such as C C is a general-purpose computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system).
See also
- Category:Declarative programming languages This category lists those programming languages that adhere to the declarative programming paradigm
- Comparison of programming paradigms
- Constraint programming
- Domain-specific language In software development and domain engineering, a domain-specific language is a programming language or specification language dedicated to a particular problem domain, a particular problem representation technique, and/or a particular solution technique. The concept isn't new—special-purpose programming languages and all kinds of modeling/
- Functional programming In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state. Functional programming has its roots in the
- Imperative programming In computer science, imperative programming is a programming paradigm that describes computation in terms of statements that change a program state. In much the same way that imperative mood in natural languages expresses commands to take action, imperative programs define sequences of commands for the computer to perform (contrast)
- Logic programming Logic programming is, in its broadest sense, the use of mathematical logic for computer programming. In this view of logic programming, which can be traced at least as far back as John McCarthy's advice-taker proposal, logic is used as a purely declarative representation language, and a theorem-prover or model-generator is used as the problem-
References
- ^ Lloyd, J.W., Practical Advantages of Declarative Programming
- ^ Declarative language in The Free On-line Dictionary of Computing, Editor Denis Howe.
- ^ http://www.cse.unsw.edu.au/~pls/damp09/
External links
- Frans Coenen. Characteristics of declarative programming languages. 1999.
- Olof Torgersson. A Note on Declarative Programming Paradigms and the Future of Definitional Programming. 1996.
Categories: Programming paradigms
|