Hacker News new | ask | show | jobs
by mrtracy 3218 days ago
As someone who has been maintaining a growing React/Redux app for a while now, this one has kept me up at night.

The main arguments in favor of Vue.js revolve around the idea that it is easier for new developers to understand; that people can pick it up and immediately be productive, with React/Redux being much harder to understand. As someone who wants to onboard new developers onto my project, it makes me wonder if I need to look into a switch, if not for my current project then for the next one.

A lot of the commonly touted differences are either a wash, or are only benefits for very small applications with perhaps a single developer. These would be Templates vs. JSX (This is a wash, they're the same thing, but this maybe even favors JSX for large applications), running Vue.js without a build system (you will want a build system regardless for any production application), "Two-way data binding" (Fools gold, will cause horrors if you ever use watches, you will end up hoisting almost all of your data to Vuex anyway in a production application) and "Single-file components" (Really skeptical that this will make a difference in development vs. any other organizational strategy). I can expand on any of these, but they've already been discussed to death.

+ Where I think Vue.js is actually superior to React:

Vue.js is quite opinionated and clear on where to put both data and computed properties. That's basically it, but it's a huge difference.

React itself is very hand-wavy about where to put data and how to interact with it; it basically leaves the problem for someone else to solve. Even Redux, which is designed specifically to store application data, has a weird interface to connect your data to the React application and has no opinion on where to put computed properties. React-router suffers from this same problem as well; you basically end up looking for blog posts on Medium to figure out how to construct an actual SPA out of these components.

This is a gigantic failing of the React ecosystem, and I think this represents almost 100% of the perception (or perhaps even reality) that developers understand Vue.js better than React.

+ Where I think React/Redux is still better

The React ecosystem takes a lot of inspiration from functional programming; it prefers "immutability" and pure functions whenever possible, and I think this becomes increasingly valuable as your application grows; not just for enormous applications, but even for medium-sized applications.

Even if you're exercising maximum discipline with Vue by hoisting your state to Vuex, you've still got many opportunities to create difficult bugs based on the mutable state. Are you sure you're not referencing mutated state in one your actions? Does one of your components hold onto mutable state in order to do a custom transition or animation? If you're using watchers, you're really risking some dangerous bugs here. Now, I know you probably won't do something silly like this, but as your development team grows and you can't code review everything going in anymore; can you vouch for everyone on your team not to make a subtle mistake with a mutable reference?

React/Redux also enables a few very useful patterns that Vue/Vuex doesn't offer at all. For example, the famous optimistic application is nearly a first-class use case for Redux, but would be quite difficult to implement in Vue. This doesn't matter for small applications; it does matter for large applications. Will it matter for your medium application? The same thing about Isomorphic rendering; Redux was built with this squarely in mind. It won't matter for your small app; are you planning for your app to be small forever?

Finally, because it is all Javascript, I think React/Redux has a much better ecosystem of tooling. That includes both linters and transpilers; for example, writing Vue in typescript isn't especially natural, but it works great with React/Redux. When considering my own purposes, effectiveness with Typescript is one of React/Redux's greatest advantages.

In summary, I would still maintain that React/Redux is better for medium to large applications than Vue, due to its commitment to pure JS and the inspiration it takes from functional programming. However, I definitely see the appeal of Vue.js, and I wish that the React ecosystem would take a note on how to provide clear opinions for developers.