(no title)
picardo | 4 months ago
The number of components is not the only yardstick of complexity. Most of the complexity in building a UI comes from state management and how state changes are propagated across the store and the UI.
I worked with Backbone for many years, and I can distinctly recall the hours of frustration I had debugging a UI because it was freezing due to cascading state changes. That was because we were using Backbone Store, which had bidirectional data flow, and when one updated the store, it would trigger a change to the UI, which would change the state store, which would change the UI, etc.
You could argue that the real innovation of React was "unidirectional data flow," but React team made Flux architecture central to the framework, making it easier to adopt good practices, whereas Backbone remained store agnostic and even encouraged Backbone Store which used the observer pattern for many years. I think you should choose a framework that allows you to fall into the Pit of Success, and React was that framework at the time, and for my money, it still is.
ruszki|4 months ago
hungryhobbit|4 months ago
Backbone employed a two-way data binding flow. You're responsible for updating the models (ie. state) (way #1) when the user triggers events, AND you are responsible for updating the DOM whenever the models (ie. state) changes (way #2).
In React, they used a revolutionary new paradigm (flux), making it so you only worry about one direction (updating the models/state in response to events); you never render anything (React renders everything for you in response to state changes)!
If you've tried developing a non-trivial site with both, it quickly becomes apparent how much that one difference completely simplifies a huge aspect of development.
CaptainOfCoit|4 months ago
Not sure if React isn't being presented as such anymore, but that's still the problem I see React solving, not more, not less.
treve|4 months ago
Marazan|4 months ago
As you say many people do not understand how important, vital and bizarrely _non-obvious_ uni directional data flow was.
sibeliuss|4 months ago
panphora|4 months ago
I appreciate the point about unidirectional data flow solving real problems, but I think we're trading one complexity for another rather than actually simplifying things.
Yes, cascading state changes with Backbone Store were frustrating to debug. But React's abstractions introduce their own set of equally frustrating problems: stale closures where your click handler sees old state, infinite useEffect loops because an object in the dependency array gets recreated every render, mysterious input clearing because a key changed from stable to index-based.
The difference is that Backbone's problems were explicit and visible. When something broke, you could trace the event handlers, see what fired when, and understand the flow. The complexity was in your face, which made it debuggable.
React's problems are hidden behind abstraction layers.
I'm not saying React doesn't solve problems. I'm questioning whether those solutions are appropriate for the 99% of apps that aren't Facebook-scale. Sometimes the explicit, verbose approach is actually easier to reason about in the long run.
sibeliuss|4 months ago
Having built many large-scale Backbone apps, anytime someone new came on board it was really very, very difficult, no matter how many design patterns one applied.
React's innovation was making FP mainstream. And then teaching the value of simplicity, as a principle. And yah, if something broke, it might be a little opaque, but at scale and in general, things broke _way less often_.
This is also the reason why most devs are full-stack now. Back in the day backend devs wouldn't dare touch FE code, and now its "not so bad", and pretty much anyone can work all over the stack.
rk06|4 months ago
You can use other frameworks for the other 1% of apps
wooque|4 months ago
You can hit the same problem with React. Circular state updates. State change->trigger useEffect->change state. I hit those when I had just started React.
lmm|4 months ago
azangru|4 months ago
Isn't this just how the DOM works? Data flows down through attributes and properties; events bubble up?
> but React team made Flow architecture central to the framework
Didn't they call it Flux rather than Flow?
flufluflufluffy|4 months ago
picardo|4 months ago
That's right, but this communication pattern causes serious complexity. Imagine trying to find out what triggered a state change. You would have to listen to every event source to find out. With Flux, all state changes were mediated by the reducer in the store. It made things a lot simpler.
picardo|4 months ago
Ah, you may be right. It's been a long time.
paulddraper|4 months ago
There is a DOM tree, but parents don’t pass data into or receive events from children.
austin-cheney|4 months ago
Why do people prefer this? It doesn't increase speed of maintenance. Its preferred because its composable to a predefined architecture scheme the developer is comfortable with. That's it. Its just about comfort, but the complexity is through the roof.
Simple isn't free.
vacuity|4 months ago
Never religiously cling to statements such as "strictly separate presentation and content". These are all just guidelines to suggest simpler solutions, not hard rules that guarantee simplicity. They will sometimes be excepted.
There are such things as components, which compose strictly by interfaces and externalize separate details, but it is up to the programmers to realize them in their programs. Also, simplicity is a global property of a system. Nothing can be judged on simplicity in a vacuum.
All that being said, I don't have experience in web or UI in particular. Seems like logic is moreso a local thing, whereas presentation is moreso global (but may consider locally defined advice). State can be local or global.
knollimar|4 months ago
You pay for it for smaller stuff, though, since that multiplicative coefficient is high.
qudat|4 months ago
Reacts innovation is simple: view is a function of state.
Before that we had to construct the ui imperatively where we managed state AND ui transitions to state changes. Now we mostly just focus on rendering a ui based on the snapshot of state we have. It is revolutionary (for ui dev), it is scalable, it is the reason why react STILL dominates the ui landscape.
React isn’t just popular because it’s familiar, that might be a component, but it ignores the historical and technological achievement it created
cindyllm|4 months ago
[deleted]
campbel|4 months ago
CaptainOfCoit|4 months ago
jgalt212|4 months ago
If have a 40X25 table on your page that's editable, that's your 1,000 components right there. But away from tables, it does seem overkill to have 1,000+ components on a single page.
amelius|4 months ago
I recently tried it with Kotlin/Compose. Turned out that everything becomes noticeably slower with so many components, even if the components are in a scroll view and only a few of them are visible.
jfengel|4 months ago
GeoAtreides|4 months ago
Why would you do it like that?! Just have a normal component for a table, and when the clicks on a cell, spawn (and teleport) an edit component over that cell.
unknown|4 months ago
[deleted]
unknown|4 months ago
[deleted]
robertoandred|4 months ago
acdha|4 months ago
That’s not to say that there aren’t benefits from that but it’s definitely extra complexity compared to using web standards.