News for hackers. Stuff that matters.
Re:SQL is syntactic sugar for relational algebra by pkkm on Saturday March 23, 2024 @08:57AM (#39799603)
Agreed, I wish that SQL was more concise and organized more left-to-right, like shell pipelines or the F# pipe operator. But what are the alternatives? The only one I know is PRQL, and that doesn't seem to be getting popular (correct me if I'm wrong).
Re:SQL is syntactic sugar for relational algebra by __mharrison__ on Saturday March 23, 2024 @10:39AM (#39800276)
Pandas and now Polars can replace a lot of SQL. I find that many of my students find these easier to build up and debug.
Re:SQL is syntactic sugar for relational algebra by AdrianB1 on Saturday March 23, 2024 @09:24AM (#39799756)
It is organized, especially if you write it correctly (split lines and indent). Minified, it is a nightmare, but with a proper layout it is a pleasure to read it. I just did a code review for a 20,000 LoC piece and it was quite a breeze after I improved the layout a bit.
Re:SQL is syntactic sugar for relational algebra by pkkm on Saturday March 23, 2024 @10:09AM (#39800043)
"Disaster" may be an exaggeration, but I think the syntax could be better, proper layout or not. In particular, I find that complex SQL queries often need to be read in a "spiral" order due to SQL's attempt to resemble natural language. I find PRQL's consistent left-to-right/top-to-bottom reading order a clear improvement.
Re:SQL is syntactic sugar for relational algebra by listenallyall on Saturday March 23, 2024 @03:56PM (#39802675)
I can understand that the statement order can be awkward, such as choosing what to select before the source.

But help me with "more concise". SQL has no boilerplate, its keywords are brief, you express the exact logic of the result set you're seeking. There are tons of SQL overlays or replacements embedded in programming languages or BI/reporting tools, and they are universally, more difficult to work with than straight SQL.

Re:SQL is syntactic sugar for relational algebra by temporarely on Saturday March 23, 2024 @04:56PM (#39803045)
There is a paper at the end of this link trail and that paper discusses everything that is wrong with SQL including concision.

https://news.ycombinator.com/item?id=39798528

et voila: https://www.cidrdb.org/cidr2024/papers/p48-neumann.pdf

see their comments on WITHIN GROUP and redundant declaration of identifiers. As for boiler plate, SQL's turf war over plain English words as reserved names creates this interesting situation of boiler plate identifiers in SQL to disambiguate from reserved keywords.

Re:SQL is syntactic sugar for relational algebra by listenallyall on Saturday March 23, 2024 @08:02PM (#39803958)
This is nothing more than one guy's opinion dressed up to look like an academic study. He actually admits a few times that SQL features are concise. SQL definitely isn't perfect, and some vendors' implementations are better than others, but things like JOINs are pretty perfect. He considers specifying an INNER JOIN as syntactic sugar (over using WHERE equality), which seems backwards, as opposed to a more consistent practice of always using the JOIN keyword regardless of the type of join.
Re:SQL is syntactic sugar for relational algebra by pkkm on Saturday March 23, 2024 @10:02PM (#39804541)
That one was more of a nitpick, so maybe I shouldn't have included that. What I had in mind was that I would like a bit more symbols instead of words, for example value IN [1, 10] instead of value BETWEEN 10 AND 10.

Some operations on groups are also too verbose, like getting top 5 items in each group.

Re:SQL is syntactic sugar for relational algebra by listenallyall on Sunday March 24, 2024 @02:48AM (#39805509)
IN already has a different meaning. BETWEEN 1 AND 10 is exactly how a human would describe it to another person.
Re:SQL is syntactic sugar for relational algebra by anon84873628 on Saturday March 23, 2024 @06:51PM (#39803593)