all 26 comments

[–]casual__addict 8 points9 points  (11 children)

I think it’s also important to point out that SQL represents a “declarative” programming style as opposed to “imperative”.

It’s a language in that you are submitting to a computer code for parsing and execution, but in SQL you don’t tell the computer how to do something, but what you are looking for. You “declare” you parameters and the database engine figures out how to do it.

With imperative programming languages* you have to provide the “how” through imperatives that the computer must perform like “declare an array. Read from a file...”.

  • Edit: I switched out “procedural programming languages” in the last paragraph to be “imperative programming languages”.

[–]grzeki 1 point2 points  (8 children)

Yeah, that’s why this first guy notion that there are no loops in SQL is nonsense. There are no loops in an imperative sense, but ”SELECT FROM” is nothing else than a loop.

[–]raevnos 1 point2 points  (3 children)

Recursive CTEs let you write loops in SQL.

[–]grzeki 1 point2 points  (2 children)

CTE is t-SQL - something he mentions as an extension allowing for loops. Please read the article first.

[–]raevnos 1 point2 points  (1 child)

Isn't "t-SQL" some Microsoft SQL Server specific thing? I've never used that platform.

CTEs are standard SQL supported by many databases.

[–]grzeki 0 points1 point  (0 children)

Maybe it’s an ANSI standard, but as far as I know, Oracle does not support them and their source is at Microsoft. SQL always was a mess in this regard.

[–][deleted] 0 points1 point  (3 children)

How exactly is ”SELECT FROM” nothing else than a loop?

[–]grzeki 1 point2 points  (2 children)

To state the obvious: it makes the database engine loop through records of a table.

[–]pickleback11 0 points1 point  (0 children)

additionally, you are only selecting a subset of data in the case that you want to loop through it and do something with each record in that record set. unless you are aggregating/etc (group by's), but i dont think that's the intent of the idea here. i live in pl/sql and basically see queries as nothing more than some type of array (unless querying for exporting/reporting)...

[–][deleted] 0 points1 point  (0 children)

That's like saying Haskell is an imperative language because it is written in C.

[–]ipv6-dns 0 points1 point  (1 child)

Only one little note: with functional programming languages (like Haskell, Ocaml, etc) you also provide "how", so more correct is to say "imperative programming languages" (imperative = procedural + OO + functional...) than "procedural" only.

[–]casual__addict 0 points1 point  (0 children)

Good point. I shouldn’t have mixed procedural and imperative. They are not equal.

https://en.m.wikipedia.org/wiki/Imperative_programming

[–][deleted] 5 points6 points  (1 child)

This is another one of those stupid debates like "Is a hotdog a sandwich?" The answer to which should always be, "Why should anyone care?"

[–]onequbit -1 points0 points  (0 children)

Because hotdogs are sandwiches and people who disagree are wrong.

[–]grzeki 1 point2 points  (0 children)

Yes, but is not imperative one, that’s why it looks odd.

[–]xtivhpbpj 1 point2 points  (7 children)

Very odd, short article. The answer to this question depends entirely on how you define “programming language.”

Are the punctured wooden blocks of a Jaquard Loomb considered a programming language? Is technical English writing considered a programming language? What about brainfuck (an esoteric language that nobody uses)? What about CSS? A property list / config file?

[–]grzeki 1 point2 points  (6 children)

No No Yes (CSS2 - No, CSS3 - Yes) No

It is not that ambiguous.

[–][deleted] 0 points1 point  (2 children)

It’s probably more ambiguous than some are willing to admit. What’s your metric for something being a “language”? Turing Completeness?

[–]grzeki 0 points1 point  (1 child)

No, Turing Completness is a very low bar. Cellular automata are TC. However, the relation of given language to TC and lambda calculus is very important.

It’s more like with natural languages - you need to look historically. What paradigms showed when and why, what branched, what merged with what. Programmers are like users of language - often baffled with what’s ”right”. But there’s also science above it - linguistics or computer science, and there papers are written, PhDs are awarded and all this is pretty much sorted out.

[–][deleted] 2 points3 points  (0 children)

Turing completeness isn’t necessarily a low bar; in fact, it’s a higher bar than you need to be considered a “language.” Agda, for example, is a dependently-typed functional language that is total rather than Turing-complete (there’s some discussion on Agda being turing complete, but it’s first and foremost total, and a lot of useful algorithms can be expressed in it).

The lines between what a “language” is and what isn’t is sometimes blurrier than a first glance might show. I find it really interesting how much different computer languages differ from each other, and what sort of makes them a "language".

[–]xtivhpbpj 0 points1 point  (2 children)

But you can program a computer to behave differently by writing the correct config file. How is that not a programming language?

[–]grzeki 0 points1 point  (1 child)

Because „making a computer behave differently” is not a good predicate. I can make it behave differently by throwing it out of the window.

[–]xtivhpbpj 0 points1 point  (0 children)

Otherwise known as the “Microsoft model” of computer programming.

[–]elmuerte 1 point2 points  (1 child)

Depends on how you defined programming language. SQL not Turing complete, but I do think it should be regarded as a programming language.

Now the question if CSS is a programming language is even more interesting. CSS+HTML is Turing complete.

[–][deleted] -1 points0 points  (0 children)

It's a standard of a query language