Skip to content
Search

Declarative programming

lastmod 2018-08-17created 2015-06-183 edits

By one definition, a program is called "declarative" if it describes what something is like rather than how to do it. For example, web pages are declarative because a web page describes "what" should appear, such as the title, font, body text, and images, not "how" the page should be displayed on a computer screen. This is a different approach from traditional imperative programming languages such as Fortran, C, and Java, which require the programmer to specify the algorithm to be executed. Simply put, imperative programs specify the algorithm and not the goal, whereas declarative programs specify the goal and not the algorithm.

By another definition, a program is called "declarative" if it is written in a functional programming language, a logic programming language, or a constraint programming language. Here, "declarative language" is an umbrella term for these programming languages, as opposed to imperative languages.

About

Declarative languages have a powerful feature called 'lazy evaluation'. It is the concept of postponing a computation until the moment it is needed, and this concept exists only in declarative languages. However, not all declarative languages support lazy evaluation. The power of lazy evaluation shows when dealing with infinity. For example, it is possible to define the set of all natural numbers as input data and assign it.

Programming language

  • ABSET
  • Lustre
  • MetaPost
  • OpenLaszlo
  • Prolog
  • SQL
  • XSL Transformations

Frameworks

  • Ruby on Rails
  • JUnit

Favorite site