3 ms·
I'd love to see more use of relational concepts inside programs. One problem is that making use of relations involves very high level descriptions of computatio
by barrkel 10y ago
I'd love to see more use of relational concepts inside programs. One problem is that making use of relations involves very high level descriptions of computations, and computing them efficiently requires a lot of smarts - you'd risk baking half a database engine into the runtime.
There would still be a bit of a mismatch between relations held locally - a kind of disconnected data set - and relations in the persistent store. Synchronization, local-remote joins, transactions - there are lots of details to get right.
It's not something trivially added on via a library either, not if you want to do it right (properly typed, abstracted at the right level, e.g. creating ASTs to represent the computation).
- eru 10y agoSomething like Haskell might have a rich enough type system to embed relations properly. (They've done statically typed relations in Standard Chartered's Haskell dialect, recently, after having had dynamically checked relations for years.) And not only type system, but also the AST ideas you are talking about. Check out higher-order abstract syntax. > One problem is that making use of relations involves very high level descriptions of computations, and computing them efficiently requires a lot of smarts - you'd risk baking half a database engine into the runtime. I wonder if a variant of Greenspun's tenth rule applies? "Every sufficiently complex program (without formal relations) contains a half-baked database engine."
- tome 10y ago> Something like Haskell might have a rich enough type system to embed relations properly. It has alread been done (and, unlike Standard Chartered's version, no weird and non-composable type-level programming required) https://hackage.haskell.org/package/opaleye https://hackage.haskell.org/package/opaleye Disclaimer: I wrote Opaleye, but most of the "embed statically typed relations in Haskell" leg work was done by HaskellDB.
- eru 10y agoSounds awesome. I'll check it out. Hmm, it says: > An SQL-generating DSL targeting PostgreSQL. Allows Postgres queries to be written within Haskell in a typesafe and composable fashion. Genering Postgres queries sounds very different from using relations as a datatype inside my program. Or is that feature buried somewhere deeper?
- tome 10y agoOpaleye only targets Postgres, not in-memory relations, but if one were to implement in-memory relations in Haskell then they could/should/would have roughly the same type structure as Opaleye.