rum

Simple, decomplected, isomorphic HTML UI library for Clojure and ClojureScript | 0.12.8 https://github.com/tonsky/rum/blob/gh-pages/CHANGELOG.md#0128
cjsauer 2020-07-14T19:55:50.171100Z

Why is rum/static not the default?

2020-07-15T09:22:06.171900Z

guess it's just the way it is historically

cjsauer 2020-07-15T14:22:05.179700Z

Yea makes sense. I’m finding that I’m adding static to basically every component to benefit from the efficient immutable prop comparison. I was starting to wonder if there was some downside. It should be pretty simple to copy the defc macro and customize it to always include the static mixin. Build my own default basically.

cjsauer 2020-07-15T14:23:29.181300Z

Although if I forego the defc macro altogether, and always use plain defn components, does that act like defc < static?

cjsauer 2020-07-15T14:24:14.182Z

With React hooks I’ve found that mixins have become less useful

2020-07-15T14:37:38.182200Z

to be fair equality check on immutable data comes with a cost

2020-07-15T14:39:37.182400Z

Fast-path identity check applies good, in most cases, for patterns like re-frame, where there's a central data store / structure, updating the same value means taking advantage of structural sharing, thus identity check short-circuits equality check sooner

2020-07-15T14:41:20.182600Z

But with data created locally in components and passed into child component this is not the case. Creating a hash map from scratch in a component does produce the same value, but equality check has to walk the whole structure, perform deep equality check (value equality), to make sure that those two hash maps are the same.

2020-07-15T14:42:03.182800Z

Now sometimes it may be cheaper to re-run Rum/React component than comparing its arguments and then running it, in case when args didn't change

2020-07-15T14:44:14.183400Z

In case of Rum this might make sense, because most of the Hiccup is pre-compiled, thus running a component doesn't pay perf hit for Hiccup interpretation as much as in Reagent for example.

2020-07-15T14:44:47.183600Z

btw, I think I should put this into Rum's docs.

👍 1
cjsauer 2020-07-15T15:40:40.183800Z

> to be fair equality check on immutable data comes with a cost My app does use a top-level state atom (although not re-frame), so the static mixin would still short-circuit to an identical? check. Component-local data is indeed different, but I find that those cases are rare and usually the data created is quite small. I hadn’t quite made the mental leap to comparing the speed of arg comparison to the speed of React’s re-render algo (made more interesting by your comment that rum doesn’t suffer hiccup penalties).

2020-07-15T15:42:19.184100Z

put a document in the repo https://github.com/tonsky/rum/blob/gh-pages/doc/optimizations.md

cjsauer 2020-07-15T17:38:31.184400Z

🙏 thanks @roman01la, very helpful and clear