r/javascript • • May 19 '18

help Some meandering thoughts about Vue.js vs. React.js

I’ve been a software engineering consultant for the past 12 or so years and, after a three-year stint performing mostly full-stack work involving some combination of Node.js, Ruby on Rails, and Ember.js, just recently began working for a client looking to develop their website’s UI in Vue.js. I began learning Vue.js from scratch, but, maybe a month into the project, the client switched to React w/Redux due to internal politics. Switching from Vue.js to React.js/Redux was . . . awkward. I can’t quite put my finger on it, and I’m probably going to get flamed for this, but . . . man, I don’t really like React. Honestly, compared to Vue, it just feels hacky and convoluted, whereas Vue feels more well-structured/better organized. I might go so far as to say that it’s a joy to develop in Vue. (I’m sure that some would have similarly kind things to say about working with React.)

I’ve heard some people say that React’s/Redux’s unopinionated nature allows for a higher measure of developer customization, etc., but, working on a team of engineers far more experienced with React (and Vue) than myself, the open-ended questions of React have led to no lack of disagreement among those engineers as to which package to use to handle interactions among actions, reducers, and the store. I noticed that we never had these conflicts/problems with Vue.js and were, on the whole, more productive, because we weren’t trying to solve rudimentary problems; Vue.js just prescribed the solution, and everything was fine.

Here’s the gotcha, though: in terms of consulting opportunities, React is far and away the more popular of the two frameworks in my major metropolis. So, while I think Vue is the superior framework, React has market share. There is considerable financial incentive to learn what feels like the worse of two similar solutions. I have a personal project that I’d like to develop using a modern front-end framework, and I’d like to use Vue.js. But, if I want to have demonstrably sharp chops at React and NOT spend all my time trying to become expert at both, I feel like I have to choose React

For all that, I’m wondering whether anyone else has undergone the same experience and has any advice as to how I might streamline/improve my React/Redux development experience, because, right now, I can’t help comparing it to Vue on a daily basis.

79 Upvotes

35 comments sorted by

View all comments

Show parent comment

18

u/acemarke May 19 '18

To be honest, a lot of this comes down to opinions, preferences, and where you fall on the "explicit behavior" vs "magic" spectrum.

React's internals are generally a black box, but the mental model it gives you is pretty explicit: a component re-renders when I call this.setState(), and all updates can be traced back to a setState() or initial tree render. Similarly, with Redux, you bring all your own state update logic - Redux just provides a pattern for organizing that logic, and React-Redux lets you specify exactly what data each component needs. Selectors aren't required, but they're encouraged to both encapsulate state shape and improve performance by skipping unnecessary re-renders. I personally like React and Redux because I have specific control over exactly what's happening in my application, and I generally prefer explicit code over implicit behavior. That said, you are also welcome to use whatever levels of abstraction you want in a React-Redux app, and you get to pick the abstractions that work best for your team.

(Meanwhile, MobX is another state management library that uses the same observable/computed data approach as Vue does, so you might want to look into that.)

JSX is definitely a hate it or love it kind of thing. Most of the React community loves it, because it means we don't need any special template languages to do our rendering - we just use normal JS conditional and looping logic. Others prefer the stricter separation of template structure from data handling. (Note that Vue does support both approaches.)

As for project structure: both "folder-by-type" and "folder-by-feature" are common, but that's really up to you and your team. Use whatever you find maintainable. I go for "folder-by-feature" myself.

Hopefully that gives you a bit more insight. If you've got any other questions, feel free to ask, and I'll do my best to answer.