Just wondering, if one were to imperatively code some functionality, and then expose its API under layers of abstractions, is it still considered declarative programming to use and implement said abstractions?
Yes. Otherwise declarative programming wouldn't exist at all, at least not in this world. Every code that is executed finally gets transformed into machine instructions which are imperative on a CPU with Von Neumann architecture. (All CPUs that are practically relevant today belong to this category.)
I would say yes. The question here is the separation of levels of abstractions. All modern computer-based systems are imperative deep inside, there is always the rock of Silica which takes imperative instructions, like to direct stream of electrons to right or left channel, right?
Relational databases consist of imperative loops and B-Trees inside, it's just implementation is hidden from you good enough so you don't have to think about it.
Or think about "goto considered harmful" paper. Goto is an imperative construct and Dijkstra wanted to remove it from high-level programming languages, but goto still exists in lower levels in form of JMP and it is ok. Loops, when compiled, are turned in JMP instructions.
Oooh, I just thought of something pretty interesting. Based on the answers above, is it controversial to classify HTML and CSS as declarative "programming" languages?
The idea of the post is to show that dichotomy of imperative/declarative is false. It is rather a spectrum.
Different parts of CSS are on different levels of the spectrum. If we would consider position and flow, CSS hardly classifies as declarative, because you can't specify "declaratively" even simple idea of centering something relative to something else. But specifying colors is pretty "declarative".
One more example of implementation detail, which CSS makes me think about is measurement units
See the video from decostructconf (link in the post). There is an explanation, how this task could be solved in a more "declarative" way
Just wondering, if one were to imperatively code some functionality, and then expose its API under layers of abstractions, is it still considered declarative programming to use and implement said abstractions?
Yes. Otherwise declarative programming wouldn't exist at all, at least not in this world. Every code that is executed finally gets transformed into machine instructions which are imperative on a CPU with Von Neumann architecture. (All CPUs that are practically relevant today belong to this category.)
I would say yes. The question here is the separation of levels of abstractions. All modern computer-based systems are imperative deep inside, there is always the rock of Silica which takes imperative instructions, like to direct stream of electrons to right or left channel, right?
Relational databases consist of imperative loops and B-Trees inside, it's just implementation is hidden from you good enough so you don't have to think about it.
Or think about "goto considered harmful" paper. Goto is an imperative construct and Dijkstra wanted to remove it from high-level programming languages, but goto still exists in lower levels in form of
JMP
and it is ok. Loops, when compiled, are turned inJMP
instructions.Oooh, I just thought of something pretty interesting. Based on the answers above, is it controversial to classify HTML and CSS as declarative "programming" languages?
I see now. From the way you put it, I definitely agree that it is indeed a spectrum.