Is it possible to say that the difference between imperative programming and declarative programming is merely in the level of abstraction? I.e. where the imperative programming will say "break the eggs, put them into plate, turn the oven to 180 degrees, etc", a declarative language will only say "cook me eggs"?
Declarative languages are not necessarily higher abstraction level. Thay are not magical - they cannot figure out on its own how to cook eggs if you dont tell it how (unless there is a library for it, but that would be the some for imperative). You still have to provide the same information as an imperative program would need. The difference is in how the information is expressed.
Imperative: A sequence of steps (possibly with branches, loops etc.). "break the eggs, put them into plate, turn the oven to 180 degrees, etc",
Declarative: The end goal, described in sufficient detail: "eggs which have been placed (without shells) in an oven on a plate at 180 degrees"
A more realistic example would be how to draw a line:
graphics.setPen(Color.Red, Size.Big) a = new Point(100,100); b = new Point(200, 200); graphics.drawLine(a, b);
Line: start: Point(100,100) end: Point(100,100) color: Red size: Big
The abstraction level is more or less the same (the concepts - line, point, colors - are the same, and the same amount of information is given), but the imperative is expressed as a sequence of steps, while the declarative express the end goal.
In practice though, the most well known declarative languages are high-level domain specific languages like SQL, CSS, HTML etc, while lower level general-purpose languages like C, Java etc. are generally imperative. It appears declarative is more suited to high level DSL, while imperative is more suited to general purpose programming.
This is true in one "direction," but not both.
Declarative programming is always some abstraction layer(s) above imperative programming (Assembly is always imperative). You are just letting some other function (an abstraction) figure out the imperative steps, by giving it a state description (a declaration).
But adding an abstraction layer above imperative programming does not always produce declarative code.
A simple proof:
Addition is a base concept.
Multiplication of whole numbers is just repeated addition (multiplication is an abstraction of addition).
4 * 12 is still an imperative expression.
Declarative programming is basically hiding chunks of implementation under the hood and providing compose-able constructs to use these implementations... creatively.
Think of HTML & CSS, the browser "knows" the imperatives/commands/steps for rendering CSS rules and tags, in domain of drawing stuff on screen.
Rather than Abstraction, its more of an Encapsulation technique:
<egg class="broken oven-cooked medium"/>