Hacker News new | ask | show | jobs
by jacobobryant 1297 days ago
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...

1 comments

SQL for XTDB seems to be under way in the XTDB "Core2" dev work, hope they keep Datalog too.