
DataScript – Datomic in ClojureScript - sgrove
https://github.com/tonsky/datomicscript
======
drcode
Looks like a great library... It would be intriguing to try to use something
like DatomicScript for the app state of an Om application.

(Edit: Read in a separate blog post that the author of DatomicScript is
thinking about this already)

At the end of the day though, I still think someone (smarter than me) needs to
figure out the full end-to-end solution for datomic+clojurescript, with both
client and server elements.

The core question: Does it make sense to map datomic to a REST API on the
server, then consume the REST on the client? Or, does it make more sense to
build something more clojure-like for the client-server interface, and remove
REST from the equation entirely?

~~~
vdm
[https://twitter.com/richhickey/status/355394063165440000](https://twitter.com/richhickey/status/355394063165440000)

~~~
drcode
Interesting, I get the feeling though that RH also thinks this isn't the right
approach, that some more though needs to be put into the client-server
interface still that goes beyond vanilla datomic.

~~~
tonsky
Thing is, server-side Datomic peers work in trusted env; every peer sees
everything. As you start doing something like a peer in every browser that
opens your app, you need to provide it only with the part of the database.
This filtering should be done two-way (what’s allowed to read, what’s allowed
to push back) and is not very straightforward thing to do. It’s not even clear
how this thing should be configured. Also server-side lazy loading model won’t
work in JS — queries will become async. Given that, server-client
communication layer can be implemented, I guess, but it won’t look like
anything like vanilla Datomic peer.

------
puredanger
...now renamed to DataScript
[https://twitter.com/nikitonsky/status/459403600775876608](https://twitter.com/nikitonsky/status/459403600775876608)

------
dj-wonk
HN moderators: can you please rename the post, since the project has been
renamed to DataScript:
[https://github.com/tonsky/datascript/commit/5beb53d7db03bd27...](https://github.com/tonsky/datascript/commit/5beb53d7db03bd274b109c823b182214151b5058)

~~~
dang
Sure.

------
imslavko
Not familiar with Datomic. Does it mean now you can reuse querying code on the
server to real Datomic and on the client (in browser) to DatomicScript?

If so, it could lead to some features like latency compensation and stubs
similar to Meteor's MongoDB and MiniMongo. That would be cool.

~~~
tonsky
Yes, query language is almost identical.

------
sethev
This looks like a very interesting project although it's a bit confusing that
it's named after a proprietary database.

~~~
ibdknox
Why is it confusing? It's a basic port of that proprietary database to
JavaScript. It's not like it's something completely unrelated.

~~~
sethev
In the same way that OracleScript would be an odd choice of name for a SQL
database implemented in JavaScript. Now that I say that, though, I guess there
isn't really a name for what Datomic is except Datomic.

------
skybrian
I had no idea what this was, but after some wandering I found some background:
[http://en.wikipedia.org/wiki/Datalog](http://en.wikipedia.org/wiki/Datalog)

Datalog is apparently a subset of Prolog that's used by Datomic (a commercial
database) as its query language.

~~~
danneu
Here's a quick introductory resource:
[http://www.learndatalogtoday.org](http://www.learndatalogtoday.org)

~~~
cjo
The SICP lectures on logic programming will provide some conceptual background
if needed.

[http://ocw.mit.edu/courses/electrical-engineering-and-
comput...](http://ocw.mit.edu/courses/electrical-engineering-and-computer-
science/6-001-structure-and-interpretation-of-computer-programs-
spring-2005/video-lectures/8a-logic-programming-part-1/)

------
sdegutis
Looks great. I could see using this for some data crunching client-side, maybe
even in conjunction with something like graph.js.

------
jchrisa
Are there any examples of using this from a JavaScript-mostly app? I can see
it being useful as a way to clean up existing "global variable" apps.

~~~
tonsky
There isn’t—yet—but it’s a popular request and I’m now thinking it could be
made accessible from JS pretty easily

------
gcv
Curious: why is this limited to ClojureScript? I can see this being useful in
JVM Clojure in projects which do not need real or full Datomic.

~~~
coolsunglasses
Why even limit it to Clojure and ClojureScript? I could use this from
JavaScript or PureScript as an immutable local store to replicate/merge with
the backend asynchronously.

~~~
cjo
The query language is embedded in legal Clojure data structures, so it would
be tricky to port to JS. That's a drawback of embedded DSL's I suppose.

~~~
coolsunglasses
Contingent on the design but not necessary. I could make something similar in
PureScript.

I wouldn't use Datalog though, I got turned off on it after using Datomic at
work.

------
dj-wonk
How about another rename? DatomicScript was clearly a bad idea and possibly
infringing. "DataScript" is just misleading. Using "_____Script" creates the
appearance that is a scripting language. Perhaps "_____DB" or "_____JS" would
be better.

~~~
dj-wonk
How about "NotDatJS" (short for the "Not Datomic" JS Database)?

