3 ms·
SQL is a functional programming language. No other imperative programming model will be cleaner or clearer in expressing intent. But, you have to understand SQL
by cty 7y ago
SQL is a functional programming language. No other imperative programming model will be cleaner or clearer in expressing intent. But, you have to understand SQL to begin with.
- deleted 7y ago[deleted]
- codetrotter 7y agoDid you mean to say declarative? That’s what makes it clear in intent isn’t it? That it’s declarative. Whether or not SQL is also functional is orthogonal to that isn’t it?
- chasd00 7y agofurther, afaik there's no assignment nor iteration in SQL. it's not a programming language at all. It's a.. query language.
- yellowapple 7y agoI'd consider INSERTs and UPDATEs to technically be "assignment", even if they're very different from how other languages do it. Some SQL dialects do support both traditional variable assignment and iteration for those cases where an iterative/imperative approach makes more sense than trying to shoehorn the problem into something set-based / declarative. Some limit them to stored procedures (e.g. Postgres, and AFAICT Db2), while others allow them pretty much anywhere (e.g. SQL Server / T-SQL).
- SAI_Peregrinus 7y agoI tend to lump it in as a "logic programming" language, along with Prolog and Datalog.
- taffer 7y ago> further, afaik there's no assignment nor iteration in SQL That was until CTEs were introduced in SQL:1999 > it's not a programming language at all. It's a.. query language. The two are not mutually exclusive. SQL is used to tell a computer what to do, and it is very powerful at it: https://www.youtube.com/watch?v=wTPGW1PNy_Y https://www.youtube.com/watch?v=wTPGW1PNy_Y
- rgoulter 7y agoOne feature I'd expect a functional programming language to have is functions as 'first class'. (e.g. can pass as input to higher order functions). But e.g. PostgreSQL doesn't have functions as a datatype. https://www.postgresql.org/docs/current/datatype.html https://www.postgresql.org/docs/current/datatype.html So, uh, SQL isn't 'functional', right?
- tmountain 7y agoWhile there's no formal definition of functional programming (that I know of at least), SQL doesn't support higher order functions, which are fundamental to all functional programming languages. That said, it's definitely declarative.
- paulddraper 7y agoDepends what you mean by "programming". But virtually all query languages are declarative; e.g. GraphQL.