Live data from Hacker News

React is holding me hostage

emnudge.dev

531–540 of 553 posts

Re: React is holding me hostage

#531
post #362

Earlier quoted context omitted.

> You want to show something new to your customers / users without rerendering? Well sorry, that's impossible, regardless of any framework you use and you should go back to UI development 101. When you say “render” are you referring to what React means by “render”, that it will go through the whole virtual DOM cycle? Because it most certainly is possible to avoid that when using pure JavaScript. Why do you say it’s i…

To show something new to the user, state must be calculated and pushed either to the DOM or blitted to a canvas.

Not sure I understand your point, can you elaborate?

My point is that updating the state for a single element causes React to compute the state for the whole page, and diff the whole page virtual DOM against the whole page actual DOM, before pushing the update of that single element into the DOM. With pure JavaScript, you can skip all that and directly update a single element. This is often in practice much faster.

Re: React is holding me hostage

#532
post #292

Earlier quoted context omitted.

> Performance is very very rarely a contributor to a product success. Users prefer more features over more performant app all the time (both directly when asked and indirectly by what products they choose). Yet this is what all the JS people were saying in 2014 - 2015 when everything started to become SPA. They argued this is what the users want. That's been used to justify all this stuff for a very long time if you'…

Rerendering on the backend can actually be faster than doing AJAX calls because the BE has to send a lot more data than if it's server rendered. I

How is "server rendered" different form "rerendering on the backend"?

Re: React is holding me hostage

#533

Earlier quoted context omitted.

We’re coming at this from different mental models. The code you linked is what React helped me get away from. There’s multiple files in different folders for one screen. It’s hard to see how it composes, which is a useful boundary as it lets me know in the scope of that part of the UI. UI is _hard_. There’s complexity that needs to go somewhere, and I’m one of those who prefer to push as much if it that isn’t busines…

It is idiomatic JavaScript. If you learned Java at the university you'll immediately be comfortable with the code. Now consider React with hooks. It is neither OOP nor functional and it looks alien to anyone who knows idiomatic Java or JavaScript. Would you recommend a youngster learning programming to learn React? I wouldn't, because it is so frankenstein. This article makes that point better than I can: https://med…

JavaScript brings together so many paradigms, I can see strong cases for multiple different expressions of the language.

We didn’t have classes until ES6. And they’re not real classes, they still use prototypical inheritance under the hood.

If you want truly idiomatic JS, you shouldn’t be using classes. You should only be writing functions, and build your class-like objects with prototypes.

On a practical level, I absolutely recommend new engineers learn React. The job market is enormous, it’s a skill the market still rewards well.

And it’s a very productive framework. It rewards you for learning it, with better collaboration and velocity.

I would say the same for the other major view frameworks too, but React still has the biggest job market.

Until ES5, the industry thought JS was a Frankensteinesque monster.

Until maybe 5-7 years ago, anything that wasn’t OOP was considered a bit weird.

Calling any of these languages weird, is like policing English speech. We borrow so much from other languages that’s words have multiple meanings. Pronunciation follows contradictory rules, and regional dialects can be hilariously incompatible.

There’s a few languages closer to French, which has a strict control on what the French language is. For example, Go. There’s really only one paradigm them, only one way to do things.

Like it or not, pushing the boundaries of language design and framework design is how we improve as an industry.

You can’t not like a new thing because it’s weird at face value. You risk missing the forrest for some moss on a tree, and being left behind.

And sorry, that’s the same article this comment thread spawned from. I didn’t find it convincing at all, it’s let down by a lack of understanding in a few key areas.

Re: React is holding me hostage

#534

Earlier quoted context omitted.

I think they’re referring to how Reacts mental model is to wipe the page and rerender. The earliest versions basically did that, and then they started diffing and applying the diff.

They're referring to a specific bit of code in that Eureka repo that sets innerHtml = "" and then does .appendChild(). They just apparently didn't notice that the code doesn't use React at all (and is meant to demonstrate the use of vanilla modern JS without React).

Yep that’s what I was alluding to as well. I’m pretty sure they noticed it wasn’t using react.

The comment was a reference to the fact that if you don’t use a framework, you’ll end up a building one anyway.

Re: React is holding me hostage

#535
post #472

Earlier quoted context omitted.

How far down the rabbit hole do we need to go? Because at some point your function call is manipulating registers on the CPU. If we go even further, the CPU needs to load its next instructions and then the data required. Point being, we abstract and encapsulate complexity and provide a simpler API around it. It’s the only feasible way to manage the inherent complexity. React builds up a virtual description of UI. rea…

It's just that "You can build a UI without useEffect." and "You can ... contain where useEffect is being used." are not the same statement. Maybe I'm being pedantic, but when I read "build without X", I think there is some method that can be used to avoid X, not that I can hide away X.

They’re not the same statement. Both are correct. But as always, the nuance is critical.

All declarative code eventually runs something imperative.

And anything non-theoretical is going to have side effects somewhere.

Painting to a screen is a side effect.

Reading a file is a side effect.

Software gets messy when it intersects reality.

But, we can do quite a lot by staying in a theoretical realm. You can build a whole UI in the theoretical realm, where no side effects exist.

When you actually need to run it though, you drop out the the theoretical and into reality. Now there’s side effect’s everywhere.

So you contain them. Encapsulate those side effects into composable blocks. Test them extensively. Offload that work to someone who’s just focussed on managing them.

Updating the DOM is a side effect. Making a network request is a side effect.

Contain them, test them, and then you can stop thinking about them.

If someone else has done all the work to contain side effects, you can build a UI without them.

Re: React is holding me hostage

#536

Earlier quoted context omitted.

"the modern webapp experience is so miserable for the average person." Hyperbole. Web apps would not be so ubiquitous and popular for solving business problems if your claim was true.

It's not hyperbole, IMO, and this format of rationale is faulty. There are many reasons why technologies and platforms become ubiquitous. Asserting that being ubiquitous means it can't also be miserable for the user is demonstrably false, with almost unlimited examples throughout software history.

Ok, I agree, Point taken.

However almost certainly ubuitity is one measure or factor in an item's usefulness. I'd also claim Usefulness inversely correlates with miserableness in the mind, but perhaps not in practice :P depending on how boring or miserable useful things are.

In general, I think usefulness overrides miserableness simply because the willingness to do useful things, despite miserableness, is clearly tolerated and performed all across human economies and societies through time. all just depends on definitions

Re: React is holding me hostage

#537
I have a few problems with React hooks.

1. I’m not sure what they have in common with each other. What exactly is a React hook. Nearly every hook is its own thing, with its own purpose, use, etc. With the new “use” hook, even the original hooks rules don’t apply anymore.

2. Related to the above, every hook is an entirely new concept. Learning react you would think once you learn “hooks” you will be able to understand basically what they did. Much like once I learn “classes” or “functions” I can figure out what they are. But every hook is its own concept, with its own rules, and gotchas, etc. Sometimes I wonder if the reason they’re called hooks is to present them as a single Concept, otherwise it would be too obvious that React replaced a few concepts, state, and component lifecycle, with about 3-5 concepts in the library in the early versions, and many more now, with an infinite possibility of concepts through custom hooks.

3. No one in the React world seems to have a clear mental model of what hooks are. useEffect is the most egregious here, but the name (and the original React docs) indicated it was for side-effects. But then it’s also used for lifecycle management. Finally, it appears that now the React devs have started pushing the idea that it’s to keep “components in sync with an external system”. And useEffect is probably the most used hook outside useState.

To be fair, usually descriptions of concepts can change with time. But with useEffect it’s not just the description that’s changing. It’s the entire mental model, which makes it seem that the React devs themselves are not clear what useEffect is supposed to be.

Fundamentally, hooks seem to be a bunch of ad-hoc solutions that React devs use to solve specific problems they notice in the wild. But there doesn’t appear to be any fundamental consistency to what they really are.

Re: React is holding me hostage

#538

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,…

The claim that if you used React for the past 6 years meant you used a single library is almost certainly false.

Because what React is as a library today, with functional components+hooks is completely different from what React was when it first came out, with class components.

React is quite clearly a name that incorporates at least 2 distinct libraries which are supposed to be fully compatible but they’re not…try using a ref for a functional component.

The existence of these 2 libraries under the same name means thst documentation is also increasingly confusing. It also means that both libraries are probably making compromises So they’re still compatible with each other on the surface.

Re: React is holding me hostage

#539

Earlier quoted context omitted.

Except React decided to change to hooks and break all their docs. And Vue decided to break things with ver 3. And then there's Next. No, Nuxt. Wait, no, it's Nest. Or Sveltekit. It's not frontend anymore, it's more like frontend on backend, but not quite. No, is both now, we got interactive islands. And web components. Oh and wasm. Or was it blazor? And we have webpack. No, Vite. Or Parcel? Almost forgot, it's esbuil…

I think you've accidentally proven his point. Half the things you've mentioned have been around for half a decade at this point, and pretty much all of them have existed for at least 2+ years. Frontend is still a fast moving space with a large ecosystem - and I get for some, that's not ideal. But this 'frontend fads' meme isn't really reflective of the current reality. Webpack - 2012, Next - 2016, Nuxt - 2016, Nest -…

Rust, which is the greatest new hotness in the backend world is from 2015.

Other major languages in the backend world are at least 2 decades old (C#, Java, Python, C++, Ruby, etc).

C# with the .Net framework is an interesting example. Microsoft realized their original windows only approach was a dead end. They created .Net Core. But someone moving from .Net framework to .Net core didn’t have to relearn much at all, beyond initial config/bootstrapping, and which subset of the APIs had been implemented, because MS completed the implementation in stages.

On the flip side you have React, where you’re ostensibly using the same library for a decade, except halfway in between they made a change which completely flipped how developers weee supposed to use the library.

Re: React is holding me hostage

#540
post #277

I feel like React + Redux + some kinda lens mechanism is a really good fit for UI development. Is there anything like that already?

> some kinda lens mechanism Does immer count? :)

You still have to reduce the entire state no? I would imagine it to be something like:

struct A { b : B }

impl Reducer for A {} impl Reducer for B {}

Now the reducer logic is spread out across the state. Sure, every sub-state now need to handle Action every time but with tools like ADT and pattern matching I don't think its as bad. I feel like this will be cumbersome, but the complexity should scale linearly.

Post reply on HN