U
U
user_of_toster2021-01-30 08:13:01
IT terminology
user_of_toster, 2021-01-30 08:13:01

Is declarative programming just using the abstractions already in the library?

Let's take the task - to write a function that cooks scrambled eggs.

Imperative Programming

cook_egg (number):
    take egg
    break egg
    put it on pan
    ....etc
   return eggs


Declarative
cook_egg(number):
     return standard_library.cook(eggs, number)


In the imperative - we describe how to do it, and in the declarative - what we want to get.

At the same time, in declarative programming, it is understood that everything necessary (cook) is already implemented inside the language or in libraries. And it doesn't matter that in an imperative style. Is my point of view correct?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-01-30
@user_of_toster

No. In your example, this is still imperative programming.
Declarative is when you describe the result, but how to achieve it is no longer your problem.
For example, HTML markup is declarative
Configs is also declarative
In a sense, SQL is also declarative

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question