Remix.run Logo
TomasBM 7 hours ago

Somewhat tangential to the article, but why is SQL considered a programming language?

I understand that's the convention according to the IEEE and Wikipedia [1], but the name itself - Structured Query Language - reveals that its purpose is limited by design. It's a computer language [2] for sure, but why programming?

[1] https://en.wikipedia.org/wiki/List_of_programming_languages

[2] https://en.wikipedia.org/wiki/Computer_language

derriz 7 hours ago | parent | next [-]

With support for Common Table Expressions (CTE), SQL becomes a Turing complete language. To be honest, it makes me somewhat uncomfortable that a query sent to a DB server could be non-terminating and cause a server thread to enter an infinite loop. On the other hand, the practical difference between a query that contains an infinite loop and one that runs for days is probably negligible.

Imustaskforhelp 7 hours ago | parent | prev | next [-]

To be honest, I'd like to chip in that it is technically possible to write brainf*ck, an esoteric programming language but nonetheless, its a programming language

https://www.reddit.com/r/SQL/comments/81barp/i_implemented_a...

Btw this runs in sqlite, you can try it yourself if you are interested.

Source: I was thinking of creating a programming language paradigm like sqlite/smalltalk once where resumed execution/criu like possibilities were built in. Let me know if someone knows something like this too. I kinda gave up on the project but I knew that there was this one language which supported this paradigm but it was very complicated to understand and had a lot of other first time paradigm like the code itself / the ast tree is sort of like a database itself but so the tangential goes.

pjmlp 7 hours ago | parent | prev | next [-]

Because stored procedures do exist, and there isn't a single production quality RDMS that doesn't go beyond DDL and DML, adding structured programming extensions.

Also, even within the standard itself, it allows for declarative programming.

yawaramin 7 hours ago | parent | prev | next [-]

What is your definition of 'programming language'?

lateforwork 5 hours ago | parent [-]

It should have arrays, and loops and conditionals.

Izkata 4 hours ago | parent [-]

Slightly simplistic: table rows cover arrays, recursive CTEs cover loops, and JOIN/WHERE cover conditionals.

rawgabbit 7 hours ago | parent | prev | next [-]

Because "programming language" is an adjective or a descriptive term. Whatever looks like a programming language, can be called a programming language.

randomNumber7 6 hours ago | parent | prev [-]

Also SQL is not turing complete. I see it more as a descriptive language like e.g. html is a language but not a programming language.

hunterpayne 4 hours ago | parent | next [-]

This is completely wrong. The SQL spec isn't Turning complete but multiple DBs provide Turing complete extensions (like pgplsql) that make it so. Also, even without the extensions, it is still very much a programming language by any definition of the term. Like most takes on SQL, it is more about your understanding (or lack thereof) of SQL.

rawgabbit 5 hours ago | parent | prev [-]

It can do loops and recursion. It can use as much memory as it is allowed. It can do general programming via functions and stored procedures.

lateforwork 4 hours ago | parent [-]

It can't do loops. Unless you're talking about extensions to SQL such as PL/SQL and T-SQL.