News for hackers. Stuff that matters.
Re:DataScript: Immutable database and Datalog query engine i... by wereHamster on Friday July 03, 2015 @04:37PM (#9827819)
Immutable database? That doesn't make sense. If you can't mutate it, how do you write to it? How do you update records in it? If it's really immutable then you can't. Such a database is a compile-time constant.

These days everybody seems to throw around terms like immutable, isomorphic, pure etc. without actually knowing what they mean, or using them in contexts whey they don't make any sense.

Re:DataScript: Immutable database and Datalog query engine i... by dragonwriter on Friday July 03, 2015 @05:07PM (#9827959)
> Immutable database? That doesn't make sense. If you can't mutate it, how do you write to it? How do you update records in it?

You don't write to the database, you perform an operation that takes a database and a write request and returns a new database. Same with updates. Essentially, the kind of things you think of as "mutating" operations have a signature of, in Haskell-ish notation:

  db -> operation -> db
Re:DataScript: Immutable database and Datalog query engine i... by wereHamster on Friday July 03, 2015 @06:47PM (#9828329)
That's how every langauge with immutable data structures works. What makes this one special?
Re:DataScript: Immutable database and Datalog query engine i... by dwwoelfel on Friday July 03, 2015 @07:12PM (#9828408)
With this one, the database is an immutable value, so you can hold on to old versions of it. Here's an incomplete example of how you could implement optimistic updates:

    tx_report = datascript.transact(db_conn, [{:key "value"}]);
    set_db_to_render_from(tx_report.db_after);
    send_report_to_server(tx_report, function(error) {
      set_db_to_render_from(tx.report.db_before);
    });
Re:DataScript: Immutable database and Datalog query engine i... by sheepmullet on Friday July 03, 2015 @09:06PM (#9828720)
Normally when you update a row in a database you lose the ability to access the previous values. E.g. If you update your address it overwrites your previous address

With datomic you are just adding a new fact. My address is now x. This has a lot of nice properties. I can now easily write a query to tell me your previous 5 addresses, rolling back is easy, you can get amazing and scalable read performance, etc etc

In the past we have either had to hand roll our own features (e.g. Have a table of past addresses, or add date columns to specific tables) or rely on error prone/brittle techniques like using audit tables, source control, or transaction logs.

Datomic makes it easy!

Re:DataScript: Immutable database and Datalog query engine i... by vruiz on Friday July 03, 2015 @04:51PM (#9827890)
The data is immutable, not the database itself, meaning that you create entries but not modify them. The same way you can not modify a constant after you create it. "Immutable data database" would sound a bit redundant.
Re:DataScript: Immutable database and Datalog query engine i... by the_nish on Friday July 03, 2015 @11:01PM (#9828969)
Love the classic HNer combination of wrong and know-it-all.
Re:DataScript: Immutable database and Datalog query engine i... by j-pb on Friday July 03, 2015 @05:06PM (#9827952)
The database is in fact immutable, it's just a persistent data-structure that allows for fancy queries.

You wrap that data-structure/database in a mutable reference type (an atom), like you do with any other data-structure in clojure if you need change.

Re:DataScript: Immutable database and Datalog query engine i... by amirouche on Friday July 03, 2015 @11:31PM (#9829041)
I did not understand persistent until someone point me to the wikipedia article [1]:

> In computing, a persistent data structure is a data structure that always preserves the previous version of itself when it is modified. Such data structures are effectively immutable, as their operations do not (visibly) update the structure in-place, but instead always yield a new updated structure.

The way I understand it in terms of python: It's like a nametuple or dict, where each update return a new namedtuple/dict with the new values for modified attributes but still the old values for attributes that did not change. It doesn't need to deep copy all the datastructure/database.

This is not persistent as in "stored on disk". Being append only is a way to achieve persistence except it is also applicable to non-stored-on-disk datastructures.

[1] https://en.wikipedia.org/wiki/Persistent_data_structure

Re:DataScript: Immutable database and Datalog query engine i... by TheLoneWolfling on Saturday July 04, 2015 @05:24PM (#9831658)
Yep.

(Fully) persistent data structures are absolutely wonderful. It's a pity that more languages don't have syntactic sugar for them.