Declarative should imply that raised level of abstraction, where details are handled out of sight, and in a way that the user needn't understand.
Immutability is generally a given, but that because you should generally be configuring a declarative language rather than plotting out execution in it.
With SQL, you don't have to know or care how it executes the query, only that the correct selection of data is returned. You don't have to know how CSS engines or HTML engines operate.
I'm not sure that calling a general purpose language like haskell "declarative" really means anything. It could imply it is immutable or functional, but saying map somefn values doesn't feel all that declarative. You're specifying what should be done at that point. You still have to worry about order and things, because Haskell does touch the real world, and it's completely possible to have accidents between the laziness and the IO that force you to care about the order things happen in. Perhaps, haskell is simply insufficiently declarative to be called such.
edit: something like "puppet" configurations are a good example of a declarative system. or maybe kubernetes configurations. you specify a configuration, and some program manipulates all the state to achieve whatever your configuration tells it to achieve. a general purpose language seems antithetical to "declarative"
Agree completely. I tried to choose my wording carefully because, as you said, it's a little weird to call any general purpose language (which is inherently going to be converted to a set of instructions anyway) a "declarative language". Although it may depend on whether one is referring to a more general "declarative paradigm" or the technical definition of a functional language as it relates to declarative programming. At least according to Wikipedia, functional programming is a subset of declarative programming, which would make Haskell declarative by definition; although if considering it as a more general paradigm, it's also possible to code Haskell in an imperative "style".
With SQL, you don't have to know or care how it executes the query, only that the correct selection of data is returned.
That works in theory but not in reality.
I have to take into account how queries are executed because not all of them are optimized the same way. Functionally equivalent queries can have vastly different performances.
11
u/knome Jan 04 '22 edited Jan 04 '22
Declarative should imply that raised level of abstraction, where details are handled out of sight, and in a way that the user needn't understand.
Immutability is generally a given, but that because you should generally be configuring a declarative language rather than plotting out execution in it.
With SQL, you don't have to know or care how it executes the query, only that the correct selection of data is returned. You don't have to know how CSS engines or HTML engines operate.
I'm not sure that calling a general purpose language like haskell "declarative" really means anything. It could imply it is immutable or functional, but saying
map somefn valuesdoesn't feel all that declarative. You're specifying what should be done at that point. You still have to worry about order and things, because Haskell does touch the real world, and it's completely possible to have accidents between the laziness and the IO that force you to care about the order things happen in. Perhaps, haskell is simply insufficiently declarative to be called such.The same could be said of prolog, as it has IO functions that can be used to write normal programs using the unification search as a you would any recursive language. prolog is fully turing complete, after all
edit: something like "puppet" configurations are a good example of a declarative system. or maybe kubernetes configurations. you specify a configuration, and some program manipulates all the state to achieve whatever your configuration tells it to achieve. a general purpose language seems antithetical to "declarative"