Live data from Hacker News

Vue.js vs. React

vuejs.org

331–340 of 486 posts

Re: Vue.js vs. React

#331
post #232
post #203

Earlier quoted context omitted.

I'm not sure I follow. To use the basic example from the link, as opposed to this: const listItems = numbers.map((number) => {number} ); return ( {listItems} ); What's wrong with looping this way?: return ( {numbers.map((num, i) => {num} )} )

> What's wrong with looping this way? The problem IMO is that it's harder to read and write than: {{num}} That's Vue's syntax, but any other templating language is more readable to me than JSX.

How does this actually work? When I see JS-esque code passed as a string I get a little queasy. Is this "eval"-ed so I can use real JS there? Or is there some Vue parser that reads this little mini language and interprets it? What is `listItem` exactly, and how does that template have access to the data represented by it?

When I'm trying to digest a bit of code, the superficial representation of what's present on the page is only half the battle - I also like to understand what it's doing under the hood. For me, then, JSX is way easier to grok than this bit of code, since I have a mental model of how JS works, and JSX is just a very small serving of syntactic sugar to compile an HTML like template into native JS. I know the transformations that are happening, and I can envision the code that it's being transformed into.

Re: Vue.js vs. React

#333

Maybe a bit off-topic, but not so much IMO. Everyone talks about react, angular and vue.js. How about Polymer? What are your experiences with it, if any? I'm no expert in either technology, but Polymer seems much more lean, needs no build process as far as I know, and is quite flexible. Why wouldn't it be an option to replace react/angular/vue? Any thoughts?

It is an option to replace other frameworks - I've built an SPA with it, it was very clean and natural feeling to me.

Building Polymer components is very similar to building Angualar 1.5 `component()`s or react components (or actually any component system for that matter).

New elements are true DOM nodes which is quite an advantage in my opinion.

You can add redux/uniflow on top of that or some vdom lib like preact too if you need that - I wonder what will come out of `lit-html` that is supposed to be vdom alternative.

One interesting thing one should understand that applications view components that are not meant to reusable should NOT use Shadow DOM (just regular DOM)- this way you can use bootstrap or whatever else to provide "traditional" styling of your application.

BTW I think right now Polymer also requires a build process - because 2.0 is written in ES6 so that means building to support older browsers like IE10/11.

Re: Vue.js vs. React

#334
post #324

Earlier quoted context omitted.

To be fair, JSX has its own idiosyncracies too for templating, such as className, htmlFor, and the obnoxious attribute name for dynamically inserted html. It is not immune to the criticism that it requires learning.

Those names have nothing to do with JSX or React, they're the actual properties you're setting. JS properties don't map 1:1 to HTML attributes: while for example the "src" attribute is controlled using the "src" property, the "for" attribute is controlled using the "htmlFor" property, and the "class" attribute with the "className" property. All React is doing is setting the properties you tell it to. (The reason for…

I agree. Those examples have nothing to do with learning a new template syntax, it's simply the API of React.Component.

Granted, there is still some syntax you need to learn for JSX, but it's very little. If you already know HTML's syntax, the only new things I can think of are the curly braces for using JS expressions as prop values (you also need to know what a JS expression is, lest you try to use an if statement), and spread attributes.

Re: Vue.js vs. React

#335

I used React for a few years and it was great and powerful, there were many things however that I disliked.. Particularly I was not a fan of JSX. I liked React but I did not feel comfortable using it. When I first saw VueJS I had a hard time understanding how it would be any better than React, that is until I saw single file components. https://vuejs.org/images/vue-component.png I fell in love with the eloquence of b…

> I used React for a few years and it was great and powerful, there were many things however that I disliked.. Particularly I was not a fan of JSX. JSX is no more than sugar for vdom function calls. You can use React without JSX, and you can use Vue with JSX. > When I first saw VueJS I had a hard time understanding how it would be any better than React, that is until I saw single file components. > I fell in love wit…

Everytime the discussion of React vs. VueJS comes out, there are always people that make the argument that you can make React do everything VueJS can.

Of course you can, these are open sourced projects and you can modify and add packages to do just about anything you want it to do.

However, when presented with an option that is designed from the ground up to work exactly the way you like it, why not use it?

I can install a dozen different packages along with React so that I can get it set up exactly how I want, or I can just use VueJS whose creator's philosophy are more inline with my own and is designed exactly how I like my front-end.

Re: Vue.js vs. React

#336
post #64

Earlier quoted context omitted.

From the charts, it shows that Vue from 2016 to now well over doubled it's downloads (over 100% growth) while react's only grew by 50%. It can be deceptive when you look at charts that list totals when what you're concerned with is growth rate.

So from 2016 to 2017, React's market share grew from 74.6% to 74.9% while Vue's market share grew from 5.4% to 9.3%. A more accurate narrative would be that Vue is eating the dying Angular.

If you only look at Vue and React, you can see that there is an increase in Vue's share on the weekends.

That may not be a true leading indicator of adoption, but it is hard to argue it isn't an indicator of increased interest.

Re: Vue.js vs. React

#337
post #277

Earlier quoted context omitted.

1. The MobX-like functionality is moreso simply a native feature of Vue. All data values are converted into observed values. A render is triggered by changes to data. I believe Evan himself basically said React + MobX = Vue. Using a render function was just a choice. It could just as easily have been written with a template. 2. Again, this was basically just a choice for the example. The spinner could be defined in a…

Ok I think I figured out how to use a template with a slot in the spinner component: {{this.error}} Then in the template the option line becomes {{option}} Not too bad. Guess I'll have to come up with a new example of what Vue templates can't do now!

I wonder if the JS snippets in those attributes is syntax checked at build time or run time.

Re: Vue.js vs. React

#338

Vue.js is going to win because simplicity and easier bootstrapping matter. In the same time Vue.js is powerful enough for building the complex and scalable apps.

Onboarding green devs into anything more than a simple Vue app is a lot more complex than a React app of similar complexity, from my experience.

The simplicity of the nested, inception style architecture of React makes it super easy to onboard and up-ramp.

Re: Vue.js vs. React

#340
post #46

You'll see quotes in this thread like "The demand for both React and Vue.js is growing tremendously" thrown around. It's good to check out npm install stats to get an unopinionated comparison. https://npm-stat.com/charts.html?package=react&package=vue&p... In reality, React is downloaded roughly 4-5x more than angular and 7-8x more than Vue. In August so far, React has 75% market share among these three libs. Interes…

Note this chart is actually showing AngularJS (1.x) only. NPM only started exposing stats for @scoped packages recently, so @angular/core (Angular 2+) only has a few months of history.

See https://npm-stat.com/charts.html?package=react&package=vue&p...

Post reply on HN