(no title)
diegof79 | 4 months ago
The article overlooks the problems that made React popular:
- Composition: Composing components is easier and more efficient in React. Backbone’s render function assumes "this.$el" is mounted and available in the DOM. That makes composition difficult: you cannot simply nest one component inside another without managing the DOM lifecycle of subcomponents. You don’t need 1.000 components to feel the pain.
- Event handling: You can’t pass an event handler as a string, so the events object must be paired with the selector to locate the element. Any structural changes require updating selectors or managing unique IDs.
- State management: Re-rendering components when state changes becomes messy in Backbone fairly quickly. That mess is why Angular 1 gained popularity. React simplifies this further by enforcing a one-directional state flow.
- Efficient DOM updates: Even if you implement composition and state management ad hoc, you still must update the DOM efficiently to avoid layout thrashing and related issues. React isn’t immune, but these problems are typically easier to handle.
- Other features: Implementing useful capabilities from scratch, like lazy loading parts of components (for example, suspense) or building hybrid apps with server-side rendering, requires significant work.
I'll argue that nowadays, if you want to use vanilla JS with templating support, lit-html (not the full framework, just the template part) is a much better choice than Backbone.
fny|4 months ago
Who wants to maintain this nightmare? https://github.com/tastejs/todomvc/blob/gh-pages/examples/ba...
Devs love to invoke Chesterton's fence but somehow forget about it when looking back on "the good old days."
What's worse, there were never good old days for frontend. It always sucked, and now it still sucks--just far less.
[0]: https://todomvc.com/
[1]: https://github.com/tastejs/todomvc/tree/gh-pages/examples/ba...
[2]: https://github.com/tastejs/todomvc/tree/gh-pages/examples/re...
ricardobeat|4 months ago
You can easily tell what every function is doing, including the library ones, and magical behaviour is kept to a minimum. It could be easily maintained 20 years from now, as you have a very thin layer over DOM manipulation and Backbone itself can be grasped and maintained by a single human.
One could argue that React leads to better development velocity, but from experience I can say that reality is not that simple. The initial speed boost quickly fades, instead a huge amount of time starts being allotted to maintenance, updates, workarounds, architecture and tooling as complexity compounds.
ysavir|4 months ago
cloverich|4 months ago
The reality is stateful UI is complex on its own. Then JS tooling is complex (byo typescript and std lib). Then UI is something everyone sees so the whole company has opinions about how it should look. Mush it all together and FE development is rough. React is a punching bag because its been dominant so long. Id welcome the next phase when it arrives. But building toy apps with aged technology imo wont bring to light any unturned stones. Id recommend researching the plethora of real code and discussions that have beaten this horse to death on the open internet instead.
throwawayffffas|4 months ago
As others have noted working with react after having worked with backbone, jQuery and ember felt like a breath of fresh air.
It felt that was we were doing was same again, and I would argue understandable. 11ish years later cruft has pilled own to dev experience detriment.
echelon|4 months ago
I'd say React is doing swimmingly at that job description.
For small, artisanal projects, there are lots of other choices and priorities.
I'm merely reiterating the blog's thesis.
flufluflufluffy|4 months ago
smrtinsert|4 months ago
diegof79|4 months ago
There are a gazillion of options that resolve the same problems: Vue, Svelte, Solid, Lit, etc.
Backbone was born as better code organization on top of jQuery and CoffeeScript. It never attempted to solve these issues.
ironmagma|4 months ago