The Advantages of Declarative Programming
A declarative language is a type of programming language where you describe what goal a task has, but without writing the code to accomplish the task. HTML, SQL and Prolog are all examples of declarative languages. This language type has several advantages compared to other types, most notably imperative languages, where you actually write code that defines how a program should accomplish tasks.
Programs made with a declarative language are often smaller than ones made with an imperative language. This is because you need to use less code to accomplish a goal. For example, in Prolog you can write a one-line fact that defines the current month, then use one more line to ask what month it is in the program. In an imperative language such as C++, you create and initialize a variable, then use a multi-line "if" statement block to check the value of the variable, and program the conditional outcomes.
The code that defines how to accomplish a task is actually built into the programming language or in the computer itself. For example, an SQL "SELECT" command tells a database that you want it to return all records in a table based on some criteria. You don't care how it gets those results to you. However, SQL knows the details, saving you the time and effort of having to write code yourself that is already a part of the language's functionality.
In imperative programming, you write a block of code, called a script, which defines how to get a result, whether it's a calculation or a list of steps. Declarative programming languages do not need scripts to define how the program should relate one clause to another. In a programming language such as Prolog, you define relationships using facts and rules, and the program knows and can determine the flow of a program by itself.
Ease of Use
Due to the simplistic nature of a declarative language, people new to programming can pick up the basic concepts of the paradigm quickly and write a program with ease. Using HTML, you can quickly learn how to design a simple Web page that includes items such as links, images and text, as all of these tags tell the browser what you want the page to look like and how to achieve that look.