Live data from Hacker News

If not React, then what?

infrequently.org

731–740 of 756 posts

Re: If not React, then what?

#731
post #725
post #709

Earlier quoted context omitted.

> I've found that even if the page is, like, tax forms, latency changes the feel of it and affects how the user feels about your site, even if they wouldn't consciously say anything about the speed. I agree with this, but probably wouldn't about specific numbers or use cases. By the way, one of the forms on our app round trips in 75ms when selecting a radio button that controls which set of fields is visible below it…

> It's one part of our app. We wouldn't let that singular use-case dictate our entire stack. Well sure, but in that case it's no longer "it's solving a problem we don't have". It's solving a problem that may be low on your priority list, that you maybe choose to tolerate, or solve in a more cumbersome way, but it's still an undeniable pain point. And if you flip the question, I just haven't seen the compelling case f…

> Well sure, but in that case it's no longer "it's solving a problem we don't have". It's solving a problem that may be low on your priority list, that you maybe choose to tolerate, or solve in a more cumbersome way, but it's still an undeniable pain point.

Yes, in that case, i.e., if it were a problem we had. It's NOT a problem we have though. That's my point. Not currently. Not in our context.

> But I honestly think that if React or similar had come first, we'd never have invented server-side frameworks as we know them

Not exactly React, but there was ActiveX, Flash, and Java Applets. Thick clients came first. It wasn't until IE6 where there some AJAX was viable. React came later to address additional shortcomings: procedurally updating the state of the document via jquery got complicated, and large organizations with poor development practices (e.g., facebook) struggled to maintain control of their application. They came up with React to help with this, and it did, but it brought its own host of problems. Declarative UI was what we always had with server rendering. They just allowed it to update. Btw, this isn't a new idea. We had something like this with ASP.NET as well, but that included the server.

Meanwhile, people like Chris McCord had already built a syncing library for Rails to solve these problems and, being fed up with the performance at that point, went to Elixir where he eventually built Phoenix LiveView. By then, React already had significant market share. Turbo's previous incarnation came out before then and its current one came out around that time or slightly after. Combined with Ruby's performance improvements over time, it was quite viable for many apps.

Also, note what's happening in React -- it's moving towards more server rendering. People realized they lost something by doing client only and they're trying to get back to it. Remix is an ode to the simplicity of old (which is really the simplicity of now, but they don't want to give up their React Components). I can't blame them in a way, React is a lot of fun to write a lot of the times.

> Maybe they've found themselves a good unified state abstraction now...

We've always had the database. That's insufficient for highly interactive applications where you need client-side state, which is likely what you mean by "unified". So yes, if you need "unified" state, and specifically the ability to change your UI based on changes to that state, React is great, or any of the other libs. The author was specifically concerned about React's current state (e.g. legacy IE6 support) and I'm specifically concerned about people reaching for React when they don't need it. That's because I've done it, I've seen people do it, and I see people continuing to preach the React orthodoxy which will lead to more people doing it. This thread is full of it.

Whether or not a person recognizes it, HTMX, Turbo, LiveView and its kind have greatly narrowed that gap. They've made server rendering just as capable at highly-interactive UIs in many more cases than many people think.

> I used to pride myself on knowing dozens of languages, but I've come to see much of that as superficial and pointless.

Sure, I can relate to this. But this is different than spreading FUD about having to learn a new language. That's easy. That's the easiest thing we have to do. I'm not suggesting to do it flippantly. I'm suggesting that sometimes it's worth it. When it's worth it, you do it and it's not a big deal.

Re: If not React, then what?

#732

Earlier quoted context omitted.

It's been used to describe code that does A on server and B on client side, where A and B are deeply related but definitely not the same. It's not just code sharing, that's just a small part of it.

My argument is that it's a forced and silly misuse of the word. I'm struggling to understand also how it came to be [ab]used in this context. To take an old Greek mathematics word and use it to mean something that it doesn't really mean? Why? Isn't that silly? Isn't it pretentious?

Yeah, that's why everyone switched to "universal" after a year or two. But some people are not as up to date and some libraries kept their old names.

Re: If not React, then what?

#733
post #681
post #545

Earlier quoted context omitted.

>it’s all prioritisation of developer experience over user experience. And I have been saying this for well over a decade. Hopefully it catches on. I have always asked for example of sites done in React where I couldn't tell it is done in React or other JS Front End. The "at worst, hundreds of milliseconds" is precisely why Web Apps never felt as good as native apps. And if we collectively cant make web apps good, wh…

> why does liking a tweet re-render the entire screen? They're probably using Redux, which has been the go-to for state management in React for nearly a decade. I've always been averse to it because it's implemented using contexts and triggers those full re-renders - it was designed during the class-based components era and relied on people actually implementing shouldComponentUpdate(), which isn't really a thing wit…

Redux uses context but does not do full re-renders except if you are using it wrong. It does a shallow compare on the object resulting from your selector to decide whether or not to re-render a component.

That being said, none of the React projects I've had the chance of working on in the last 5 or 6 years has used Redux, so stating that it's been the go-to state management library for nearly a decade kind of sounds weird to me.

Re: If not React, then what?

#734

Earlier quoted context omitted.

My argument is that it's a forced and silly misuse of the word. I'm struggling to understand also how it came to be [ab]used in this context. To take an old Greek mathematics word and use it to mean something that it doesn't really mean? Why? Isn't that silly? Isn't it pretentious?

Yeah, that's why everyone switched to "universal" after a year or two. But some people are not as up to date and some libraries kept their old names.

I wasn't aware that the favoured term had changed. I do think universal is clearer and much less silly.

Re: If not React, then what?

#735
post #724

I've spent years slowly migrating a personal project from PHP to Scala/React, and I'm devastated if React is out-of-date already. The web tech treadmill is relentless! Seems the author recommended HTMX as an alternative in a couple of scenarios including my own use case ( https://caption.me ). I checked out HTMX. The canonical example on the homepage ( https://htmx.org/ ) was a button where a click calls the server a…

yes, htmx is very much suggesting returning HTML rather than JSON from the server, and collapsing a layer of complexity in the process. this has turned out very well for some applications, dramatically lowering complexity:

https://htmx.org/essays/a-real-world-react-to-htmx-port/

looking at caption.me, I see nothing that couldn't be effectively addressed using this hypermedia approach, and I suspect it would simplify the application. You don't worry about "breaking the other side" because there is no other side: everything is hypermedia, in the original mode of the web

I don't think PHP has much to do with htmx: you can use PHP if you'd like on the server side, but you can use whatever server side technology you'd like to produce HTML. People are using Go, Java, Kotlin, Scala, Rust, Python, Lisp, etc. with it and it works fine. It's a generalization of hypermedia controls[1] (anchors and forms) and, like anchors and forms, has no opinion on what the server side looks like.

One piece of good news regarding htmx is that the API is not going to change dramatically in perpetuity, so there is no treadmill to keep up with.

[1] - https://dl.acm.org/doi/pdf/10.1145/3648188.3675127

Re: If not React, then what?

#736
post #713
post #702

Earlier quoted context omitted.

> It's calling into you three or more times, invisibly, if I remember the details of what useEffect and useState actually do at runtime correctly. Which rather illustrates the point. If they were using useState() correctly and provided a button or link to call the update function, yeah, React would call into their code as many times as the user clicked the button. As it is though, it's just once (useEffect with that…

> If they were using useState() correctly and provided a button or link to call the update function, yeah, React would call into their code as many times as the user clicked the button. As it is though, it's just once (useEffect with that second argument is "only run the passed-in function once on mount"). As I understand it both the useState and useEffect create points where their code will be suspended and resumed…

Nope:

The first run through, useState() returns the default value and your code runs to completion. When the update function is called, that entire React function is run again, but this time useState() returns the new value instead of the default value.

Likewise useEffect(), your React function runs all the way through and the callback passed to it is run afterwards at various times depending on the dependencies array. First run is immediately after, on component mount, then every time the dependencies change (if dependencies are specified), or every rerender (if null/undefined instead of an empty array).

Re: If not React, then what?

#737
post #700

Earlier quoted context omitted.

> Routing: react router (not very good imo but widely accepted and good enough) Unnecessarily complicated and confusing, with odd choices in the most recent version (that IIRC are not backwards compatible). I went with wouter after searching around. > state: No libraries. Just use “useState” and if necessary “useReducer” useState is the same thing as the old setState, and useReducer not much different - they're not s…

I don’t see how prop drilling is an anti pattern. Passing data around via props is a feature of the library, it’s totally fine if you need to pass a lot of props. If you really have too many props or need to widely disperse the same prop you can refactor using higher order components or use a context. A separate state management library isn’t necessary unless you are building something with a ton of complex UI state…

Prop drilling refers to depth, not width - you had to add the props to every intermediate component between where the state is stored and where it's used. Some of us tried to come up with nested usage patterns so at least the intermediate components didn't need to know about the structure and it wouldn't be a pain when moving things around, but it still wasn't very good.

Re: If not React, then what?

#738
post #630

Earlier quoted context omitted.

"Trucks are bad for X" "No, trucks are good for X" "Look at this use case (Amazon) with tons of objective data that shows that trucks are bad for X"

"Look at this use case (Amazon) with tons of objective data that shows that trucks [do not fit Amazon's use case for X]"

It seems that you're arguing that the performance requirements of Amazon are different from other sites (in e-commerce or not). Is this it?

Are you arguing that web devs should ignore CWV for e-commerce sites?

Re: If not React, then what?

#739
post #730
post #483

Earlier quoted context omitted.

I might not be able to tell if it's using React specifically, but I can tell it's using a React-like framework trivially because it feels like the entire website is covered in glue

No. You are just dealing with bad code. There are highly performant web apps written in React. It's all about craftsmanship. React gives you many tools to skip unnecessary work and reduce latency, such as shouldComponentUpdate, and assigning keys to elements in a collection. Or architectural decisions like splitting your UI into components correctly. It's up to the individual developers to use them. Bad developers wr…

> No. You are just dealing with bad code. There are highly performant web apps written in React.

cool maybe I'll see one one day

> React gives you many tools to skip unnecessary work and reduce latency, such as shouldComponentUpdate, and assigning keys to elements in a collection

but do people use these outside of demos

I have an high end CPU with 32GB of RAM and almost every single website I use gives me a worse experience than I got 20 years ago

> if one writes bad frontend code, well the cost is diffuse and many don't notice it.

exactly, and that's why we are where we are today - surrounded on all sides by websites covered in glue, because bad experience has been completely normalised, all for what? Some abstract notion of developer convenience that results in almost every case in a significantly worse experience by almost any metric.

Re: If not React, then what?

#740
post #631

Earlier quoted context omitted.

React is in use in many heavily used frontends at Amazon, maybe not the retail site But there's no inherent reason React couldn't be used for a page that basically shows pictures of products with a description next to them, the bottlenecks will have nothing to do with the frontend in a well engineered system for that type of site

> maybe not the retail site I'm discussing the retail site specifically because that's where CWV matter. If a company has internal tools that take seconds to load it doesn't really matter. Captive users don't have much of a choice.

It's in use in customer facing apps, Prime Video is built with React
Post reply on HN