Re:Biff tutorial: build a chat app with Clojure
by joeevans1000 on Wednesday November 23, 2022 @09:50PM
(#33727332)
It's bitemporal and a graph database and so on. It seems like it can cover most of the use cases of a number of other dbs. This goes into that: https://docs.xtdb.com/concepts/what-is-xtdb/
Re:Biff tutorial: build a chat app with Clojure
by jacobobryant on Thursday November 24, 2022 @05:02PM
(#33736722)
The main ways that XTDB has been useful to me personally are:
- Immutability, which makes it fit well with the functional programming style used in Clojure. You can create a database connection object that represents a snapshot of the database at a specific point in time (usually the current time), and queries made via that object will ignore any transactions that occurred later. So you can effectively pass the entire DB around as an argument and your functions stay pure. (That also makes it easy to inspect historical snapshots, similar to looking through old git commits--I don't do it often, but it's very nice to have when you need it.)[1]
- Datalog instead of SQL. I find Datalog queries to often be more compact than the equivalent SQL, especially thanks to the implicit joins--you can query for things from multiple "tables" without having to type up a bunch of JOIN expressions. And there are various other handy doodads like pull expressions[2].
- Clojure ergonomics. You can store Clojure maps as XTDB documents as-is without needing to write code to translate them to records.
[1] XTDB's bitemporality also has some benefits over e.g. Datomic (https://www.datomic.com/, another immutable, Clojurey database), though I haven't needed to use it yet--Datomic's "monotemporality" would be sufficient for my current needs.
Re:Biff tutorial: build a chat app with Clojure
by codemonkey-zeta on Wednesday November 23, 2022 @10:18PM
(#33727455)
Excellent project, I love the xtdb/htmx stack, and wanted to experiment with it myself. Maybe I'll give biff a try first!
I was going to ask why the tutorial mentions using rum to render components, but then also mentioned using htmx, since the latter seems like it should be sufficient. But a quick perusal of the code suggests rum isn't used after all. Why does the tutorial still mention that?
Re:Biff tutorial: build a chat app with Clojure
by jacobobryant on Thursday November 24, 2022 @04:25PM
(#33736398)
Rum is used throughout, though mostly via middleware[1], so you (almost) never see any calls to `rum.core/render-static-markup`. But all of the hiccup-style data structures (`[:div "foo"]`, etc) do get rendered by Rum.
htmx doesn't render anything on the backend; rather it gives the frontend more ways to interact with the backend. e.g. say you make an inline form--htmx gives you the ability to display/submit that form without refreshing the entire page, but all the html that's sent to the frontend is still getting rendered first by Rum.
Interesting project though
- Immutability, which makes it fit well with the functional programming style used in Clojure. You can create a database connection object that represents a snapshot of the database at a specific point in time (usually the current time), and queries made via that object will ignore any transactions that occurred later. So you can effectively pass the entire DB around as an argument and your functions stay pure. (That also makes it easy to inspect historical snapshots, similar to looking through old git commits--I don't do it often, but it's very nice to have when you need it.)[1]
- Datalog instead of SQL. I find Datalog queries to often be more compact than the equivalent SQL, especially thanks to the implicit joins--you can query for things from multiple "tables" without having to type up a bunch of JOIN expressions. And there are various other handy doodads like pull expressions[2].
- Clojure ergonomics. You can store Clojure maps as XTDB documents as-is without needing to write code to translate them to records.
[1] XTDB's bitemporality also has some benefits over e.g. Datomic (https://www.datomic.com/, another immutable, Clojurey database), though I haven't needed to use it yet--Datomic's "monotemporality" would be sufficient for my current needs.
[2] https://docs.xtdb.com/language-reference/datalog-queries/#pu...
I was going to ask why the tutorial mentions using rum to render components, but then also mentioned using htmx, since the latter seems like it should be sufficient. But a quick perusal of the code suggests rum isn't used after all. Why does the tutorial still mention that?
htmx doesn't render anything on the backend; rather it gives the frontend more ways to interact with the backend. e.g. say you make an inline form--htmx gives you the ability to display/submit that form without refreshing the entire page, but all the html that's sent to the frontend is still getting rendered first by Rum.
[1] See https://github.com/jacobobryant/biff/blob/6353c406adef034448... and https://github.com/jacobobryant/biff/blob/6353c406adef034448...