Programming, Imperative, Declarative

Programming, Imperative, Declarative

Various paradigms are used when programming in computer science. These paradigms may differ depending on the programming languages ​​and the purpose of the project. We can divide the paradigms used in general into two main headings;

 

                              -Mandatory Programming

 

                              -Declarative Programming

 

               First of all, the word command means order, conditional and denotes an order. In imperative programming, the "how" is more important than the "what". What is meant by this programming paradigm is the line-by-line definition of actions to be taken. It is the most suitable programming method for computer hardware because every detail is processed individually. For your better understanding, I want to explain with a very common example.

 

Consider a robot, if we were to command the robot with imperative programming, these commands would be:

 

                             · Move your arm 25 centimeters to the right at an angle of 15 degrees.

 

                             · Turn your head 30 degrees from left to right.

 

 

 

It would be in shape. The point I want to make with this example is that even the simplest lever action consists of multiple subcommands. Languages ​​such as C, C++, Java, as well as primitive languages ​​such as machine language or Fortran, are imperative languages ​​by Algol structure.

Considering that you understand imperative programming, I want to talk about declarative programming, which is the opposite of this paradigm. As a declarative word, the definition means to declare. We mentioned that imperative programming deals with "how" the action is done, whereas declarative programming deals with "what" to do. In the declarative paradigm, it would be sufficient to command the action itself without the need for subordinate commands. In the example I gave above, we commanded a robot with the imperative paradigm. If the same robot were commanded with the declarative paradigm, the robot would be given commands to take the glass from the table:

 

· Detect table.

 

· Approach the table.

 

· Detect the trophy.

 

· Take the glass.

 

It would be in shape. The point we need to pay attention to here is that the commands we give are given for a purpose. As I mentioned in the title, what comes to the fore in declarative programming, while the question of how in command programming comes to the fore. Of course, actions in declarative programming also consist of a series of subcommands, and these subcommands form an order. However, each function written in the programming approach serves a purpose and then these functions are combined to obtain a modular problem solution. On the other hand, in imperative programming, each instruction is a subcommand of another specific instruction and the programmer always has to give the command. Languages ​​such as lisp, prolog, schema are declarative languages ​​in structure.

Light