Top
Best
New

Posted by b-man 12/18/2025

The Rise of SQL:the second programming language everyone needs to know(spectrum.ieee.org)
156 points | 134 commentspage 2
pavlov 12/22/2025|
I’ve always hated SQL, but fortunately LLMs write it so well that it’s effectively become a read-only language now. You just need to know enough to check the output.
system2 12/22/2025|
I agree. Claude Code writes superb SQL queries for very complex data. I was dealing with PostgreSQL recently, and it improved the query from 30 seconds to 5 seconds. I couldn't figure it out myself.
rtkwe 12/22/2025|||
How do you present the interrelations between the tables when you're dealing with complex table structures?
simlan 12/22/2025|||
Prompting with documentation and examples works. In an agentic tool having an MCP server for the db helps assuming it is a straightforward schema with explicitly defined relationships. Also helps if the tables correspond to entities in a natural way.
lateforwork 12/22/2025||||
Use a tool to do that. Try https://visualdb.com it can send the relationships and table definitions to AI.
rtkwe 12/22/2025||
We're pretty locked down around AI tools. Right now we can only really use GH Copilot, it's been ok so far though it's funny to see it suggest edits then suggest the opposite on the next time it review the PR if you accept them.
sfn42 12/23/2025|||
I just go into SSMS and expand the columns for the tables I care about in the left hand explorer, screenshot it and send that to copilot.
baq 12/22/2025|||
sonnet 4.5 was really bad at anything more than simple queries. even GPT 5 was not great. gemini was consistently good even at 2.5; caught multiple bugs in outputs of either. I haven't tested Opus 4.5 properly at SQL yet, but I've got a feeling Anthropic doesn't prioritize it in training and google does.
system2 12/23/2025||
I switched to Opus permanently, but I am being cautious. It tends to go berserk and add a bunch of extras. Most of my time is spent narrowing the task to it. Sonnet was much more straightforward forward, but Opus' quality is unmatched when compared. I caught Opus messing up my CSP settings, and I had to restrict the access levels to deeper levels. Using it as an agent with full access without a plan more is suicide with Opus, but Sonnet didn't have this problem.
yawaramin 12/22/2025||
Learning SQL basically launched my career as a professional SWENG. Once I knew SQL, I found ways to apply it in even non-technical jobs.
bikeshaving 12/22/2025||
This is a nice coincidence.

I’ve been heads-down on publishing a JavaScript full-stack metaframework before the end of the year. However, in the past two weeks I’ve been goaded by Claude Code to extract and publish a separate database client because my vision includes Django-style admin/forms. The idea is to use Zod to define tables, and then use raw SQL fragments with JavaScript template tags. The library adds a tiny bit of magic for the annoying parts of SQL like normalizing join objects, taking care of SELECT clauses and validating writes.

I’m only using it internally right now, but I think this approach is promising. Zod is fantastic for this use-case, and I’m sad I’ve only just discovered it.

https://github.com/bikeshaving/zen

adamddev1 12/23/2025|
This looks promising!
deepsun 12/23/2025||
My only problem with SQL is it was designed for human input (same as shell commands), not for machines. Hence the SQL Injection attacks and other peculiarities and inefficiencies.

IMO for machine-to-machine talk we should not be using a long text that needs to be parsed carefully and securely on the other side, but rather a structured structure that's easy to de-serialize (like AST packed into a protobuf, but for SQL). So that any invalid SQL parameters like "1;DELETE FROM users;--" would just fail to parse.

It may be called ABI, although it may be textual as well (like json), not necessarily binary (like protobuf).

PostgreSQL already supports binary wire protocol, but I never seen it's being used, instead people prefer sending raw SQL strings designed for humans even from applications.

brettgriffin 12/23/2025||
You'd have to be using very antiquated (by nearly two decades!) patterns or practices for SQL injection to be a concern.
deepsun 12/23/2025||
Agree, but for example, migration scripts are still often just a bunch of long .sql files (unless it's Liquibase with its own cross-DBMS XML syntax), or test/staging/benchmark schemas. Even today.

And subling commenters say that all you need is raw SQL and results mapping to your code. Which I did for a while, but found that mapping is a lot of copy-pasta with minor diffs, a burden to maintain. So it's easier to use a thin library like JOOQ for mapping, or use only the mapper part of a bigger ORM framework like Django/Hibernate.

And my argument is that it's easier to map to/from a concise strongly-typed ABI/API structs instead of one raw SQL string with its structure designed for human reading/writing, like SELECT before FROM. There are such ABI-s, but they are DBMS-specific, while SQL is less so.

SoftTalker 12/23/2025||
luckily you can use parameterized queries and completely avoid this problem.
deepsun 12/23/2025||
Only for simple queries. E.g. it's hard to parameterize table names.

Also it makes an extra round-trip to server to prepare the query.

TomasBM 12/22/2025||
Somewhat tangential to the article, but why is SQL considered a programming language?

I understand that's the convention according to the IEEE and Wikipedia [1], but the name itself - Structured Query Language - reveals that its purpose is limited by design. It's a computer language [2] for sure, but why programming?

[1] https://en.wikipedia.org/wiki/List_of_programming_languages

[2] https://en.wikipedia.org/wiki/Computer_language

gfody 12/23/2025||
"structured query language" is actually a backronym, SEQUEL is indeed a programming language and the only mainstream 4GL. consider the output of the compiler (query planner) is a program with specific behavior, just that your sql code is not the only source - the other inputs are the schema and its constraints and statistics. it's an elegant way to factor the sourcecode for a program, I wonder if Raymond Boyce didn't die young what kind of amazing technology we might have today.
derriz 12/22/2025|||
With support for Common Table Expressions (CTE), SQL becomes a Turing complete language. To be honest, it makes me somewhat uncomfortable that a query sent to a DB server could be non-terminating and cause a server thread to enter an infinite loop. On the other hand, the practical difference between a query that contains an infinite loop and one that runs for days is probably negligible.
Imustaskforhelp 12/22/2025|||
To be honest, I'd like to chip in that it is technically possible to write brainf*ck, an esoteric programming language but nonetheless, its a programming language

https://www.reddit.com/r/SQL/comments/81barp/i_implemented_a...

Btw this runs in sqlite, you can try it yourself if you are interested.

Source: I was thinking of creating a programming language paradigm like sqlite/smalltalk once where resumed execution/criu like possibilities were built in. Let me know if someone knows something like this too. I kinda gave up on the project but I knew that there was this one language which supported this paradigm but it was very complicated to understand and had a lot of other first time paradigm like the code itself / the ast tree is sort of like a database itself but so the tangential goes.

pjmlp 12/22/2025|||
Because stored procedures do exist, and there isn't a single production quality RDMS that doesn't go beyond DDL and DML, adding structured programming extensions.

Also, even within the standard itself, it allows for declarative programming.

yawaramin 12/22/2025|||
What is your definition of 'programming language'?
lateforwork 12/22/2025||
It should have arrays, and loops and conditionals.
Izkata 12/23/2025|||
Slightly simplistic: table rows cover arrays, recursive CTEs cover loops, and JOIN/WHERE cover conditionals.
yawaramin 12/24/2025|||
OK. My definition is that it should be able to add two integers together and give you a result somehow. So in SQL:

    select 1+1; -- Result: 2
In HTML: not possible.

That's the key difference.

rawgabbit 12/22/2025|||
Because "programming language" is an adjective or a descriptive term. Whatever looks like a programming language, can be called a programming language.
randomNumber7 12/22/2025||
Also SQL is not turing complete. I see it more as a descriptive language like e.g. html is a language but not a programming language.
hunterpayne 12/22/2025|||
This is completely wrong. The SQL spec isn't Turning complete but multiple DBs provide Turing complete extensions (like pgplsql) that make it so. Also, even without the extensions, it is still very much a programming language by any definition of the term. Like most takes on SQL, it is more about your understanding (or lack thereof) of SQL.
geysersam 12/23/2025|||
I was under the impression that recursive CTEs make the SQL spec Turing complete. Not that it makes any practical difference, it's still very difficult to use for "general purpose" programming, and still very practical to use for data processing / management.

Last year I read about some database researcher who implemented AoC in pretty standard SQL.

bigstrat2003 12/23/2025|||
If the spec isn't Turing complete, only individual extensions to the spec, I think it's correct to say "SQL isn't Turing complete".
rawgabbit 12/22/2025|||
It can do loops and recursion. It can use as much memory as it is allowed. It can do general programming via functions and stored procedures.
lateforwork 12/22/2025||
It can't do loops. Unless you're talking about extensions to SQL such as PL/SQL and T-SQL.
geysersam 12/23/2025||
It can do loops. Recursive CTEs has been in the standard since SQL:1999

https://en.wikipedia.org/wiki/SQL:1999

gjvc 12/23/2025||
https://blog.codinghorror.com/object-relational-mapping-is-t...
avmich 12/23/2025||
The problem of SQL is that is is ubiquitous.

The advice to learn SQL is because it's everywhere. Now it has inertia, and a better way of doing things has an uphill battle. In 1980-s somebody compared working with SQL to drinking data through a straw, comparing to swimming in data with APL. We had a recent article comparing modern SSD delays and RAM sizes to those which defined architectures of SQL systems of recent decades - we can perhaps reengineer our databases better for modern opportunities. But all these approaches have to deal with SQL as an entrenched technology. Probably a task for a company of a Google class.

mpalmer 12/24/2025||
Getting more than a little tired of "news" stories like this, that read as though the author is learning about the subject matter for the first time.

That in itself is fine, of course. Less fine is the author's thoughtless assumption that their readers are all learning about it too.

jinwoo68 12/22/2025||
Folks, the article is from 3 years ago, 2022.
calebm 12/22/2025|
With LLMs, you should be able to just query in English and have LLMs transpile from English to SQL.
bigstrat2003 12/23/2025||
You should also be able to reliably generate working code with LLMs, but you can't. They aren't a good tool until they actually work when they are supposed to.
tete 12/22/2025||
SQL largely is plain English, which is one of its design choices.
More comments...