Answer the question
In order to leave comments, you need to log in
What role does the declarative or imperative approach play?
Declarative code seems easier to understand, but probably only when you think about it.
I got acquainted with these terms, and I wonder if the choice of approach plays some role in the work?
Can code be called shitcode just because it's written in an imperative way?
In the sense that the code does something, but it is difficult to understand what exactly and how
Answer the question
In order to leave comments, you need to log in
These are different approaches and each of them should be applied where it belongs. For example, when we configure the infrastructure, it is much easier to specify the target configuration, but sometimes we need to control the process pointwise and then we need to manage it. The same with programming.
Imperative - "do as I say." The examples are all programming languages.
Declarative --- "give me this result, I'm not interested in how to get it." Examples: SQL - you describe the end result, the database engine gets it on its own.
Declarative programming can't. easier, if only because it requires a deeper knowledge of mathematics. Without immersion in mathematics - a declarative programmer will only be able to do very simple tasks, clearly not enough to earn decent money.
In addition, a lot depends on what a person learned in childhood. For example, I studied imperative programming, so declarative programming remained alien to me, although I respect this approach.
A declarative program without an optimizing compiler will perform very poorly. Whereas an imperative program, even without an optimizing compiler, will work pretty well (well, if the programmer is decent).
With an average level of optimization, they go approximately on a par.
But further - writing an optimizing compiler for an imperative program becomes much more complicated. While improving the optimization of compilers for imperative programs is quite simple, since you can freely change the order of operations.
More or less like this.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question