11 ms·
So, how does immutability matter if we deal with the database -- which is what holds the state, and is obviously mutable.
by carterehsmith 7y ago
So, how does immutability matter if we deal with the database -- which is what holds the state, and is obviously mutable.
- fnordsensei 7y agoDatomic is immutable in the sense that what you had for lunch today doesn't change what you had for lunch yesterday, where "lunch" is any arbitrary fact stored in the database. I.e., you can ask to look at the entire database as it was yesterday, and run arbitrary queries against it. You can also do speculative updates to it, in the sense of "show me the entire database as it would be if I were to have pizza for lunch". It models this as a strictly linear succession of assertions and retractions of facts. Yesterday, `A` was true, today `A` is no longer true. While this new fact is recorded, it doesn't change the fact that yesterday, `A` was true.
- carterehsmith 7y agoSounds great in theory. What we see in reality is that append-only database is unusable without making additional "projections" or whatever you call them, databases that are ready to be queried/updated, with maybe specific denormalizations, indexes and so on. And oh, btw, those later databases are not "imutable".
- fnordsensei 7y agoIt’s structured so that these operations can be done pretty much instantaneously. Schema is sort of asserted at read time, not write time. I highly recommend the talk “Domain modeling and with Datalog”[1]. It gives an explanation of how all this works, including indexing. 1: https://youtu.be/oo-7mN9WXTw https://youtu.be/oo-7mN9WXTw
- dustingetz 7y agoDstomic is an immutable log (kind of like git). the only operation is append. there is a head pointer stored pointing to “latest”, this is the point of mutation you’re looking for, and it’s the only point.