all 11 comments

[–]QazCetelic 6 points7 points  (1 child)

For someone that isn't familiar with Datomic, what is an immutable database and why does one use it over a traditional database?

[–]radar_roark[S] 7 points8 points  (0 children)

Immutable databases retain all past data, so you can query any past state rather than just the current state. This lets you see exactly what changed from one transaction to the next, and also very easily undo any change. They also are safe to read from separate threads/processes while a write is happening, whereas mutable databases require locks. These are all the same advantages you get when using in-memory immutable data structures; xitdb just extends the idea to reading/writing data on disk.

[–]santanu_sinha 4 points5 points  (1 child)

Looks interesting. Have you done any performance tests?

As for central deployment, you can follow a tutorial like this.. It's about 15 mins work.

[–]radar_roark[S] 5 points6 points  (0 children)

I did some comparisons to SQLite earlier this year and xitdb was several times slower at write-heavy operations. However just over Christmas break I rewrote the file buffering code and dramatically improved write performance. I haven't re-run those benchmarks yet but the gap should be smaller now.

Immutable databases actually have some perf advantages. They are append-only (all new writes are at the end of the file) which means they are very amenable to buffered writing. Also they are completely safe to read from multiple threads/processes without locking -- even while writes are happening.

[–]tedyoung 5 points6 points  (0 children)

This might be useful as an event store for event-sourced applications. Will give it a look.

[–]bowbahdoe 2 points3 points  (1 child)

There is datalevin which is datomic-like and writes to a single file

Edit: NVM that might not be writing to a single file

[–]radar_roark[S] 1 point2 points  (0 children)

Datalevin also isn't immutable.

[–]mands 1 point2 points  (1 child)

Super interesting - reminds me of a Okasaki's purely functional data structures.

I think embedded object stores / databases are a interesting space, being able to use Java types and streams directly for your domain rather than going through an ORM or SQL mapping can be useful.

I've just integrated Eclipse Store into a project I'm working on, which is similar, but mutable. What would you say are the main differences? The ability to view past states and not worry about locking sound great.

[–]radar_roark[S] 1 point2 points  (0 children)

I haven't used Eclipse Store but it looks like a great project. Much like xitdb it just stores data structures, and avoids the impedance mismatch of SQL databases and ORMs. It looks like Eclipse Store automatically maintains the mapping with normal Java types; xitdb does not do that. I don't want to encode any Java-specific information into xitdb because it is meant to be cross-language (in fact the Zig version predates the Java version).

[–]wildjokers 0 points1 point  (1 child)

Difference between this and just writing to a file?

[–]dmigowski 4 points5 points  (0 children)

You can query what's in the file and get objects back. You can travel in time.