Fork me on GitHub
#hoplon
<
2019-05-23
>
dave12:05:51

thought-provoking stuff, @alandipert ! i can totally see how clojurescript could be thought of as almost the logical conclusion of react. like, if someone took the ideas behind react and made them into a programming language, it would probably look a lot like clojurescript this might be a good argument to sell react programmers on clojurescript ๐Ÿ™‚

flyboarder14:05:00

What I never understand is using react FROM clojurescript, Iโ€™m just like.... why?

alandipert15:05:21

it's a much better name than loop-tpl ๐Ÿ˜‚

alandipert15:05:25

when I was telling people about hoplon originally I don't think I did a good job either, relative to how people were learning about react

alandipert15:05:02

partially because the important differences were not totally obvious even to me

jumblerg17:05:21

@alandipert well put! much of the intrigue in this field seems to arise out of seeing a familiar problem from a new perspective, so i always enjoy a reading a good ah-ha!

jumblerg17:05:59

and marketing ideas in general. i agree that clojure's value equality semantics facilitate a more systematic alternative to throwing the results of gratuitous, unnecessary computation at a dom-wrapper, before the penalty becomes unbearable to users. but i wonder if this too is a band-aid, albeit a more general/elegant one , that patches the symptom a more fundamental problem rooted in control flow.

alandipert17:05:23

iโ€™m not sure if itโ€™s a bandaid, i think of it as maybe a heuristic

alandipert17:05:46

because the clj equality is always going to be slow relative to comparing pointers, even with the immutable things

alandipert17:05:19

but programs just come out so much nicer

jumblerg17:05:29

i agree. but what if the comparisons/equality checks can be avoided altogether? consider the typical cqrs/mvc-ish/unidirectional data flow architecture. functions on the command side, where writes to the database typically occur, can be invoked easily without performing any redundant computation in any language without anything extra; it is only on the query side where data binding frameworks, virtual doms, and other flavors of data-diffing schemes get employed.

jumblerg17:05:37

i find it interesting to think about why this is.

jumblerg17:05:24

a couple distinctions come to mind: first, commands are inherently differential, and contain only the transaction that should be applied to the database. the diff is already done. second, the flows of control and data are aligned on a linear path all the way down to the db. i think this is the more significant distinction, because if the control flow and data flow are in the same direction, then the function being called with a differential transaction can transform and propagate its value. the diff is already known to it.

jumblerg17:05:43

or preserved all the way through.

alandipert17:05:14

i think in thta case maybe the b-tree in the db is the vdom

jumblerg17:05:15

more generally, when writing to an object, the control and data flows are aligned. but whenever reading from an object, to include a restful http get in the large, the control and data flows are in opposing directions. this is where, on the query side, the "you call me so i can call you and you can give me all your data to include all the data i already got last time i called which i will then diff" madness.

jumblerg17:05:56

yeah. so my conjecture is that the dom and the db should be treated the same way - that maybe reads/gets should be avoided alltogether, and that if we're always writing to the next object, whether it be the database or the dom, there's not much to diff in the first place.

alandipert17:05:37

do you mean like using the dom as the data model?

alandipert17:05:45

ie not accumulating state in any js structures

jumblerg17:05:32

no, just that we can think of the dom/application from the perspective of the db the same way that we can think of the db from the perspective of the application.

jumblerg17:05:30

everything can be a differential write.

jumblerg17:05:27

when we read from a service, we've lost the control flow and by extension last diff(s) that was written. so we grab the entire thing all over again and use a vdom, or a more systematic equality checking, to sort it out. but it was already known what the diff was when the transaction was written. so why are we diffing again at all?

jumblerg18:05:40

the click of a submit button applies a function to the arguments in a form's fields that calls a continuation/callback that eventually writes to the db. maybe the function writing to the db should similarly call its continuation, and keep writing the same transaction that was persisted to the db to all the subscribed document models on the other side of the cqrs loop.

jumblerg18:05:11

admittedly, things are a bit more involved on the query side due to the 1:n relationship between services and client applications, and client applications to views. rather than a clean, linear path down the dependency tree to the db/root, this requires pushing up multiple branches. but this seems to me like it is more ideal that doing redundant comparison checks on data where the difference was already known.

jumblerg18:05:10

so long as the control flow and data flow are aligned, differences can be propagated all the way through the entire graph of the system, and the dom(s) can be written to incrementally the same way writes are done to a database.

jumblerg18:05:57

alternatively, i suppose someone could go the other way and make a "virtual db", so the actual db doesn't get overwhelmed, for an application that requires its users to reenter all their data every time they use the thing. ๐Ÿ˜„