4 ms·
(Author here.) I think you're confusing a couple different major classes of languages — declarative versus procedural. I said specifically "most expressive ever
by brandur 6y ago
(Author here.) I think you're confusing a couple different major classes of languages — declarative versus procedural. I said specifically "most expressive ever for querying and manipulating data", and I'd stand by that.
The nice part about SQL compared to the languages you've cited is that you just need to specify the "what" and not the "how". I tell it what data to fetch, where I want it from, how I wanted it grouped/sorted (etc.), and the engine figures out the best (and probably a very efficient) way to do that. This is different from a procedural language like Python or Rust where it'd be on me to also define every implementation detail — get data from here, join by doing this and with that algorithm, sort what comes out, ...
This gives SQL a number of very nice properties:
* It's very fast and succinct to write.
* Even very complex queries are likely to be executed as optimally as they can be (because database engines tend to be very good at this).
* It's so high-level that it can actually get more performant over time. See for example Postgres 12, which eliminated an optimization fence for CTEs (common table expressions) [1], which means that a lot of queries got faster automatically, without the user having to do _anything_.
I love a lot the languages you listed, but SQL is a different animal, and amazing in a way that's quite unique.
---
[1] https://info.crunchydata.com/blog/with-queries-present-future-common-table-expressions https://info.crunchydata.com/blog/with-queries-present-futur...
- xyzzy_plugh 6y agoI don't know. Procedural and declarative languages can both query and manipulate data. Maybe I'm being pedantic, but that's not my intent. For all of SQL's warts, it is the golden standard, and I agree with most everything else you say (it's succinct, easy to get optimal behavior, etc.) but compared to what you can express with Spark in Scala, it's not the end-all-be-all of expressivity. In fact, several SQL-compatible query engines have extended SQL to allow you to do work around its limitations and manually hint at what you want the engine to do. And even then, there are tons of situations where you fight the engine to do what you want. If I had a nickle for every Data Scientist or Finance person I unblocked because what ends up being a recursive join was making their query run time infinite...