by diegof79 · 1y ago · 0 comments
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.
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...
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.
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.
This was exactly how I felt. I building a Backbone app around the time React was released. It was only around 2600 lines of JS at the time but event handling and state management already felt like a tangled mess.
Porting it to React was a huge improvement even at that scale and really paid off over the next 5 years of development.
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.
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.
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.
Haha, coffeescript was so hot for a minute
He had a very prolific year.
But to keep in the good graces of our thought leader overlords, let's start solid or svelte.
React looked great when I first used it for something really small. It looked horrific when I used it on a massive project with ridiculous amounts of data and tons of middleware. Although the real horror was the useEffect spaghetti. Vue keeps looking reasonable in every project I encounter it in. Even when people use it poorly, it's never Vue itself that's the problem. Well, maybe when people start working around the reactivity. That can get really bad.