Hacker News new | ask | show | jobs
by aminit 4189 days ago
Your examples are a little misleading.

// Imperative: (essence of it) x = 0; x = x + 1; y = x;

// Procedural: x = 0; inc(x); return x;

// Functional: return inc(x);

// Declarative: select x + 1;

--- My argument is that all of these above are imperative. Down below sits imperative CPU which will give exactly the same result. Every time.

Wiki definition of imperative programming in my opinion is too broad: "Imperative programming is focused on describing how a program operates"

This applies to every program in every language. Because you as a programmer are always focused on describing how program operates. Prolog is only another higher abstraction layer.

Wiki: "... imperative programming is a programming paradigm that describes computation in terms of statements that change a program state."

Lets reverse the logic here. Non-imperative programming will not describe computation in terms of statements that change program state. So, non-imperative program will not use statements.

1 comments

Down below sits imperative CPU which will give exactly the same result. Every time.

If you're authoring programs for an abstract virtual machine in a declarative and/or functional style, it doesn't necessarily matter to you that that the underlying CPU architecture is imperative in nature. That's the point of an abstraction layer.

When we say a language is declarative vs. imperative, we're talking about the language level itself, not the full stack all the way down to the metal. A programming language and an implementation are different things.