News for hackers. Stuff that matters.
Re:Why and How We Retired Elm at Culture Amp by rcme on Saturday April 08, 2023 @03:15PM (#35496618)
On the other hand, React is super slow, a problem which is further exacerbated by the fact that rendering and invalidation happens somewhat indirectly, meaning it’s really easy to accidentally make something super slow.

For your run of the mill website, this probably doesn’t matter. But for interactive web content, it can absolutely be a competitive advantage to use something faster and more responsive.

Re:Why and How We Retired Elm at Culture Amp by MajimasEyepatch on Saturday April 08, 2023 @04:04PM (#35497058)
I don’t think I’ve ever seen a web app where the performance of React was such a bottleneck that it would in any way justify migrating to another tech stack. You’d have to get so far into a project for that to become an issue that the cost of switching would be huge.
Re:Why and How We Retired Elm at Culture Amp by rcme on Saturday April 08, 2023 @04:30PM (#35497310)
Have you tried the new Reddit website?
Re:Why and How We Retired Elm at Culture Amp by 88913527 on Saturday April 08, 2023 @04:34PM (#35497343)
Actually analyze the DOM, flame charts, and third-party scripts if you want to critical of heavy front ends. Blaming React is myopic. They could've used Angular or Vue and it'd just as bad because the bloat isn't where you think it is.
Re:Why and How We Retired Elm at Culture Amp by yladiz on Saturday April 08, 2023 @04:46PM (#35497434)
Do you think it’s solely because of React?
Re:Why and How We Retired Elm at Culture Amp by rcme on Saturday April 08, 2023 @05:03PM (#35497601)
If you read my original post, one of my points was that React’s rendering and data model makes it too easy to render unnecessarily, which causes perf issues.
Re:Why and How We Retired Elm at Culture Amp by yladiz on Saturday April 08, 2023 @05:37PM (#35497884)
I would say “can cause” performance issues, but I wouldn’t say React is one of the primary reasons for poor performance. You can get very far with little optimization in React, so I am skeptical that the way React works fundamentally causes issues.
Re:Why and How We Retired Elm at Culture Amp by ricardobeat on Saturday April 08, 2023 @07:25PM (#35498622)
YMMV. I've been involved in multiple large-scale React projects at this point, and they all eventually suffered from performance issues, related to React's rendering model. And fixing it is always painful.

On Reddit, as another comment mentioned, yes, React seems to have been a major factor in how slow it became due to the patterns it encourages, and the massive JS sources.

You can only 'get very far' because browsers are crazy fast and you don't notice what's going on underneath. Until it catches up to you.

Re:Why and How We Retired Elm at Culture Amp by bayesian_horse on Sunday April 09, 2023 @05:18AM (#35501079)
Then you would need to show me proof that other frameworks handle similar complexity with less performance degradation or optimize with less pain.

My general advice in such cases would be to strive for more isolation. Do use Redux. Don't be afraid to use multiple stores on one page if that allows you to isolate rerenders.

Re:Why and How We Retired Elm at Culture Amp by rcme on Sunday April 09, 2023 @08:12AM (#35501988)
I have experiencing on both complex React projects and complex vanilla JS projects (think the scale and complexity of Figma). Vanilla JS lends itself to being more performant. Anything that happens in Vanilla JS happens for an explicit, developer-defined reason. Things don’t rerender unless explicitly asked to. This can be both good and bad. While Vanilla JS tends to stay way more performant as complexity scales, “stale state” bugs are much more common. It’s a tradeoff.
Re:Why and How We Retired Elm at Culture Amp by bayesian_horse on Sunday April 09, 2023 @09:24AM (#35502484)
I had the exact opposite experience. I mean, first of all, people using "VanillaJS" get the DOM manipulation wrong a lot more often. And then I do hope you don't conflate code size with complexity, because of course, direct DOM manipulation takes one heck of a lot more code (unless you create and maintain your own bespoke framework creating your own headaches). You are basically contradicting the whole reason Facebook, a pretty big and quite smart company, started React in the first place.

You also don't seem to understand what "rerendering" means. And that is often a problem in terms of performance. A React component only executes to determine if things have to be changed in the DOM. Not understanding this is creates a lot of pain.

Re:Why and How We Retired Elm at Culture Amp by satvikpendem on Sunday April 09, 2023 @10:47AM (#35503200)
As well, people don't understand that React is an idempotent rendering framework. It's easy to reason about because of the same reason why functional languages are easy to reason about, it does not mutate but instead creates new copies.
Re:Why and How We Retired Elm at Culture Amp by rcme on Sunday April 09, 2023 @10:52AM (#35503268)
This is a discussion about perf. Creating new copies is part of what makes it slow.
Re:Why and How We Retired Elm at Culture Amp by satvikpendem on Sunday April 09, 2023 @01:57PM (#35504956)
The point is the same as functional languages, making immutable copies is what makes it easy to reason about, where reactive changes don't. There are ways to make VDOMs fast too, faster than reactive frameworks.
Re:Why and How We Retired Elm at Culture Amp by bayesian_horse on Monday April 10, 2023 @02:57AM (#35509827)
Understanding that part means you know where to use memoization to speed up what needs to speeding up. Which isn't that much, usually.
Re:Why and How We Retired Elm at Culture Amp by rcme on Sunday April 09, 2023 @10:48AM (#35503216)
As I said, this project was about as complex as Figma: a feature rich collaborative editor. This designation has nothing to do with code size.

Go hook up the React dev tools to Reddit and look how much each component renders. You see that components are constantly rendering even though nothing apparent has changed. I get that ideally React would only re-render when something has changed, but clearly it’s easy to create situations where react thinks something has changed even if it hasn’t.

Another good example is the Facebook website itself. It’s just so slow. I get saying Reddit developers suck, but I don’t think you can say the same about FB developers given that FB made React. React is popular because it’s a good developer experience. It’s not the best choice if you want optimal performance.

Re:Why and How We Retired Elm at Culture Amp by bayesian_horse on Monday April 10, 2023 @02:56AM (#35509822)
I have a hard time assuming you are not confusing network delays with rendering speed...
Re:Why and How We Retired Elm at Culture Amp by rcme on Monday April 10, 2023 @07:59AM (#35511319)
Yes, that seems to be a common theme: you have a hard time believing anything that doesn’t fit with your preconceived notions.

Again, connect React dev tools to Reddit yourself. Given that you’ve been given a concrete example of a slow website, I have a hard time believing you can even differentiate a performant website from a slow one.

Re:Why and How We Retired Elm at Culture Amp by internetter on Sunday April 09, 2023 @04:32PM (#35506214)
Well, we all seem to be in agreement that excessive rerenders are the leading cause of poor performance, and reactive frameworks are the solution.

The only performance bottleneck (I can think of) at scale with these frameworks is bundle size. Components are marginally larger in solid, and much larger in svelte. Fortunately, components don't all need to be loaded at once, and react has a lot of weight from the getgo. I cannot imagine a situation where the increased component size of svelte or solid would actually result in a larger app, even before weighing the performance gains from reactivity.

One other thing to note: An old team tried scaling with svelte once, and we ended up with react. This isn't related to performance, just DX. Solid is going much better, the primitives approach makes scale easy to reason with.

Re:Why and How We Retired Elm at Culture Amp by ricardobeat on Monday April 10, 2023 @04:47PM (#35517201)
> Components are marginally larger in solid, and much larger in svelte.

That doesn't sound right. Components are usually much smaller in Svelte, both source and compiled output; if you have hydration enabled, the JS only contains code needed to hot-patch the DOM, and not rebuild the entire template including all the static parts as react/solid does.

When Svelte still called itself the "disappearing framework", the trade-off was larger overhead in the overall project due to repeated code, but in later versions Svelte ships a runtime with a shared library.

> we all seem to be in agreement that excessive rerenders are the leading cause of poor performance, and reactive frameworks are the solution

When we were hand-wiring components in Backbone, knockout.js etc, rendering was extremely optimized, since you decided on each and every action that would trigger it, and you did not want to overwrite potentially stateful DOM elements unless really needed.

It was way easier to get stuck into infinite loops, get desync issues, or simply completely loose track of chains of events, but unnecessary re-renders were not a major issue because they were much more expensive. React offered a solution to reason about the component tree more clearly, and along with flux and the unidirectional data flow, eliminate issues around stale data and mutations. It was not meant to be faster.

Re:Why and How We Retired Elm at Culture Amp by internetter on Monday April 10, 2023 @08:44PM (#35519254)
> The trade-off was larger overhead in the overall project due to repeated code, but in later versions Svelte ships a runtime with a shared library.

This is news to me! I switched off svelte in 2021, and onboarded with solid in early 2022. This excites me to check out svelte again

> It was not meant to be faster.

Well, this whole discussion is performance so...

Re:Why and How We Retired Elm at Culture Amp by pxtail on Sunday April 09, 2023 @09:19AM (#35502456)
> Do you think it’s solely because of React?

Yes, if the company like reddit, facebook - which has prestige, finances and ability to hire rockstar-10x-A-players React/JS developers is unable to get their shit right and their react fronts works like garbage then it simply means that there is no hope, for some reason it's simply not possible to make performant app with React.

Re:Why and How We Retired Elm at Culture Amp by satvikpendem on Sunday April 09, 2023 @10:45AM (#35503186)
Or it's purposefully bad to incentivize people to use their app which has more tracking. I've had React frontends that were performant and plain JS frontends that were laggy. It's not really a factor of the framework.
Re:Why and How We Retired Elm at Culture Amp by belmont_sup on Sunday April 09, 2023 @10:49AM (#35503232)
The other way around is to point at great React based apps. Linear’s project management tool is so quick and fast. It takes a whole mindset embedded into a team to make a product fast from the get-go.
Re:Why and How We Retired Elm at Culture Amp by anonymoushn on Saturday April 08, 2023 @07:36PM (#35498676)
As soon as a web site adds the feature where content is removed when out of the viewport and the browser's find feature no longer works, that web site has reached this point and is deploying workarounds that harm the user experience. Facebook and Twitter have had this feature for most of a decade.
Re:Why and How We Retired Elm at Culture Amp by internetter on Sunday April 09, 2023 @04:16PM (#35506064)
Oh lord I thought it was just me. Browsers are really good at displaying long lists, just maybe not loading them all at once ;)
Re:Why and How We Retired Elm at Culture Amp by Yoric on Saturday April 08, 2023 @04:41PM (#35497400)
I haven't used React in a long time, but when I did, one of the main reasons for using it was that it was much faster than most handwritten non-trivial DOM code because it managed to avoid the `write CSS -> read layout` anti-pattern.

What makes React so slow these days?

Re:Why and How We Retired Elm at Culture Amp by justrealist on Saturday April 08, 2023 @04:48PM (#35497460)
Just people who don't understand how to write performant React, honestly.

There are ways of writing React that result in vast numbers of re-renders... it's not a best practice, but it's relatively easy to make happen, especially if you ignore the official recommendations and pull Stackoverflow answers from 2015.

Re:Why and How We Retired Elm at Culture Amp by internetter on Saturday April 08, 2023 @04:49PM (#35497479)
Sure, to some degree, but you have to wonder why it's so easy for developers to footgun themselves. It's the fault of the language, imo, not bad developers.
Re:Why and How We Retired Elm at Culture Amp by Marazan on Saturday April 08, 2023 @05:00PM (#35497575)
React is easy to use without understanding the component lifecycle. The penalty is poor performamce rather than a non-functional app.

You saw the same thing in the before times with Adobe Flex. So much code from people who had no understanding of the lifecycle - apps that worked but were appallingly slow and buggy.

Re:Why and How We Retired Elm at Culture Amp by justrealist on Saturday April 08, 2023 @04:52PM (#35497507)
I've never seen a language or framework that is both easy to be quickly productive in, and free of footguns.

React is easy to be quickly productive in... thus, it has footguns.

Re:Why and How We Retired Elm at Culture Amp by Yoric on Saturday April 08, 2023 @04:51PM (#35497493)
What would prevent that?
Re:Why and How We Retired Elm at Culture Amp by internetter on Saturday April 08, 2023 @05:26PM (#35497796)
I believe the term is "fine grained reactivity". Basically, components do not rerender when data updates, only the specific part of the DOM dependent on that data.

This alleviates all the footguns that come with rerenders (including the infamous infinite loop) and often results in cleaner code.

I'm partial to solid[0] (there are hundreds of comparison articles that illustrate the DX improvement, but a couple are [1] and [2]). I believe svelte is similar and vue is experimenting with this as well

[0]: https://www.solidjs.com/

[1]: https://news.ycombinator.com/item?id=30508524

[2]: https://news.ycombinator.com/item?id=35061672

Re:Why and How We Retired Elm at Culture Amp by jakelazaroff on Saturday April 08, 2023 @10:34PM (#35499595)
That isn’t always true. Reactivity can make updates faster, but adds more overhead to creating DOM nodes because you need to set up the subscriptions that are used to eventually update them.

To steal a phrase originally about VDOM: “reactivity is pure overhead”. Nothing comes for free!

Re:Why and How We Retired Elm at Culture Amp by internetter on Sunday April 09, 2023 @04:48PM (#35506338)
Maybe in theory, but solid still outperforms react in creations by a considerable amount, and I think most applications will find they are doing a lot more rerenders than insertions anyway
Re:Why and How We Retired Elm at Culture Amp by internetter on Saturday April 08, 2023 @04:48PM (#35497465)
It's a combination of many things, but imo one of the worst is all the footguns regarding state and the rerenders they cause

https://emnudge.dev/blog/react-hostage

It's so easy, that we monkey patch react to debug it https://github.com/welldone-software/why-did-you-render

Plus the vdom... Isn't great, the bundle size puts react at an inherit disadvantage, and the community has a knack for over reliance on bloated packages

Re:Why and How We Retired Elm at Culture Amp by ricardobeat on Saturday April 08, 2023 @07:39PM (#35498703)
> it was much faster than most handwritten non-trivial DOM code

That would be incredibly rare. Despite the myth propagated, React is unlikely to be faster unless you were doing a ton of interleaved layout-triggering reads and writes.

Re:Why and How We Retired Elm at Culture Amp by internetter on Saturday April 08, 2023 @04:42PM (#35497406)
Everyone seems to be saying that the performance doesn't matter, but as a general consumer and an employee with ADHD, I absolutely notice every millisecond, and have been known to abandon products over it (or make my own frontend, depending on the viability of alternatives).

Like, I can feel the delay typing in a web browser compared to native, and it drives me crazy. If the output doesn't seem like a direct response to my input, I lose focus. Simple as that, and react seems to be a big part of that problem.

We have ways to go in our apps, but solid has done wonders already. Currently I'm researching state caching and optimistic updates, both of which should also improve it.

Fast enough is a myth. Instant apps are magic.

Re:Why and How We Retired Elm at Culture Amp by TexanFeller on Sunday April 09, 2023 @01:02AM (#35500194)
Also an ADHD person. He's not exaggerating. I do notice every single 100ms delay in the computer doing what I commanded.
Re:Why and How We Retired Elm at Culture Amp by bayesian_horse on Sunday April 09, 2023 @05:14AM (#35501066)
Bullshit. "React is super slow" is just not true in any shape or form.

Especially not React itself. And even if React itself or the way it does things is "too slow" (which is the only metric that counts) then there are escape hatches or ways to deal with that.

Re:Why and How We Retired Elm at Culture Amp by sunshinerag on Sunday April 09, 2023 @03:35PM (#35505699)
what would one do with React itself.?