“declarative” is sort of an unfortunate term to emerge in computer science. The point is to contrast the language in question with “imperative” languages but in reality all programming languages are declarative. Take for example code in the IO monad is Haskell. Is that declarative or imperative? In one sense it’s declarative since it’s a purely functional / data-oriented construct, in another sense it is imperative because it describes how data flows across a sequence of IO operations.
Going back to the OP, the fact that SQL is declarative is not what enables a wide range of optimizations. It’s that SQL specifies fewer semantics in terms of what its constructs mean computationally. Haskell is another language that is underspecified in terms of how computations happen and also is amenable to a wide array of optimizations. It isn’t necessarily that it’s declarative.
“declarative” is sort of an unfortunate term to emerge in computer science. The point is to contrast the language in question with “imperative” languages but in reality all programming languages are declarative. Take for example code in the IO monad is Haskell. Is that declarative or imperative? In one sense it’s declarative since it’s a purely functional / data-oriented construct, in another sense it is imperative because it describes how data flows across a sequence of IO operations.
Going back to the OP, the fact that SQL is declarative is not what enables a wide range of optimizations. It’s that SQL specifies fewer semantics in terms of what its constructs mean computationally. Haskell is another language that is underspecified in terms of how computations happen and also is amenable to a wide array of optimizations. It isn’t necessarily that it’s declarative.
score 1 · canonical