Meanwhile, React lets you write your UI with JavaScript functions, which is completely different from anything I've seen before. You develop a bunch of functions and reuse them everywhere. Since functions are first-class citizens in JavaScript (i.e. you can pass a function as argument to a function and a function can return another function), there are pretty cool patterns in React. Like functions that enhance or inject styles or logic into your components (which are just functions too). This offers a lot of composability and reusability options to design and code your applications. (personal tip: Add TypeScript and VSCode on top of it to make your productivity skyrocket)
I've been a consultant using both for over 3 years now, full time and I can tell you I just use Vue these days. Everything is more readable, well-organized when the project is finished. You could do the same with React too, but it puts the mental burden on you.
I think performance-wise as well Vue is faster (it used to be). Not that it matters a lot. But, if you are a company, it's easier to find React developers than Vue developers.
Also, in big company environments, teams using React always end up in messy code that's not maintainable because of the freedom the framework gives as opposed to teams using VueJS.
So you need to pick the one that fits your use-case.
This is debatable...
> But, if you are a company, it's easier to find React developers than Vue developers.
... and this is probably one of the reasons why you've found more "messy" projects in React than in Vue.
In other words: people who know what they like (and hence probably do a good job with it) pick either Vue or React. Teams that don't know pick React because it is more widespread, easier to hire for, etc.
Could you expand on this? They're both tools for building components, how does Vue enforce more structure? FWIW I usually expect the same high-level structure for applications with both frameworks.
The use case I recommend Vue for is when you just want a quick drop-in solution. For any serious development I stick with React.
For any serious development I stick with React.
Isn't this a bit disingenuous given Vue's usage in true, scalable production capacities? I'm not the expert but companies like Netflix, Adobe, and GitLab have Vue deployed at scale. Since when was "quick" synonymous with "not sufficient for serious development"?Vue tries to keep code and HTML separate.
React says "everything is code".
Having spent years in the old "MVC html template framework" world, I used to be in the former camp. But nowadays I find JSX/TSX incredibly convenient. It's nice that a component is represented by a single javascript(ish) language.
I would imagine Vue is a much lighter, far less opinionated version of Angular. I've never been able to understand why templating is superior. And I want a strong argument that makes me seriously appreciate it, even if I don't change my mind. I've yet to see it. One gripe, at least with Angular templating, is templating constructs that are defined globally feel like leaky abstractions. Angular Pipes, for example. When I see a pipe, it's hard to find where's it's defined, where as React components are imported at the top of the file.
Because I already know the language, it's easy to conceptually build on top of that, which is why JSX is simple. But templating essentially defines a whole new language on top of it. It's not an insurmountable barrier, but it increases friction.
Maybe there's different brained folks where either "everything as code" vs. "HTML templating" is simpler.
You might find useful information here: https://phabricator.wikimedia.org/T241180
(The Wikimedia Foundation describes why they went with Vue.js instead of React or other competing libraries)
Single File Component tells you where you need to put things. You don't need to figure it out yourself and build up your own organization and patterns on top of Vue. You just start building the application.
It's not a completely apt comparison: but Vue shares more in common with Rails than with Node development—at least in terms of grokking. My understanding is their performance is virtually the same. Some applications perform better on one vs the other.
The biggest reason is that React works properly with Typescript. Vue can't type check anything in your templates, you can't type check Vuex (its state management system), you can't type check injected dependencies. Everything is strings. This means you'll spend a lot more time chasing down runtime errors and writing tests than with React. A lot more time.
Other differences:
* React doesn't have events, but frankly you should not use them in Vue either - use callbacks instead.
* CSS has to go in a separate file in React. That is a little annoying to be honest.
* React has an API split between traditional class-based components and function-based components ("Hooks"). They say to use Hooks in new code but I've seen some things that are really awkward to do with Hooks. Still you can just use class-based components if you like (same as with Vue).
* The React NPM package has something like 5 dependencies. Vue has something like 1000. It's basically impossible to avoid the NPM insanity if you use Vue.
* React has better documentation. Not that Vue's is bad, it's just not as extensive as React's.
* React is way more popular. Easier to hire people to work on it, bigger community to get help from etc.
* React has better tool support. Everything supports JSX/TSX. Not many things support .vue files. For example if you define a type in a .vue file you can't actually import it from any other Typescript files. Quite annoying.
There are probably other things I've forgotten. If you're using the class-based React approach then yeah they are quite similar; React is just much better engineered. If you are using React Hooks then it is quite a different approach to Vue.
A valid vue component can be as simple as {template: <div>{{1+1}</div>'}
Ofcourse you can extend it all you want and it even comes with its own cli but the fact they've managed to keep things so simple is what I love most about it.
export default () => <div>{1+1}</div>Beyond that, I would say the biggest difference between the two is that Vue is the scope of the framework. Vue includes much more in the framework itself and as first-party helper libraries whereas React relies heavily on third-party packages of which there often many competing options and which one is used varies from company to company and project to project.
React is pretty opinionated; it wants you to do things a certain way. There's a very good reason for that way too: Facebook arrived at that opinion after solving some serious real-world problems.
Vue seems to steer around any strong opinions. It feels like something that the W3C would have come up with, it feels like it belongs in a browser. You can use mostache-like templates (which approximate web components), or you can use JSX, or you can use no-frills raw JS (which really set it apart for something I was solving).
It is mostly aesthetic parameters. There are functional parameters, but you're in rare company if you care about them.
Vue embraces web technologies. JS is to enhance your HTML.
React is a javascript-first, FP-first mentality.
Minor point: vue benchmarks slightly faster these days. The react runtime has gotten pretty thick.
Vue itself is both smaller and more full featured than React. To make a working React you need to add a lot of parts (React DOM, CRA, Redux, React Router, CSS in JS…) which are often only semi-official, whereas Vue has solutions either built in or officially supported.
I honestly wouldn’t recommend React per se to anyone who has a choice, but it’s good to be familiar with it to get a sense of how the trends are moving, and they often have ideas that inspire (built in or officially supported) parts of Vue.
That said, a recent survey of /r/reactjs readers [0] showed 50% using plain JS, 48% TS, and only 2% using Flow . Given that the React ecosystem probably has the most Flow users, I'd say it's safe to describe Flow as dead.
From my viewpoint, TS has more than hit enough critical mass to survive for the long term:
- Microsoft is heavily invested in its ongoing development
- The Angular community requires use of TS
- Per that stat, it's reached solid adoption in the React community (see guides like the React+TS Cheatsheet [1])
- Where CoffeeScript introduced new syntax entirely, TS's focus on being a superset of standardized JS means that there's both less to worry about compat-wise _and_ it can be seen as a way to use new language features instead of Babel.
So, seems like it's going to be around for a while.
I wrote up my thoughts last year on my own experience learning and using TS from both an app dev and library maintainer's perspective [2].
[0] https://www.swyx.io/writing/react-survey-2019/
[1] https://github.com/typescript-cheatsheets/react-typescript-c...
[2] https://blog.isquaredsoftware.com/2019/11/blogged-answers-le...
On top of that, I think a lot of the momentum of a powerful type system for front-end development has moved (in the React world) towards Reason anyway. Between Typescript and Reason, we're spoiled for choice in building robust front-ends that stomp bugs early and often!
For anyone else, yeah, they should probably be using TypeScript in 2020.
It's not fair - Microsoft and co. have done a tremendous job with the implementation and documentation of Typescript. But the reality exists nonetheless.
TS is very, very close to being standard practice. It's already being used by over 50% of JS developers [0]. It doesn't have to be beginner/tooling friendly to be widespread.
[0]: https://2019.stateofjs.com/javascript-flavors/typescript/
*Depending on who you define as God, the creator of JS?
That doesn't mean everyone needs to use it.
The approach of using a compiler instead of a framework makes a lot of sense and I personally believe it's the best way forward.
I recommend watching the talk here; https://svelte.dev/blog/svelte-3-rethinking-reactivity
I've used Vue, React, Preact, Mithril, Inferno, Imba, and Angular for the past 6 years. I started doing front end in the late 90s btw.
I tried Svelte for a small project last year and liked it. A couple of weeks ago I evaluated it more seriously and decided to go with it for my current big project.
I was initially attracted to Svelte by the performance and small bundle sizes but was concerned about all the custom syntax, single file components, and the pragmatic magical approach. But oh boy after using it for a couple of days you become super productive really fast. I think this is actually its best feature.
It's essentially a similar tradeoff as in AOT vs JIT. Even though AOT brings the compilation step forward, JIT would have much more runtime context for better performance.
Reacts needs Suspense because it's quite slow and bloated in comparison.
See this video Rich Harris made when comparing a visualization use case:
I agree, I wish it wasn't an entire framework though and more of a front-end library like react. I've learnt long ago not to invest too much into a single tool.
Svelte can target web components, which allows you to use it in just a portion of a web page, just like react.
The first version jumped right in and solved an immediate problem. Even with the best foresight possible the designers simply could not see all the problems they would run into.
Or even if they did, sometimes pragmatism forced fixing issues down the road.
After doing this for over 20 years (I build software coders/designers/laymen use) I am really impressed with how well Vue was designed to start with, and the migration path (at a glance) looks nearly painless from v2 to v3.
Put method in data or prop? It actually works, but why would you do that when there is a field called `methods`?
The setup method seems like a slightly enhanced data() that allow you to place things in a more free way.
Although the benefits of the Composition API are clear-cut, the Options API is beloved by the community for its ease of use and clarity. For me personally, it will be hard to switch since I'm not a heavy user of mixins and I don't venture too far beyond simple components. However, I still need to learn the Composition API in more detail so I can make a more informed decision. Evan and the Vue team worked very hard on v3 and I trust them to make the right decisions.
what I found is the composition API is actually nicer to deal with not even considering mixins. Because things are grouped together you don't end up moving around your files so much so it ends up being quicker.
https://krausest.github.io/js-framework-benchmark/current.ht...
Yeah it's significantly faster and smaller than Vue 2.
[1] https://hn.algolia.com/?dateRange=all&page=0&prefix=false&qu...
[2] https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
> “Build a Hacker News Client with the Vue 3 Function-based component API, Vuex and vue-hooks by Coding Garden with CJ on Youtube (video)” [1]
No idea if that video is good but 146:0 liked it.
Edit: comment mentions that “Building of Hacker News Client starts at 33:18”
[1]: https://youtu.be/g9bSmxnx-O0?t=318 (starts at 5:18)