T
T
Tyrion Lannister2017-05-03 00:38:45
Programming
Tyrion Lannister, 2017-05-03 00:38:45

What is the difference between procedural programming and imperative programming?

The descriptions of the two styles are very similar. Or is it the same thing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Adamos, 2017-05-03
@Adamos

There is a procedure: before asking a question, google yourself.
There is an imperative: google before asking such questions.
Since neither is done, there is no difference.

I
Ilya, 2017-05-04
Tollu @itollu

With an imperative approach , you can assume that you have an executor at your disposal who understands a certain set of commands. It can dig, it can not dig, it can branch, loop, assign, call, etc.
The imperative approach is often contrasted with the declarative one . You don't say what the performer should do. Instead, the desired result is described (declared). As a rule, the declarative approach is more high-level. For example, when composing SQL queries, we do not tell the DBMS how to get the result (as a rule). These are implementation details that we don't care about.
Compare, for example, two approaches to infrastructure management:
and

  • I need a car like this
  • On which there is such and such a package,
  • Which has such and such a configuration.
Procedural programming is a way of organizing imperative programs. First, this programming is structural. Relatively speaking, we do not have a goto statement. There are procedures. As parameters of the procedure, levers for data manipulation are received. In their code, the procedures "pull" these levers. They can read their parameters, change their parameters, make calls to them. You may encounter procedural programming when writing stored procedures for PostgreSQL. From the real world: when you give shoes to be fixed, you take a procedural approach.
To complete the picture, we must immediately mention pure functions. Unlike procedures, a pure function cannot change the state of its parameters. And it cannot change the state of the outside world. Therefore, she is pure. In the course of work, a pure function forms an entity that it "returns" upon completion. In the real world, a doctor's consultation is an example of a pure function. The input argument is your state. Output value - recommendations and appointments.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question