Most unpopular true opinion:

SQL is COBOL for relational databases.
COBOL is just SQL for ISAM.

MULTIPLY QUANTITY BY PRICE GIVING EXTENSION

SELECT QUANTITY, PRICE FROM INVOICE_LINES

The worse realisation:

THERE IS NO HASKELL OR PYTHON OR JAVA OR EVEN C FOR RELATIONAL DATABASES

Of all the possible interfaces for all our data, we went with the COBOL-like one. Fake English sentences. As strings. That you have to generate and parse at runtime.

And stuck with it for 40 years, because if there's one thing we programmers are great at, it's reinventing and reengineering everything that's even faintly inefficient, amirite

Show thread

@natecull My brother spoke very clearly on this: "Why are we speaking to databases in sentences?"

It would be much better if we could speak to databases on some general-purpose AST, be that canonical s-exps or heck even json. Something with structure.

That we're having to encode rules to avoid "little bobby tables" security risks in every language is bonkers.

Follow

@cwebber @natecull Isn't this solved by libraries like SQLAlchemy Core? Any text protocol might have attacks like SQL injections; I have seen code not escaping ' in JSON, there are attacks on apps accepting newlines in HTTP headers. Or is the problem in libraries (not protocols and languages) treating SQL/HTML/... as text?

@mtjm @natecull JSON has a realtively consistent structure that can be parsed in a few hundred lines of code.

However, SQL: more-magic.net/posts/lispy-dsl

@natecull @mtjm I'd challenge you: what's the smallest, consistent parser and writer you can build for... let's make it "simple", and take a single Database's syntax. Write a universal parser and writer for all of Postgres' syntax from a structured representation to the appropriate strings, and the reverse.

Can you do it? How large would it be?

@cwebber @natecull It looks easier with writers only, not parsers, in client libraries. Cases like PostgreSQL getting a new feature, or implementing such a library in a new programming language, are very good arguments for a consistent protocol syntax. (Or being able to hack tools for e.g. generating a smaller query reproducing a bug.)

@cwebber @natecull @mtjm I can parse JSON in one line of code? (Although it will take a couple more lines to work with it after it's an object)

@hyper I find this difficult to believe... using eval (yuck) or using an existing parser isn't relevant to the conversation here.

Could you paste your one-line-json-parser?

Sign in to participate in the conversation
Mastodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!