9 ms·
> And that's exactly what SQL does. So an SQL UPDATE statement is purely declarative? "Update" sure looks like an operation to me. Similar remarks would apply
by pdonis 8y ago
> And that's exactly what SQL does.
So an SQL UPDATE statement is purely declarative? "Update" sure looks like an operation to me. Similar remarks would apply to DELETE or INSERT.
For queries, I can see your point of view, yes; but even for queries, SELECT, GROUP BY, etc. can be viewed as operations just as well as descriptions of the result set. (WHERE, I agree, doesn't really look like an operation.)
> GROUP BY x and WHERE X > 10, etc. are not "the operations performed to obtain the result", are high level descriptions of the result we want.
Again, I think this is a matter of point of view. GROUP BY isn't a low-level operation, sure; but that doesn't mean it's not an operation, or can't be viewed as one. High-level operations are still operations.
> in CS courses, SQL was one of the canonical examples of declarative programming
I'm not trying to dispute this. I'm saying that given how the author of the article is using the term "functional", it seems to me that SQL could be considered "functional". But I've already noted that the way the author of the article is using the term "functional" is probably not the way that term is commonly used.
- coldtea 8y ago>So an SQL UPDATE statement is purely declarative? "Update" sure looks like an operation to me The Update statement tells "set this column to this value". It's totally a declaration of intent. It doesn't specify anything about how the update is going to happen behind the scenes (open this file, use this tree structure, traverse, find the nth entry, write this value to the disk, and so on). (Databases also support PL/SQL which is more imperative in nature, but here we're talking about SQL the query language). >but that doesn't mean it's not an operation, or can't be viewed as one. High-level operations are still operations. Operation in the context of declarative vs non declarative is not about high vs low, it is about whether the language has the user explicitly define control flow. In the "group by" the user just tells to the DB that they want the results grouped, they don't specify any control flow, or tell how that grouping will happen.
- pdonis 8y ago> The Update statement tells "set this column to this value". It's totally a declaration of intent. "Set this column to this value" sure looks like an operation to me. > It doesn't specify anything about how the update is going to happen behind the scenes Neither does the expression y = f(x). But that expression is the canonical example of a function, not a declarative statement. > Operation in the context of declarative vs non declarative Is whatever you are defining it to be, I get that. But I don't think the author of the article is using words the same way you are.