When to use declarative programming over imperative programming

As far as I know, the main difference between declarative and imperative programming is that in declarative programming you will more likely indicate what the problem is, and in imperative programming you determine exactly how to solve the problem.

However, it is not clear to me when to use one over the other. Imagine that you are imposed to solve a specific problem, according to what properties you decide to allow it declaratively (for example, using a prolog) or strongly (for example, using Java)? For what problems do you prefer to use one over the other?

+4
source share
1 answer

Imperative programming is closer to what a real machine does. This is a form of programming at a fairly low level, and the more complex your application, the more difficult it will be to understand all the details at such a low level. On the plus side, being close to the machine, you can write fairly efficient code if you are good at it.

Declarative programming is more abstract and higher: with a relatively small amount of code, you can express rather complex relationships in such a way that they are easier to understand.

, , , Prolog Java: , Prolog. , . , , .

, , Java-: . .

, , , , - . .

+3

Source: https://habr.com/ru/post/1622879/


All Articles