3 ms·
I was blown away when I learned the concept of the virtual DOM and how diffing it could be made fast. But as practical tool, React has been a regression for th
by tambourine_man 3y ago
I was blown away when I learned the concept of the virtual DOM and how diffing it could be made fast.
But as practical tool, React has been a regression for the web IMO.
- Kilenaitor 3y agoHow has it been a regression for the web?
- tambourine_man 3y agoI don’t think direct DOM manipulation was ever a problem, if done thoughtfully. If keeping track of state is so hard that requires a library to render it, perhaps you have too much state for a single view. It’s ultimately a UI/UX design problem, as it will be hard on your users as well. I find the way they mix markup with code distasteful, and lots more.
- 5Qn8mNbc2FNCiVV 3y agoIt's less keeping track of state is hard and more keeping state in a medium that isn't suitable for it (the DOM). The argument of too much state in a single view is nil by what applications are built nowadays (and also expected). Obviously it was already possible without the rise of declarative rendering frameworks but it made it more accessible to the majority of developers and thus raising the bar. If you do however find the way markup and code is mixed feels distateful, I'd suggest to not look at any templating engine in the last 20 years because that's what most of them already did.
- tambourine_man 3y agoIf you’re building a Gmail competitor, by all means, go with React, build your own solution, whatever. If you need to choose the color of a shirt with 3 sizes, perhaps it’s an overkill. Regarding templating engines, I use PHP :)
- yazaddaruvala 3y ago> I don’t think direct DOM manipulation was ever a problem, if done thoughtfully. Then you've never worked on a medium/large UI application (1k+ LOC), and most certainly couldn't have lived through the era of DOM manipulation! jQuery when it first arrived was a god-send! but even the most thoughtful couldn't structure it right. Backbone when it first arrived was a god-send! but even the most thoughtful couldn't structure it right. React when it first arrived was a god-send! but even the most thoughtful still can't always structure it right. With, the inclusion of so many other failed and semi-successful attempts throughout history I have no idea how you can possible claim: > I don’t think direct DOM manipulation was ever a problem, if done thoughtfully. without just being naive...
- tambourine_man 3y ago24 years of web development here. Large code bases and I still love jQuery. Whenever I can avoid React, I do. htmx is the first JS thing to tickle my curiosity in a long time. Vue seemed fun at first, but it got more complex than needed, IMO.
- yazaddaruvala 3y ago> By removing these arbitrary constraints htmx completes HTML as a hypertext I agree, this is interesting. I even agree, htmx is probably a polyfill waiting for the browser standards to catch up. That said, trying to make a markup language smart is a losing battle in the long-term. It makes simple things like `if` and `while` difficult. Markup also really struggles with time / interactivity. e.g. What should be displayed when a form is invalid? https://htmx.org/docs/#validation-example https://htmx.org/docs/#validation-example is just not ergonomic even for a simple case, let alone complex validations that interact with other fields, are async, etc. I get a allure of wanting "only a markup language", however, it just isn't enough to be competitive for 95% of web development these days. In a different response you say "if you're building the next Gmail, fine use React, but you don't need React for picking between 3 colors to order a shirt". This is true, but it is fundamentally lacking the realization that no company wants to end their feature set at 3 colors for a shirt. They "want" to build a foundation quickly, but then enhance it to be able to custom create the shirt for exactly your body sizes and allow interactive movement of the "logo" or "graphic" anywhere on the shirt. They want the validation to ensure the shirt can be printed, and they want to ensure their logistics network is dynamically updating the order history for live tracking of the package. To get there, the best thing to do is to use React (or similar) even when it is "just 3 colors".
- steve_adams_86 3y agoI don’t agree with that blanket statement, though I do agree that it (and libraries/frameworks like it) have played a significant role in bloating the web. Perhaps even bloating development tooling in the JS ecosystem. At the same time, my capabilities with web applications have skyrocketed in the last ten years and I wouldn’t credit it strictly to my experience. These tools aren’t only used because they’re relatively accessible; they’re genuinely capable and powerful, and when used well, allow remarkably fast development and iteration on products with real value. I think that’s better than the bad parts. Also, a lot of what’s bad about the web today (for me at least) has virtually nothing to do with the tools we use to develop. It’s that our attention has been commoditized, and that market has eroded a vast portion of what made the web exciting.
- hbrn 3y agoThe concept of the Virtual DOM is a means to an end to achieve declarative UI. It being "fast" is a common myth that spread in React community. Fast compared to what?
- tambourine_man 3y agoCompared to what I would imagine such complicated scheme would be. Turns out, computers are fast and diffing algorithms are fun to tinker with. Also, you don't need Virtual DOM to have declarative UI, just ask Svelte.