Fork me on GitHub
#hoplon
<
2021-01-16
>
GusWill16:01:09

hey guys, so, I've been learning reagent and hoplon and was wondering... whats the difference between between reagents ratom and javelin's cell?

GusWill16:01:26

they both seem to do the same thing right?

GusWill17:01:47

what I'm trying to ask is, reagent and hoplon look very similar in terms of programming paradigm... You set some state in a ratom/cell, write a view function that emits html, this view automatically reacts when said state changes... so, why choose hoplon over reagent?

phronmophobic18:01:05

How does reagent handle a cell that depends on another cell. In hoplon, I believe you can have cells that depend on other cells that depend on other cells and they will be kept in sync.

euccastro06:01:03

reagent has reactions. it seems to be meant as more of an internal thing, but it is in the public API and I have used it: https://github.com/euccastro/seven-guis/blob/4676c97f31eae46bf8a1b00239e18d174fafb028/src/seven_guis/cells/components.cljs#L120. I found it unnecessarily hard to test. having worked with that is what got me interested in hoplon again, after having taken a cursory look a long time ago but never having given it a fair try

GusWill15:01:20

@U65FN6WL9 How would you compare ratoms with javelin cells? On the surface they seem to be different apis that serve the same purpose, right?

jjttjj18:01:32

yes iirc ratoms require being more explicit with deriving new ratoms from dependencies. Javelin is more magic. Reagent tends to require explicit deref'ing to react to something while hoplon is more implicit (a cell passed as an element attribute will imply that that attribute will change when the cell changes, while reagnet, I believe, will have you wrap element in a function and call deref on the ratom.

jjttjj18:01:49

Hoplon is tied to cells but i believe it could be modified pretty easily to use anything that's watchable/derefable so you could hack it to use ratoms if you really wanted to, I believe all that's stopping this from hoplon core is a couple calls to cell? (this is probably a bad idea though)

kennytilton18:01:11

There are a number of key differences. Javelin does not "see" dependencies reached via function calls. Also, in the form (if A B C) where A, B, and C are Cells, in Javelin dependencies are established on all three, tho any one result can really only depend on two, A and one other. Last I looked, I should add.

GusWill15:01:49

Thanks for your thoughts but I'm new to Hoplon so I'm not sure I follow. What do you mean by Javelin does not see? And what is the advantage of this model?

kennytilton15:01:05

The formula for A may call a function F. F reads Cell B. No dependency is established between A and B. This comes up when we buy into reactive programming seriously, and reactive programming is a slippery slope: once we have cell A depending on B, B is likely to depend on sth else.

GusWill15:01:52

I think I understand it now, thanks. But isn't this also possible with reagent's reactions?

GusWill15:01:03

What I'm trying to understand is: what does Hoplon give me that isn't also viable with Reaget?

phronmophobic18:01:17

I think with reagent, reactions to updates are really just about rerendering (usually). I think hoplon is a little more general, and reactions can trigger other types of events.

jjttjj18:01:07

True, yeah I believe ratom modications are batched to each animation frame by default

euccastro06:01:03

reagent has reactions. it seems to be meant as more of an internal thing, but it is in the public API and I have used it: https://github.com/euccastro/seven-guis/blob/4676c97f31eae46bf8a1b00239e18d174fafb028/src/seven_guis/cells/components.cljs#L120. I found it unnecessarily hard to test. having worked with that is what got me interested in hoplon again, after having taken a cursory look a long time ago but never having given it a fair try