What is declarative programming?

Declarative programming is a way to specify, what the program should do rather than specify how to do it. Most computer languages ​​are based on the steps needed to solve the problem, but some languages ​​indicate only the basic features of the problem and leave it on the computer to determine the best way to solve the problem. It is said that former languages ​​support imperative programming, while the latter support of declaring programming. in order to obtain data. The SQL system can go through each sales record and determine whether the status is met or can quickly obtain several highest records in advance. The statement only indicates the nature of desired data.

The prologue is a declarative programming language that denotes logical relationships between entities.

predecessor (m, c):- mother (m, c)
The predecessor (x, z):- mother (x, y), predecessor (y, z)

The above program refers to the trusies. If m is the mother C then he is a predecessor C. If x is the motherAny person who is the predecessor of the Z, then X is the predecessor of Z. Given this and some facts of the mother's mother, the program can answer questions about the entire parent pedigree.

During the program, the prologue system creates a number of real commands, creating a knowledge base. This knowledge base is searched effectively in itself. The creator of the above program does not specify how to look.

HTML and CSS are declaring programming languages. For example, an example of HTML indicates a thin edge. Example CSS is Color: blue . This determines the color of the text. As can be seen in these examples, HTML and CSS determine what should appear on the website, but not how to do it.

The advantage of declaring programming languages ​​is mainly double. The programs are brief; This makes it easier for non -programmers to obtain a solution. In the above example SQL the analyst orEnterprise Support to obtain the required information. Similarly, Laypsons can write acceptable websites using simple HTML and CSS commands.

The second advantage of the declarative programming model is that the recurring code of imperative that shows how to solve things is provided in the computer system behind the scenes. Such a code can be highly efficient and may include the best ideas from computer technology. It can take advantage of parallelism.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?