React vs. Vue (3)
Part III - React vs. Vue
Just so that you don’t have to read through the whole article, let me tell you right away. I prefer Vue over React. I prefer it because it is a workhorse and I was able to create UI functionality faster than with React. Having tried out these two technologies on the same project, I can say with confidence that Vue was also easier and more fun. React is certainly a serious contender with aspects worthwhile considering, most notably its functional nature and its large ecosystem. However, if I had a greenfield project or legacy project porting to do, I would certainly choose Vue for the web UI. The reason is that Vue gives developers a more powerful and comprehensive set of tools. It builds on the strengths of React and Angular and then adds some impressive features of its own. Vue gets two things right: reactive data binding and extensibility. In conjunction these are very powerful. With power comes responsibility, of course. It would be possible to go overboard and abuse these features. However, the foundation of the Vue framework is very sound. Despite of it being newer than React and Angular, it can be considered a mature framework.
Neither Vue nor React contain any actual UI components. Of course, one could create components from scratch using just HTML5 and CSS3, but most developers will want to add a ready-made UI component library to make their lives easier. There are many excellent libraries available for both React and Vue. I worked with Vuetify for Vue and Material UI for React. Both are semantic component libraries based on Google’s “Material Design”. They both have support for responsive design and -besides components- they both provide scaffolding for styles, typography, layout, icons and color themes. In terms of components, Vuetify’s selection is more comprehensive. Aiming at an all-in-one solution, it contains everything but the kitchen sink. Autocomplete, calendar, datepicker, carousel, treeview, expansion panels and timelines are some examples for its more advanced components. It also integrates with the Vue CLI and tooling. With Material UI, you have covered all the basics, like inputs, comboboxes, tooltips, tables and such. But you might have to look for additional third-party components every now and then. For example, I used the excellent material-table component in my project to simplify the task of displaying data tables.
Let’s talk about application design. There are many similarities between Vue and React, including the one-way dataflow, virtual DOM rendering, and support for TypeScript and Flow. And then, there are also many differences, the most important perhaps relating to application design itself. React is primarily concerned with UI rendering and state management. Application design is completely left to the developer; React is “unopinionated” in this regard. Vue provides more structure in the form of single file components which themselves have a well-defined internal structure. Perhaps we can call this a “sensibly opinionated” component design. It means there are some conventions that provide developers with a baseline to build on. But that’s about it. Vue doesn’t dictate design beyond the level of components. Interestingly, working with React felt at times more restrictive to me, despite of its unopinionated nature. This may sound counter-intuitive, but once you have chosen to prefer certain React patterns, such as using functional components and hooks over class components and lifecycle methods, implementations become more uniform and simultaneously more restricted. It becomes harder to implement certain functionality and it takes more lines of code to write. The main reason is that you have to write code to perform state changes and trigger rerendering manually, whereas in Vue this happens automatically. I also found the React
useEffect hook a bit unwieldy compared to the React lifecycle methods and the Vue lifecycle methods.
You can bet there is a reason behind this, and in my opinion the reason is found in the respective design philosophies of React and Vue. React was designed by and for a large corporation. It was created to be used in the context of Facebook applications in order to solve certain problems in UI programming. Large corporations have more staff, more interfaces, more rules and more complexity. In a large company, technology decisions affect many people and there may be constant fluctuation of individuals and teams working on different aspects of a large scale system. Im such an environment, conventions are very important. If people understand and apply the same conventions, they can collaborate more effectively. React is ideal in this scenario, because it emphasizes and enforces conventions in a minimalist way. Vue, on the other hand was created by an ex-Google engineer who designed the system to his own liking. Evan You created Vue to bring together the things he liked best about other existing frameworks, such as Angular and React. In doing so, he set out to achieve a balance in scope, rendering, and state management that falls somewhere between Angular and React. Vue gives developers more choices and more responsibilities than React. Perhaps one could say that React is corporation-oriented, while Vue is more developer-oriented.
To summarise, React is great for organisations that prefer layered, strictly defined and highly customisable solutions for progressive scope. There is a large React ecosystem which addresses exactly this need. Vue is ideal for organisations that emphasize productivity and prefer out-of-the-box solutions for standard problems. Vue accomplishes this without being overwhelming and simultaneously maintains efficiency and balance.