Declarative programming

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.[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 describing 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.[3][4]

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.[5]

Common declarative languages include those of database query languages (e.g., SQL, XQuery), regular expressions, logic programming (e.g. Prolog, Datalog, answer set programming), functional programming, configuration management, and algebraic modeling systems.

  1. ^ Lloyd, J.W., Practical Advantages of Declarative Programming
  2. ^ "declarative language". FOLDOC. 17 May 2004. Archived from the original on 7 September 2023. Retrieved 7 September 2023.
  3. ^ Sebesta, Robert (2016). Concepts of programming languages. Boston: Pearson. ISBN 978-0-13-394302-3. OCLC 896687896.
  4. ^ "Imperative programming: Overview of the oldest programming paradigm". IONOS Digital Guide. 2021-05-21. Archived from the original on 2022-05-03. Retrieved 2023-05-23.
  5. ^ "DAMP 2009: Workshop on Declarative Aspects of Multicore Programming". Cse.unsw.edu.au. 20 January 2009. Archived from the original on 13 September 2013. Retrieved 15 August 2013.