What does HackerNews think of datascript?
Immutable database and Datalog query engine for Clojure, ClojureScript and JS
Last time I used `datalog` was years ago, I was developing an internal interactive tool that was used to compare different approaches to solving a certain problem at my employer. I used `datascript`[1] by way of clojurescript to store all experiment data and then interrogated the `datascript` DB via `datalog`. This is something I always remember fondly.
[0] https://www.learndatalogtoday.org/ [1] https://github.com/tonsky/datascript
Two "copy cats" (not meant to be derogatory) of Roam that are open source are: https://github.com/logseq/logseq https://github.com/athensresearch/athens
The underlying in memory datalog style database that can run in the browser that enables these apps https://github.com/tonsky/datascript
Datascript seems to be another Datalog engine (in memory only)
Either way, super powerful.
Refs: https://en.m.wikipedia.org/wiki/Datalog https://github.com/tonsky/datascript https://www.datomic.com/
- Google's Firebase (meh, though maybe Supabase is mature enough by now to replace this suggestion?)
- Tinybase: https://tinybase.org
- sql.js (SQLite compiled to js): https://sql.js.org/
But there's no single stack available (yet). I'm suprised Nikita didn't mention datascript here (https://github.com/tonsky/datascript) given the neat compatibility it offers with other datalog databases, but maybe he feels it's too niche/immature?
- There are several such talks at https://www.hytradboi.com/ (happening this Friday)
- Roam Research and its clones Athens, Logseq, use Datascript / ClojureScript https://github.com/tonsky/datascript
- differential-datalog isn’t an end-to-end system, but is highly optimized for quick reactivity https://github.com/vmware/differential-datalog
- Datalog UI is a Typescript port of some of differential-datalog’s ideas https://datalogui.dev/
I think an under appreciated aspect of Datalog is as a pure specification language for relationships. Schema languages like GraphQL specify a relation between types exists, but not how it is computed. Prisma and other ORM DSLs like ActiveRecord do a better job specifying how to compute a relation from SQL tables, but support only a few strict computation types that can be modeled using SQL JOIN on columns.
Datalog lets you purely specify arbitrarily complex logical relationships between data types. Even if you were to only use Datalog as a rules engine at test time, it could still be quite powerful for validating logic implemented in different languages on the same data model, to say keep your Typescript, Kotlin and Swift logic in sync.
1: https://github.com/tonsky/datascript 2: https://www.datomic.com/ 3: https://github.com/metasoarous/datsync
So it seems as though the decision to use Clojure was not made for technical reasons, but it's not exactly arbitrary.
I would suggest soufflé (https://souffle-lang.github.io/) if you're batching data through for static analysis.
DDLog (https://github.com/vmware/differential-datalog) if you want a rule-engine within your interactive application, to encode decision procedures and business rules.
If you actually want this to drive the views of a (web-)application, I don't think we're really there yet. We have to wait at least for the next generation of developments. But you can give it a try with datascript https://github.com/tonsky/datascript
- Datascript: https://github.com/tonsky/datascript
Interop with hosts is a core feature of the language so it feels natural to reach for it when you need it and it's easy to write code that handles multiple runtimes but 95% of the time maybe more you don't need explicit runtime features
[0] https://www.datomic.com/ [1] https://github.com/tonsky/datascript [2] https://opencrux.com/
Datascript allows you to write datalog queries in ClojureScript(and JavaScript) that operate on a b+ tree maintained by the library. It includes first class relationships and unique keys.
Maybe I'm just a dinosaur, but I can't keep up with all the changes to JavaScript, whereas ClojureScript compiles to ECMAScript 3 and the syntax hasn't changed since its release 12 years ago.
This is an older presentation but its all about doing Datalog from the client to the DB.
See: https://www.youtube.com/watch?v=aI0zVzzoK_E
But if you go threw the Clojure world, there is Datalog all over the place, both client and server. Check out Datascript:
https://github.com/tonsky/datascript
This full-stack framework: http://book.fulcrologic.com/
[1]: https://github.com/tonsky/datascript
That is probably my main issue with SQL: That the names of some of the keywords are very table-ish and not very semantic; like LEFT OUTER JOIN. I mean, if we have some facts, like how old people are, and what they like to eat, then what does it even mean that any of those facts is to the left or on the inside of another? I can't fit that into my brain.
But let's take an example. We have these sets of facts (which, if they were in SQL, would be in two different tables):
age(alice, 20).
age(beatrice, 30).
age(charlie, 90).
likes(alice, carrots).
likes(alice, chips).
likes(charlie, crumpets).
Then an INNER JOIN would probably be like: age(Name,Age), likes(Name, Something).
This can be read as "What is the age of anyone, who like something?" (or more absurdly, "What does anyone, who has an age, like?", depending on what variable we focus on.)I'm probably getting this wrong, but if we wanted LEFT OUTER JOIN it would be more like:
age(Name,Age); likes(Name, Something).
Which is more like "What's all people's ages, and what does anyone like?"In Prolog, the comma means 'and', and the semicolon means 'or', so in the second query anyone, who has an age but doesn't like anything, will still be included. In this query, that would be Beatrice. That's a bit like a LEFT OUTER JOIN, isn't it?
> I find the idea of a simple Prolog, like a Datalog, very intriguing as a potential simple query engine for apps in mainstream languages–not having to worry about the maps, filters, reduces, flatmaps, and all the other operations we have to do to coax data into the right shapes in line-of-business apps.
Seen DataScript?[0] I think MiniKanren has also been implemented in most languages. I like how Prolog "forces" a declarative style though.
https://github.com/tonsky/datascript And this (deprecated) project, that translate datalog to SQL(lite) https://github.com/mozilla/mentat
"Datomic is a distributed database and implementation of Datalog.". Datomic seems to be quite succesful [2].
Related to datomic, I'm trying to learn Datascript these days ("An immutable in-memory database and Datalog query engine in Clojure and ClojureScript.") [3].
1: https://en.wikipedia.org/wiki/Datalog
Hickey's Spec-ulation keynote is probably his most controversial talk, but it finally swayed me toward dynamic typing for growing large systems: https://www.youtube.com/watch?v=oyLBGkS5ICk
The Clojure build ecosystem is tough. Ten years ago, I could not have wrangled Clojure with my skillset - it's a stallion. We early adopters are masochists, but we endure the pain for early advantages, like a stable JavaScript target, immutable filesets and hot-reloading way before anyone else had it.
Is it worth it? Only if it pays off. I think ClojureScript and Datomic are starting to pay off, but it's not obvious for who - certainly not very ever organisation.
React Native? I tore my hair out having to `rm -rf ./node-modules` every 2 hours to deal with breaking dependency issues.
Whenever I try to use something else (like Swift), I crawl back to Clojure for the small, consistent language. I don't think Clojure is the end-game, but a Lisp with truly immutable namespaces and data structures is probably in the future.
[^1]: In 2014 I wrote down "Why Clojure?" - http://petrustheron.com/posts/why-clojure.html [^2]: https://github.com/tonsky/datascript [^3]: https://github.com/mozilla/mentat
https://github.com/tonsky/datascript Datascript is also neat, it's an in-browser DB with datalog query syntax. There's some neat stuff possible with om.next + datascript: https://github.com/omcljs/om/wiki/DataScript-Integration-Tut...
I found it very useful for dealing with relational data in browser apps.
Thinking in "facts" / binary relations is itself a refreshing approach.