Honest question, I'm curious.
Honest question, I'm curious.
Datomic takes the knowledge that many databases are built like this, and basically designs with that in mind. The ability to say "give me a view of the data as it was 1 month ago" is built into the system from the very beginning, rather than added on later.
I've seen it implemented 2 times in enterprise systems and it works OK, but like all design patterns it's workaround for lacking feature.
Also some dbs (for example Oracle) allows you to do
SELECT * FROM SOME_TABLE WHERE USER_ID = 5 AS OF TIMESTAMP...,
but that's not good enough.While googling I've found from this post: http://www.postgresql.org/message-id/Pine.GSO.4.64.080203152...
this free (?) book - Snodgrass/Jensen "Developing Time-Oriented Database Applications in SQL" - http://www.cs.arizona.edu/people/rts/tdbbook.pdf
Haven't read it, so I'll spend some time through it.
To me this is an interresting thing, since I would like to know whether I can do history tracking of game asssets for game development. E.g. often in our studio someone would like to compare data, how it was before this and what changed. We do have the mechanism, but they are not so ellegant.
Regarding game assets - why not keep them in git or some other cvs? For textual data it has huge additional advantage - you can blame, merge and easily see differences, but even for binary data it can be used.
Don't get me wrong, I like immutable data and I use it over mutable whenever possible (Clojure is my favorite language), but to call it "flawed" is an overreach at best.
No, they are only inaccurate software abstractions of the business abstractions they are supposed to model. People like immutability and reversibility of concepts and that's why they try to apply it in business, law, finance etc.
But the real/natural world, at least from our subjective perspective is not like that. Things in the world are not practically reversible or immutable - you cannot "restore" a deadbody. The real world is loosy and mutable, at least from an agent's perspective. The human brain is so efficient at what it does simply because it just "throws way* (irreversibly!) so much information every second, filtering for just what it needs. A small corner of the world is our "business/finance world" and using immutability and reversibility is great here, but there's way more to computing than implementing business/finances logic and processes in software!.
...if you think about it, classical OOP is inspired from cellular biology (can't find the reference now, some musing of Alan Kay I think...), so it's no wonder why it's such a trouble maker when used to model business logic, it was the wrong tool for the job from the get go. But generalizing that mutable data structures are a bad tool to model and understand the world in general is waaaay overstretched, the world is bigger than "business", and all modeling approaches are equally useful.
If you think I'm wrong about this, I'd appreciate some examples.
Mutability is useful as an optimisation, but I don't think it has much worth as a model.
No, it's not. You cannot mutate any fact! You will never be able to change the fact that Hitler existed, for example. Facts never change.
This is the purpose of Datomic: to store facts. Mutable databases only seem to be interested in maintaining the most recent fact about any particular piece of information.
> Mutable state makes reasoning about program behavior more difficult than necessary.
You could dispute that claim, but bringing up performance characteristics is totally irrelevant to it.
Yet programming in imperative, mutating, mainstream languages is nothing like how code works at the machine level. I understand you're talking about data, but I think the analogy still stands. Or maybe a better one is that a file system or even a database itself is an abstraction of how data is stored on disc.
There are other distributed consistent databases (HBase, RethinkDB, arguably Cassandra if you always use QUORUM, etc.) but neither supports transactions or has a design that seems to me like it easily could.
The storage layer is distributed automatically because it's decoupled from both the transactor and the peer. It's actually pluggable, too... you can use DynamoDB, Riak, Couchbase, Infinispan, Postgres, etc. which all have different performance and availability characteristics.