Fork me on GitHub
#rum
<
2020-07-14
>
cjsauer19:07:50

Why is rum/static not the default?

roman01la09:07:06

guess it's just the way it is historically

cjsauer14:07:05

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.

cjsauer14:07:29

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

cjsauer14:07:14

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

roman01la14:07:38

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

roman01la14:07:37

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

roman01la14:07:20

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.

roman01la14:07:03

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

roman01la14:07:14

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.

roman01la14:07:47

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

👍 3
cjsauer15:07:40

> 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).

cjsauer17:07:31

🙏 thanks @U0FR82FU1, very helpful and clear