Hacker News new | ask | show | jobs
by charesjrdan 1297 days ago
What’s the reasoning behind using some database I’ve never heard of vs Postgres etc?

Interesting project though

2 comments

The main ways that XTDB has been useful to me personally are:

- Immutability, which makes it fit well with the functional programming style used in Clojure. You can create a database connection object that represents a snapshot of the database at a specific point in time (usually the current time), and queries made via that object will ignore any transactions that occurred later. So you can effectively pass the entire DB around as an argument and your functions stay pure. (That also makes it easy to inspect historical snapshots, similar to looking through old git commits--I don't do it often, but it's very nice to have when you need it.)[1]

- Datalog instead of SQL. I find Datalog queries to often be more compact than the equivalent SQL, especially thanks to the implicit joins--you can query for things from multiple "tables" without having to type up a bunch of JOIN expressions. And there are various other handy doodads like pull expressions[2].

- Clojure ergonomics. You can store Clojure maps as XTDB documents as-is without needing to write code to translate them to records.

[1] XTDB's bitemporality also has some benefits over e.g. Datomic (https://www.datomic.com/, another immutable, Clojurey database), though I haven't needed to use it yet--Datomic's "monotemporality" would be sufficient for my current needs.

[2] https://docs.xtdb.com/language-reference/datalog-queries/#pu...

SQL for XTDB seems to be under way in the XTDB "Core2" dev work, hope they keep Datalog too.
It's bitemporal and a graph database and so on. It seems like it can cover most of the use cases of a number of other dbs. This goes into that: https://docs.xtdb.com/concepts/what-is-xtdb/

"Many databases can support various levels of "time travel" queries across transaction time (i.e. the transactional sequence of database states from the moment of database creation to its current state), however such capabilities are typically complex to use and have practical limitations. By contrast, XTDB provides an always-on capability for point-in-time querying of past transactional states and across the valid time axis."