hoplon

The :hoplon: ClojureScript Web Framework - http://hoplon.io/
2019-05-23T04:37:01.052300Z

shared a thought on reddit thats been rumbling inside for a while, https://www.reddit.com/r/Clojure/comments/bqh0z4/virtual_dom_is_pure_overhead/eohn35i?utm_source=share&utm_medium=web2x

πŸ‘ 2
dave 2019-05-23T12:58:51.054400Z

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 πŸ™‚

flyboarder 2019-05-23T14:12:00.055500Z

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

2019-05-23T15:04:21.057300Z

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

2019-05-23T15:05:25.058500Z

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

2019-05-23T15:06:02.059400Z

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

2019-05-23T17:38:21.093Z

@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!

2019-05-23T17:41:59.095900Z

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.

2019-05-23T17:42:23.096400Z

i’m not sure if it’s a bandaid, i think of it as maybe a heuristic

2019-05-23T17:42:46.097Z

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

2019-05-23T17:43:19.097900Z

but programs just come out so much nicer

2019-05-23T17:44:29.098600Z

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.

2019-05-23T17:44:37.098900Z

i find it interesting to think about why this is.

2019-05-23T17:45:24.099500Z

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.

2019-05-23T17:45:43.099900Z

or preserved all the way through.

2019-05-23T17:46:14.100500Z

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

2019-05-23T17:46:15.100600Z

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.

2019-05-23T17:47:56.101800Z

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.

2019-05-23T17:49:37.103500Z

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

2019-05-23T17:49:45.103800Z

ie not accumulating state in any js structures

2019-05-23T17:51:32.104900Z

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.

2019-05-23T17:52:30.105800Z

everything can be a differential write.

2019-05-23T17:57:27.109600Z

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?

2019-05-23T18:03:40.114400Z

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.

2019-05-23T18:13:11.121400Z

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.

2019-05-23T18:17:10.123600Z

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.

2019-05-23T18:25:57.128Z

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. πŸ˜„