Live data from Hacker News

React is holding me hostage

emnudge.dev

511–520 of 553 posts

Re: React is holding me hostage

#511

Earlier quoted context omitted.

> it is worse when the user can instantiate arbitrary components (say for a knowledge graph editor or a geospatial intelligence tool) that ‘listen’ to event changes. Your application is effectively "anything can modify anything", which is the previous step to "anything modifies anything", I/E big ball of mud. React's answer to that is "keep all the state in a small component" (small ball of mud) or "keep the state in…

I'll push back on that. In those two applications I joined failing projects that really were a "big ball of mud" and got them working. I didn't just figure out a working solution to the async updating problem, I became intimately familiar with seductive non-solutions. The problem with the discussion about React is that 99% of the use cases of React don't need to be an SPA . If it's possible to SSR your application yo…

the "MVC" nomenclature came from traditional desktop apps, no? RoR just followed suit.

So, I always "hated" RoR, because it was full of hidden conventions and regular black magic. At least PHP was globally simple and primitive, even if locally ugly and complex.

I still remember Misko's early(est?) Angular announcement video, it was just part of GTAC [google test automation conference], and the whole thing was about testability.

https://www.youtube.com/watch?v=gQclnI_8Vmg

It was seen as natural separation of concerns, it was seen as - finally - breaking free of the big bulky backend (of GWT and the shackles of semi-autogenerated frontend code) the frontend runs on the browser anyway, it needs to manage its own state anyway, etc, etc.

Of course this only emphasizes your point, that a good ~95% of the sites are not like this, they shouldn't even try to manage state on the frontend.

> Once you get into the range of applications that really need an SPA they let you down.

Yep. I wholeheartedly agree.

Re: React is holding me hostage

#512

``` The quickest obstacle you’ll run into as someone new to React will be something like this function MyComponent() { const [num, setNumber] = useState(42); // infinite loop setNumber(n => n + 1); return {num} } Trying to make state updates at the top level of a component will result in an infinite loop. ``` I've taught React to dozens of people without ever seeing someone try this. A render function is an idempoten…

Most people who use React don't understand idempotency, in my experience. Without understanding that fundamental concept, and that that React will blow away the tree and recreate it (albeit efficiently), one will not understand React.

Yes, most people are idiots and most developers can't solve fizzbuzz, but that's not the problem of React.

Re: React is holding me hostage

#513
There is way too much local ad-hoc state in modern web apps. (Ad-hoc as opposed to persisted state.)

The first example of UI frameworks is always the `counter`, but it's always the least realistic scenario you encounter. Almost every app involves retrieving state over the network, sharing state in multiple places in the app, and how this state is CRUDed.

The reality is that all state is very interconnected.

Ideally you want fine-grained reactivity for every rendered UI element, that ultimately reacts to the changes in a database in the cloud.

And every piece of state should ideally be persisted. Even things like dropdown menus and their state.

The simple solution to all this is to store all state/data in a single database on the client. Every time you render something from the database, a component should have its own "view model". And this view model should react to changes in the database.

This "view model" also shouldn't be hidden inside components. There should be one place where you can view all the view models throughout your code. And see the interconnectedness. In a visual way too.

Maybe we went off-track when we started to merge the view/model/controller in the same file. We create hierachies of views, and then they need to get their data from this view hierarhcy. But instead they should be getting their data from a central database in as few transformations as possible.

The mistake people make is trying to make components isolated and decoupled from the rest of the app as a principle. It sounds nice, in that when you work on a single component, you only have to worry about what props are being passed to it. What makes apps complex though is data transformations. Ideally you want data to be as close in shape to the underlying dataset as possible. Otherwise caching/memoizing becomes very difficult, and this is usually the cause of many performance issues.

Re: React is holding me hostage

#514

The whole thing around React is odd to me. People laugh at web development, especially the frontend, for changing libraries every week but you read a thread like this and everyone is so sure that React is a bad library and we should be using some newer library instead. I work with React daily and it has issues, but I find most issues can be worked around without much trouble. It's easy to hire people, onboard people,…

> It's easy to hire people, onboard people Yes they'll know the React part. It's the Redux/Mobx/React Router/whatever snowflake libraries you chose part that will be more difficult. I really don't like incomplete solutions personally.

>Redux/Mobx/React Router

All of these libraries are standard and easy to approach; when I was freelancing, my onboarding on React projects was incredibly quick, and I pushed bug fixes and features within the first few hours of joining a project. React's productivity boost is often overlooked; most developers should easily understand a fairly well-written React component connected to a Redux store.

Re: React is holding me hostage

#515

I'm still a React guy. I've also worked with Angular and Vue and toyed with Svelte. People tend to compare these frameworks on things that don't matter - often it's performance. We used to compare React performance to AngularJs performance too, which was meaningless. VDom is nice. Reactivity in signals is nice. Limiting rerenders is nice. But I choose frameworks because of developer ergonomics. The killer feature for…

[deleted]

Re: React is holding me hostage

#516

Earlier quoted context omitted.

It's more like React is the MFC to HTML5's Win32. A not very good API with a near monopoly that people spend lots of time wallpapering over with ever more elaborate frameworks that end up being used only for distribution reasons.

It’s a pretty great API, I’d say! The alternatives also have their own warts.

That's a novel take. What justifies Win32's claim to greatness in your eyes? Do you mean by the standard of the time, or even today?

Re: React is holding me hostage

#517

Earlier quoted context omitted.

> the modern webapp experience is so miserable for the average person. I see this claim a lot and I'm curious what this is based on, can somebody drop some links to further reading?

Just go and use the “new” Reddit. Take any metric you want from there.

The new Reddit is so slow... after some bingescrolling I often give up due to the annoying loading times and close the site. I always imagine that many people react like this on super slow websites, but on the other hand it's Reddit and many people don't know which site to visit instead :P

Re: React is holding me hostage

#518
post #383

``` The quickest obstacle you’ll run into as someone new to React will be something like this function MyComponent() { const [num, setNumber] = useState(42); // infinite loop setNumber(n => n + 1); return {num} } Trying to make state updates at the top level of a component will result in an infinite loop. ``` I've taught React to dozens of people without ever seeing someone try this. A render function is an idempoten…

That’s a good point, that example does feel a bit contrived. Interestingly though it is actually “canon” to call setState within the render function (for certain rare situations). I didn’t actually know this until I read the React beta docs: https://beta.reactjs.org/learn/you-might-not-need-an-effect#...

That's a not a call to setState within the render function though, that's a declaration of an effect that sets state. Reference != call.

Re: React is holding me hostage

#519

``` The quickest obstacle you’ll run into as someone new to React will be something like this function MyComponent() { const [num, setNumber] = useState(42); // infinite loop setNumber(n => n + 1); return {num} } Trying to make state updates at the top level of a component will result in an infinite loop. ``` I've taught React to dozens of people without ever seeing someone try this. A render function is an idempoten…

Most people who use React don't understand idempotency, in my experience. Without understanding that fundamental concept, and that that React will blow away the tree and recreate it (albeit efficiently), one will not understand React.

I think most people can intuit it, they just don't have the FP lingo. I still don't understand what a newcomer would expect that piece of code to do.

Re: React is holding me hostage

#520

Earlier quoted context omitted.

Would you? Most $400 laptops are on 10th gen Intel or such. Thats actually pretty good. A Pentium Gold is actually just on the edge of a modern i3 which in single core. Smokes most 8th gen chips. They are pretty good. $250 in an Android phone can get you a SD 695 5g these days. IT's not fast per say but it absolutely doesn't suck.

Yeah I agree with the GP. Most $400 laptops come pre-loaded with all sorts of janky crap that make that 10th gen intel CPU run like a wounded animal. Most users have no idea how to remove any of it. Or, worse, they'll enable all of the preinstalled antivirus programs because they want their computer to be safe. And it gets worse. I visited my parents once and noticed something weird on my dad's macbook air. Turned ou…

Oh I know, but that situation has become less common over the years. Fewer users are buying AV and most AV is getting better so people don’t complain. Users using outdated versions of Windows with IE has a much larger impact (because IE’s JS engine is incredibly awful)

But the point I was making was that the average computer has actually gotten pretty good. Most users use near-latest chrome, most laptops have gotten much quicker.

And that’s before noting that the average cell phone in the US has BETTER js performance than the average computer. Most US mobile users have a modern iPhone that is faster in single core performance than some 10th gen laptops.

Post reply on HN