Hacker News new | ask | show | jobs
by remywang 39 days ago
Every verification needs a spec, and in this case the spec is the Postgres implementation. I think we can and should do a lot better than taking 2.6 million lines of C code as the spec.

In general, the spec must be human readable, and I believe to achieve that we must do away with SQL. Putting aside the thousands of pages of SQL standard, even the core subset has a gnarly semantics due to issues like nulls.

A simpler semantics is one of the main motivations behind Prela [1], and despite its simplicity, we now know it’s powerful enough to express thousands of queries in the wild [2], as well as run doom [3].

[1]: https://prela-lang.org/

[2]: https://github.com/remysucre/prela/tree/sqlstorm

[3]: https://github.com/remysucre/prela/tree/doom/

4 comments

Sometimes it's good to have bug-for-bug compatibility, where the code is the best spec.
I always wondered about this. Software engineers always want a spec, and either complain about it being insufficiently specific or find some ambiguity and make it a reason to write their own text editor instead of shipping the fucking product. But if you hand them running code and say "make it do exactly this", they frown and don't wanna.

Like, what the literal fuck?

> In general, the spec must be human readable, and I believe to achieve that we must do away with SQL

Eh. Carthago delenda est? Why?

Yeah, that's the most impractical part of the original post.

Like, SQL was around before I was born, and barring the immanence of the Machine God (and potentially even then), will be around long after I die (unless civilisation collapses, I guess).

SQL is a lot more intellectually coherent than its syntax belies. It's easy to be attracted to things like SPARQL, which has a well-written simple public spec, or Datalog, which doesn't really have a spec but does CTE in a way that doesn't look so painfully half-baked, or to feel really queasy looking at triggers and other features... but SQL isn't that bad. Dialects like postgres actually have pretty good support for JSON.
SPARQL is cool, but fairly limited. For example, one cannot implement common graph operations like a BFS or a DFS in SPARQL, and SQL of course can (even though I wouldn't necessarily recommend it). I was fairly puzzled when I figured this out. This means SQL is strictly more expressive than SPARQL!
The semweb badly needs a SPARQL 2.0 but we won’t get it, not least because the community was burnt out by the standards process. Myself I am keen on facilities common in document databases to represent ordered collections because the culmination of my work on the semantic web was figuring out how to use (mostly) OWL to represent complex document schemas such as the ISO 20022 financial messaging standard. And order matters for that!
> the spec must be human readable

Usually I would agree with you but when porting code the source code is the spec.

Ideally an executable specification, not as hard as it sounds for many things.