1. 11

  2. 1

    SQL is the second-most common programming language

    I don’t want to be pedantic, but SQL is not a programming language- it’s a query language. It’s right there in the name. And that is also a big piece of its longevity- it’s solving a different problem domain than programming languages do. It’s a narrower domain, with different constraints, and because SQL is much more abstracted out of the operations being performed, the language itself has much less of an impact on things like performance (generally, poorly performing queries are caused by bad database designs, not bad SQL).

    1. 2

      It’s a Declarative language, where you specify what is required rather than what to do (its not an imperative language).

      Either way, the convention is for both languages families to be called programming languages.

      1. 1

        It is a declarative language, but it is not a programming language, in the sense that you could not write a program in SQL, any more than you can write a program in XML. Both SQL and XML can be extended into programming languages- TSQL and PL/SQL are clearly programming languages- but raw SQL is not.

        More specifically, SQL is an implementation of relational calculus, which is itself a variation of first order logic, and you could not implement a Turing Machine in it.

        1. 5

          Apparently with recursive CTEs SQL is Turing complete: http://stackoverflow.com/a/7580013/221619

          1. 2

            Well, what do you know. I’ll revise my statement to say that it’s not a programming language in the common sense of the word, but could count as an esolang.

      2. 1

        I cannot vouch for it, but the website http://modern-sql.com/ by the Use The Index, Luke guy claims SQL is turing complete. Whether that makes something a programming language is probably up for debate.

        1. 1

          He says that, yes- but a quick troll through his site doesn’t seem to indicate any support for that claim. He does cover a lot of features that too few developers know about, but Turing completeness is a bold claim that I don’t really see him supporting.

          I would argue that implementing a Turing machine in a language is the sole criteria for being a programming language.

          1. 3

            Well, this comment explains what’s going on with turing complete SQL. It is technically correct, which is certainly the best kind of correct.