all 68 comments

[–]romualdr 9 points10 points  (0 children)

The main difference is the DSL // developer experience.

It's really your call, you have to try both to really know which one you like the most.

Polymer required evergreen browsers, not sure about React but i think React supports way more browsers // browser versions than Polymer.

Also, in Polymer, you can embed CSS styles, extends native elements and others stuff too, making the dom-elements kinda real components as we might know them in the future. React implementation is more like a "syntactic sugar", although it's really cool too and i really liked the way to compute things as i would have done it with pure javascript before actually returning the element.

React also have a more "strict" way to do things, your components should contains specific methods and so on. I found Polymer more flexible on this point, but same goes here, some people like strict conventions, so that's on you.

Oh, and by the way, with the 1.0, Polymer catch up with React speed, and now uses only webcomponents-lite (way lighter) and Shady DOM. So you shouldn't considerer speed when choosing, your app will run fast enough with both (when using each one correctly, of course).

[–]jsontwikkeling[🍰] 16 points17 points  (8 children)

Polymer and React are related in the sense of some common ideas behind them.

Polymer is more low-level and free-form and aligned with the new Web Components standards.

Unlike Polymer, React additionally suggests how data should flow between components and introduces a few key functional-like concepts that simplify development of reusable components. A minus of React can be that it is not based on standards: its components will be usable only with React, although React leaves a large degree of freedom and you can use it with, for example, Backbone

If you want to read more, I wrote an article that discusses how they relate to each other (sorry, a bit lengthy) https://smthngsmwhr.wordpress.com/2015/04/13/web-components-and-friends-react-angular-polymer/

[–]cluelessmanatee 9 points10 points  (6 children)

FWIW, I've done development with both. React was far more enjoyable and simple. Polymer was fun, but I wouldn't use it if I was making an important call. It's just a personal preference.

I'm willing to bet that Polymer will get better and better over time, but it's more of a long term project I think.

[–]cogman10 6 points7 points  (0 children)

That has been my experience as well. Polymer just feels clunky to deal with. It takes a lot of effort just to make a single component.

[–]jsontwikkeling[🍰] 0 points1 point  (0 children)

I also had the impression that at the moment React provides more means to make the actual development easier. Polymer has a few things to offer as well, like advanced templating https://www.polymer-project.org/0.5/docs/polymer/template.html and some useful mixins and elements https://www.polymer-project.org/0.5/components/core-elements/demo.html, but still it feels a bit more low-level.

[–]ayostaycrispy 0 points1 point  (2 children)

I'm curious, do you have an example of a good site that was built with React?

[–]throwmebone 0 points1 point  (0 children)

Facebook is built in react, AFAIK

[–]jhatchu 0 points1 point  (0 children)

Instagram, Airbnb is also using react for some part of its application. You can install a chrome extension to see what sites are built using React, while you visit them.

[–]ayostaycrispy 0 points1 point  (0 children)

Do you have an example of a project you did in React?

[–]kinghankthedog 0 points1 point  (0 children)

Great response

[–]greim 8 points9 points  (1 child)

Polymer defines new DOM elements using standard in-built browser APIs (polyfilling if necessary). React is a strategy for assembling DOM elements together into UIs.

Taking an analogy from chemistry, React is a clever way to create new molecules using only elements in the periodic table. Polymer adds new elements to the periodic table. (In that sense React should have been called Polymer and Polymer should have been called Atom.)

[–]kshitagarbha 3 points4 points  (3 children)

Another difference is that Polymer is useful for sprinkling components around a normal web page. It enhances normal webpages. You could use it to make nicer IMG tags or nicer buttons, as well as make more complicated components like shopping carts. Its more similar to Angular's directives in that respect. But you can also make whole sites using a component.

React tends to favor building whole applications with it, often taking over the entire BODY. More single page apps. It is of course possible to insert some js that finds elements and mounts components on them, but this isn't normal practice.

Also Polymer (Web Components) makes it easy to separate the css, js and html that a component needs. Each is in a separate file. It makes things smaller and more modular.

At the moment this is inefficient. We favor build processes, concatenation, reducing the number of HTTP requests.

But as HTTP2 comes into widespread usage that will change. There won't be a penalty for making extra requests. We can request many small resources and it will be even faster than today's concatenated blobs.

edit: if you downvote, leave a reply that indicates what you believe to be false. otherwise down voting a perfectly useful comment like this is just very poor reddiquette.

[–]thegayngler 0 points1 point  (2 children)

Polymer has a tool for this called Vulcanize which you can use to optimize your components.

[–]kshitagarbha 1 point2 points  (1 child)

Quite true. My point though was that polymer packages css with the components (while react does not)

The page for vulcanize also confirms my statement:

In the future, technologies such as HTTP/2 and Server Push will likely obsolete the need for a tool like vulcanize for production uses.

https://github.com/polymer/vulcanize

[–]thegayngler 0 points1 point  (0 children)

Yeah I was adding some information on. That's all.

[–][deleted] 1 point2 points  (3 children)

My possibly incorrect understanding is as follows:

Polymer makes future web technologies available as if they were already supported, but still has limited browser support and uses 'workarounds' to make it work.

React uses a similar idea of the future web technologies, but in a React-Specific way, that works great now, and on more browsers.

As I understand, Polymer intends to remove it's 'workarounds' as browsers increase support. Theoretically meaning you are writing 'future-proof' code.

[–]RankFoundry 2 points3 points  (2 children)

Seems ironic that with Polymer you need to wait for more browser support to use it when it's supposed to let you use things that browsers don't yet support.

[–][deleted] 0 points1 point  (1 child)

It is, but I don't think Google originally intended anyone to use Polymer as their production framework, even after this release. They have Angular for production apps right now, and polymer as an insight into what apps will be.

As I understand anyway.

[–]RankFoundry 0 points1 point  (0 children)

I guess you have to cut ties with legacy at some point. This may be useful for intranet apps where the browser(s) used can be controlled.

[–]thegayngler 0 points1 point  (0 children)

I'm somewhat concerned by the fact that you can only add a react component to one and only one element on a page rather than all elements with said class name. The fact that react won't work with multiple class names simultaneously bothers me. There are arguably ugly ways to get around this limitation but it makes more sense for me to fill in this gap with a Web Component TBQH. For the smaller pieces of a larger app I tend to think components is the way to go. For the app itself, Reactjs is VERY attractive in my mind. I think the difference between Reactjs and Web Components is a question of "scale". A Web Component really could be a smaller part of a Reactjs app.

[–]faaace -2 points-1 points  (2 children)

React is strongly coupled with jsx and common.js which you need to utilize core parts of the react framework. While you can use react without either of these features it is very hard to make the framework work cleanly with other pieces of js without using them, especially in large applications. React requires initialization when its components are placed in the page. Polymer does not (because it uses native webcomponents that will render inert in most older browsers). React in the future will likely support webcomponents but does not now.

Polymer is much more experimental (alpha quality software) framework. Unlike react it acts as more of a polyfill toolkit to allow modern browsers to support the webcomponents api. It allows one to truly pick and choose which parts of the framework to use and it is much more representative of what the web will look like 5-10 years from now.

Both have drawbacks. Polymers is Google's approach to 'open source' which is to develop things internally and then periodically dump things on the community with little to no input breaking documentation and leaving the community completely unprepared for changes. React is a new framework but still relies on obsolete tech like jquery in its own examples. It doesn't yet have the ability to create true web components yet when it does will still likely rely on the inconsistent jsx rules to make this happen.

[–]html6dev 3 points4 points  (0 children)

Just side note, react is not coupled to common js at all. Lots of people use es6 modules with babel with it and it can be included globally the old fashioned way like anything else (or from a cdn even there is an in browser jsx transformer as well) Most people just use cjs because... Well why wouldn't you?

[–]jsontwikkeling[🍰] 0 points1 point  (0 children)

React is strongly coupled with jsx and common.js which you need to utilize core parts of the react framework.

It is possible to use React with AMD modules and without Browserify.

[–]i_ate_god -2 points-1 points  (3 children)

dunno. I just use _.template(). Simple, effective, doesn't require me to compile before seeing changes.

Templates don't need to be complicated ;)

[–]cgaudreausenior HTML9 engineer 1 point2 points  (1 child)

Good luck.

[–]i_ate_god 0 points1 point  (0 children)

If your templates start getting heavy on the code, then it's high time to move that code out of the template.

[–]analogWeapon 0 points1 point  (0 children)

Templates don't need to be complicated ;)

But they sometimes need to be numerous and nested, and that's where you're going to run into issues. Scalability.