Top
Best
New

Posted by b-man 4 days ago

The Rise of SQL:the second programming language everyone needs to know(spectrum.ieee.org)
138 points | 118 commentspage 2
FjordWarden 16 hours ago|
The CM DB group YT channel is good place to learn about the basics and advanced topics: https://www.youtube.com/@CMUDatabaseGroup
Tostino 15 hours ago|
I find them great for database development, but haven't seen practical "how to use SQL" type advice from Andy.
avmich 11 hours ago||
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.

yawaramin 16 hours ago||
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 16 hours ago||
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 9 hours ago|
This looks promising!
TomasBM 16 hours ago||
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 8 hours ago||
"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 15 hours ago|||
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 16 hours ago|||
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 16 hours ago|||
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 16 hours ago|||
What is your definition of 'programming language'?
lateforwork 14 hours ago||
It should have arrays, and loops and conditionals.
Izkata 12 hours ago||
Slightly simplistic: table rows cover arrays, recursive CTEs cover loops, and JOIN/WHERE cover conditionals.
rawgabbit 16 hours ago|||
Because "programming language" is an adjective or a descriptive term. Whatever looks like a programming language, can be called a programming language.
randomNumber7 15 hours ago||
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 13 hours ago|||
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 4 hours ago|||
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 4 hours ago|||
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 14 hours ago|||
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 hours ago||
It can't do loops. Unless you're talking about extensions to SQL such as PL/SQL and T-SQL.
geysersam 4 hours ago||
It can do loops. Recursive CTEs has been in the standard since SQL:1999

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

pavlov 15 hours ago||
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 15 hours ago|
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 15 hours ago|||
How do you present the interrelations between the tables when you're dealing with complex table structures?
simlan 15 hours ago|||
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 14 hours ago|||
Use a tool to do that. Try https://visualdb.com it can send the relationships and table definitions to AI.
rtkwe 13 hours ago||
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.
baq 14 hours ago|||
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 7 hours ago||
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.
jinwoo68 14 hours ago||
Folks, the article is from 3 years ago, 2022.
calebm 14 hours ago||
With LLMs, you should be able to just query in English and have LLMs transpile from English to SQL.
bigstrat2003 4 hours ago||
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 14 hours ago||
SQL largely is plain English, which is one of its design choices.
ifh-hn 14 hours ago||
I've always gravitated towards query languages and SQL is one of my favourites. I've never really understood the need for ORMs and other abstractions but then I'm not a software developer.

If I was going to chose a "third" language I'd say regex.

namegulf 15 hours ago|
Data is the new oil or gold, SQL is the tool, the language to interact with it.

Put it together, it's pure gold!

More comments...