Is Functional Declarative

An anonymous reader asks:

Is a pure FunctionalProgramming style imperative or declarative? One can view it more like math instead of sequential instructions, even if it can be (and often is) implemented via sequential instructions. However, the order of execution may not matter as long as the rules are followed.


According to DeclarativeProgramming, pure FunctionalProgramming is declarative. However, whether the order of execution actually matters or not, the flow of execution is specified by the programmer in typical FunctionalProgramming, so it should probably not be considered declarative. This assumes we agree that "declarative" means a style of programming that does not specify, nor is dependent upon, order of execution. Some simplistic definitions of declarative, such as that it is a programming style that specifies "what" instead of "how," seem to be intuitively meaningful but quickly crumble when scrutinised. Virtually every statement in a practical, non-trivial program in any given programming language can be considered both a "what" and a sequential step within a larger "how," and examples of "what" in the absence of "how" are difficult to find except in deliberately limited, special-purpose languages such as SQL.

In the absence of a more rigorous, generally-accepted definition for "declarative," and given the fact that most TuringComplete languages will support -- out of necessity -- both declarative and imperative styles of programming, it may be that "declarative vs. imperative" is not a meaningful distinction. It is perhaps more helpful to categorise languages, language features, or programs on the degree to which they support or implement abstraction and clearly understandable order-independent definitions, and not think in terms of "declarative vs. imperative" at all.

(Note: I'm probably talking out my ass. The above is not my area of expertise, and has been heavily influenced by beer and distractions. Corrections, including outright deletion if it's nonsense, are welcomed. DeleteWhenCooked.)

-- DaveVoorhis


EditText of this page (last edited September 17, 2005) or FindPage with title or text search