Live data from Hacker News

SQL looks like English is a well intentioned error

github.com

1–10 of 24 posts

Re: SQL looks like English is a well intentioned error

#2
Lately I've been experimenting the usage of LLMs for the explainability of SQL stored procedures with exceptionally good results - think about identifying important fields, linking them to existing glossaries, expanding said glossaries, etc. I wonder how much SQL looking like natural language helped for my use case.

Re: SQL looks like English is a well intentioned error

#3
I am no fan of the syntax of SQL, however the authors solution of making SQL more procedural is (imo) correctly identifying an issue but then reaching for the wrong tool to fix it.

When I am authoring SQL, I find the declarative and relational concepts extremely powerful and well suited to the problem I am solving.

Re: SQL looks like English is a well intentioned error

#4
post #2

Lately I've been experimenting the usage of LLMs for the explainability of SQL stored procedures with exceptionally good results - think about identifying important fields, linking them to existing glossaries, expanding said glossaries, etc. I wonder how much SQL looking like natural language helped for my use case.

> Lately I've been experimenting the usage of LLMs for the explainability of SQL stored procedures with exceptionally good results

Heavily agree here. LLMs have significantly shortened the time it takes me to write complex queries.

Re: SQL looks like English is a well intentioned error

#5
> and after GROUP, an extra BY needs to be written.

group /= groupBy.

Group just put things in groups. GroupBy allows for a function on the item to be used (think passing a custom comparator into a sort() function). In SQL's case I think this is just limited to a column id, but I could be wrong.

> The main downside of being like natural language is non procedural. Program logic is generally executed step by step

SQL has thrived on being non-procedural. It is high-level and abstract, and its various implementations make much better optimisations than would the average-idiot-programmer-in-a-hurry.

All that would go out the window if the programmer had to write how to do things. Forget 'repeatable read' or 'linearisable' or any correctness guarantees provided by a database - if it's up to the programmer to write how, not what, then your correctness guarantees are basically: "I hope every programmer who touched this codebase took the right number of locks in the right order at the right time".

Re: SQL looks like English is a well intentioned error

#6
I find the author to be fairly out of touch with modern programming languages based on the assertions made in the article. But more importantly, I think leaning into procedural programming is a fundamental misunderstanding of the power of declarative syntax and also does not take advantage of the RDBMS’ biggest strength: the ability to think in sets.

Re: SQL looks like English is a well intentioned error

#7
post #3

I am no fan of the syntax of SQL, however the authors solution of making SQL more procedural is (imo) correctly identifying an issue but then reaching for the wrong tool to fix it. When I am authoring SQL, I find the declarative and relational concepts extremely powerful and well suited to the problem I am solving.

I agree with you.

Changing SQL to a description of how you'll get the data would make a query incomprehensible to me.

Re: SQL looks like English is a well intentioned error

#8
post #2

Lately I've been experimenting the usage of LLMs for the explainability of SQL stored procedures with exceptionally good results - think about identifying important fields, linking them to existing glossaries, expanding said glossaries, etc. I wonder how much SQL looking like natural language helped for my use case.

Do you have any suggestions on prompts to use here?

Re: SQL looks like English is a well intentioned error

#9
The authors argument that SQL's english-like syntax is a "well-intentioned error" overlooks the accessibility it provides. SQL, inspired by relational algebra, enables set-based operations, distinct from procedural programming's linear approach.

This is why SQL has endured for so long.

That mathematical base allows for efficient data manipulation across vast datasets.

To his point that no other languages strive to be spoken like, languages like ruby (and python to a degree )have successfully adopted a natural, english-like syntax, enhancing readability and developer productivity.

Emphasizing procedural over declarative concepts misinterprets SQL's core advantage: expressing complex data relationships and manipulations succinctly. Such perspectives miss the broader utility of making programming languages approachable and efficient for diverse tasks and user backgrounds.

Side rant: I just wish SQL was more composable.

Re: SQL looks like English is a well intentioned error

#10
Anyone who has had to sift through large BNFs such as [0, 1] to find that the syntax error was a syntactically significant "TO" knows that this is the case. Natural language has synonyms, computer languages really should avoid synonyms and also any spurious syntactic sugar.

[0] https://www.postgresql.org/docs/13/sql-altertable.html

[1] https://www.postgresql.org/docs/13/sql-commands.html

Post reply on HN