Live data from Hacker News

DataScript: Immutable database and Datalog query engine in ClojureScript

github.com

21–30 of 30 posts

Re: DataScript: Immutable database and Datalog query engine in ClojureScript

#21

Earlier quoted context omitted.

> 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

That's how every langauge with immutable data structures works. What makes this one special?

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 in ClojureScript

#22

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.

Love the classic HNer combination of wrong and know-it-all.

Re: DataScript: Immutable database and Datalog query engine in ClojureScript

#23
post #7

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.

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.

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 in ClojureScript

#24
post #18

Earlier quoted context omitted.

We're also using it in production, and it works really well when paired with Datomic. Thanks to transaction queues on both ends, we can set up a meteor-style sync that's pretty handy. It's also well-suited for rapid-prototyping. I'm working on a small project that will eventually need a backend, but for now I just store everything in a datascript db and serialize that to localStorage. When I'm ready to add a backend,…

The syncing in meteor-style is something I've been interested in for a while. Do you by any chance have any document on how it's done?

Seconded.

Re: DataScript: Immutable database and Datalog query engine in ClojureScript

#25
post #18

Earlier quoted context omitted.

We're also using it in production, and it works really well when paired with Datomic. Thanks to transaction queues on both ends, we can set up a meteor-style sync that's pretty handy. It's also well-suited for rapid-prototyping. I'm working on a small project that will eventually need a backend, but for now I just store everything in a datascript db and serialize that to localStorage. When I'm ready to add a backend,…

The syncing in meteor-style is something I've been interested in for a while. Do you by any chance have any document on how it's done?

[deleted]

Re: DataScript: Immutable database and Datalog query engine in ClojureScript

#27

I've been thinking a lot about using a datascript database in place of a large mutable deeply nested hash map, or other non-regular chunk of data, to keep track of state using the amazing clojurescript library re-frame[1]. There are some times when having a novel way to query could lead to simpler data. [1] https://github.com/Day8/re-frame/

I've been playing around with re-frame and it's pretty damn easy to use. What other technologies are you going to use alongside it?

Re: DataScript: Immutable database and Datalog query engine in ClojureScript

#29
post #7

Earlier quoted context omitted.

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.

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 term…

Yep.

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

Re: DataScript: Immutable database and Datalog query engine in ClojureScript

#30
post #12

I wonder when we are going to see an open source implementation of Datomic's main ideas in the database space.

DataScript already can run on JVM natively. Only thing missing is durable storages (it’s inmemory only now, same as JS version)
Post reply on HN