33

The question is in regard to AngularJS, BackboneJS, EmberJS and the other frameworks.

I have to translate a project from php to javascript and I have to decide, if I am going to use:

  1. AngularJS
  2. Polymer
  3. A combination of them

I prefer using Polymer, because I like it.

Yet, I am missing (and correct me where I am wrong) the ability to make:

  1. Views and link between them (like in Angualar)
  2. Controllers

I know that the structure is up to me, on how to build my application, but it seems that angularjs has a well predefined structure for building mvc-applications.

Therefore I want to know: Is Polymer a substitute for Angular, if you want to build a well structured web application or is Polymer complementary library to be used along other existing frameworks?

EDIT 21.09.2014 No one really answered the question to my fullest satisfaction, therefore I marked it as not answered yet. Many say it just "DEPENDS". But no one is able to elaborate, on what exactly it depends.

On the complexity of the application? On the needs of the application? For what needs does Polymer fit and for which doesn't it fit? These are the answers I was looking for.

Some say it can be used as a frontend framework. Others say that is just a library and others say "Yes and No". Unfortunately rather confusing answers.

I wish there was an official answer to this, but I let you in on what my feeling is. I believe it is a substitute, but Polymer hasn't yet reached the structure, that other frameworks require to work. Maybe this is intentional, maybe it is just a matter of unreached maturity, because the framework is new.

I hope that the creators will explain, when it is best to use AngularJS and when should someone use Polymer for building large scalable web applications.

EDIT 15.08.2015

Polymer 1.0 is out. And it turns out Polymer is officially NOT a framework and is supposed to work in a complentary way with other frontend frameworks. https://youtu.be/fD2As5RmM8Q?t=6m42s

LoveAndHappiness
  • 9,735
  • 21
  • 72
  • 106
  • 2
    I would say that this is somewhat opinion based. I'd suggest to use polymer only, and if you stumble over any inconveniences regarding structure, you can easily add Angular to your project, too. Would love to hear about your progress; I am definetely checking out polymer, too! – Wottensprels Sep 16 '14 at 11:34
  • 2
    Regarding the edit, what are you looking for that is missing? Many frameworks existed because the native DOM was missing so much. With web components the DOM becomes the framework. Polymer is a library adds things like declarative data binding and event mapping. – Erik Ringsmuth Sep 25 '14 at 22:50
  • Polymer just went 1.0 at the Google I/O conference, so it is now "ready" according to Google. – RationalDev likes GoFundMonica Jun 04 '15 at 10:15
  • This is a major headache for angular teams. – SuperUberDuper Jun 29 '15 at 21:07
  • 1
    Surprise. It seems that a new group of elements (Carbon) will be introduced. Group that will provide solution for layouts, routes and etc. I guess it will be more like a library on steroids. https://youtu.be/jVn8tlnwAEs?t=20m12s – michaelbn Nov 18 '15 at 13:46

6 Answers6

10

IMHO both are two different things and they both are to serve two different purposes. Though they have some common features to offer, data-binding can be one of them.

Polymer

If you truly want to use the Awesome Webcomponents, Polymer is one way to achieve that. There are other options like you can go with your vanilla JS, or use other libraries like X-Tag from Mozilla or Bosonic. These libraries polyfill the webcomponent features which are still in drafted state. So, these libs help us have/provide the same user experience across browsers even where there is no native support for the webcomponents.

Angular

This is a full fledged MVC framework. And people here know what Angular as an MVC framework includes/provides.

That all said to answer your question

Google's Polymer is not exactly a fully functioning Frontend Framework and can be used as a Subsitute OR Complement to other Frontend Frameworks. It can be used as a substitution for the V part in Angular as MVC. Like people use React as V in different frameworks. It is not much a different case for me. Being more specific in case of Angular, Polymer is like directives in Angular 1.x while like components in upcoming Angular 2.x.


References

To be more sure of what I am talking about and for additional sources on how to use the Polymer with Angular2 (Angular2 not released to this date)

So, in my view these two projects are not competing each other.


Webcomponent Specs

The webcomponent specs are here for one's reference

I just wish the webcomponents are native to the evergreen browsers ASAP.

Marc-André Lafortune
  • 78,216
  • 16
  • 166
  • 166
dopeddude
  • 4,943
  • 3
  • 33
  • 41
5

From the Polymer Starter Kit: "Framework-free, or framework-compatible Build your app out of elements, or wire in an external framework to handle business logic. It's up to you!"

Update: What was described as Carbon Elements seems to fall under:

Polymer(version 2) App Toolbox

  • Component-based architecture using Polymer and web components.
  • Responsive design using the app layout components.
  • Modular routing using the elements.
  • Localization with <app-localize-behavior>.
  • Turnkey support for local storage with app storage elements.
  • Offline caching as a progressive enhancement, using service workers.
  • Build tooling to support serving your app multiple ways: unbundled for delivery over HTTP/2 with server push, and bundled for delivery over HTTP/1.

Carbon Elements adding framework features

During The Polymer Summit 2015 Keynote, Google announced a new "Polymer idiomatic and framework oriented" set of elements, tentatively named the Carbon elements.

Some quotes from the longer tjsavage answer regarding Angular 2 vs Polymer Carbon: "The trick is in thinking about the web platform as an application framework... Polymer the library is to the web components component model as the carbon elements will be to using the web platform itself as an application framework: the opinionated rails to make it easier to understand and achieve."

"Angular 2 will provide one way of structuring your application that uses Angular's view of what makes a good application structure. The carbon elements will provide a different way of structuring your application that more directly uses what the web platform itself provides as its structural underpinning."

Mehdi Raash
  • 8,721
  • 2
  • 29
  • 42
3

Polymer is almost fully functional. Currently it is missing routing for example but this doesn't mean you can't do this with Polymer.

There is now https://elements.polymer-project.org/elements/app-route

In Dart also dependency injection works fine with Polymer because of the types. If it's possible in Dart, it's possible in JS as well because Dart transpiles to JS. DI in plain JS might be more cumbersome though.

In this package (Dart) https://github.com/bwu-dart/bwu_polymer_routing I made the routing and DI packages used by Angular.dart available for Polymer. There are also routing packages for Polymer.js available.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • So in my specific case. When trying to translate a php-application. Would you recommend doing it with angularjs, polymer or a combination of two? – LoveAndHappiness Sep 16 '14 at 21:36
  • 1
    I would try to avoid a combination. Go either with Angular or Polymer. – Günter Zöchbauer Sep 17 '14 at 04:55
  • Using Polymer elements in Angular2 is working fine with some restrictions that hopefully will be ironed out in Angular2 eventually or when web components (shadow DOM) better supported natively by all browsers. – Günter Zöchbauer Jun 09 '16 at 17:56
2

I put together some router demos. The "missing parts" really depend on what type of application you're building.

https://github.com/erikringsmuth/polymer-router-demos

Erik Ringsmuth
  • 1,083
  • 9
  • 8
  • So you're saying, if it weren't for the routing, you would say, that polymer is a "good" frontend framework to build a project on. I personally don't need routing anyway, because I handle them by the backend. – LoveAndHappiness Sep 16 '14 at 16:42
  • 1
    I'd say it doesn't even fall under the framework category. Frameworks try to do everything (views, controllers, models, routing, etc.). Polymer is simply a library that does custom elements very well. That said, you can build anything a JS framework can build with custom elements. Custom elements are the future and Polymer is the best library to build custom elements with IMO. – Erik Ringsmuth Sep 16 '14 at 17:37
  • So you are saying, that polymer is there to complement a framework like angular, instead of replacing it. – LoveAndHappiness Sep 16 '14 at 22:38
  • 1
    Polymer is about custom elements but you can build custom elements that do (almost?) all things other frameworks do. – Günter Zöchbauer Sep 17 '14 at 04:55
  • 1
    MVC -> Custom Elements (native or Polymer); Templating / data binding -> – Erik Ringsmuth Sep 17 '14 at 13:48
  • 1
    With all these pieces you can build anything a framework can build. Polymer isn't so much complementing a framework as it's complementing the native DOM Web Components spec. That said, you can use it with a framework like Angular. There really aren't any rules. You can use it to any extent you want. – Erik Ringsmuth Sep 17 '14 at 13:52
2

I've used it as both, as an enhancement to an app written in another framework, and as the full framework itself, where it was responsible for every element on the page.

I really like just about everything about Polymer, so I've been very happy using it for the whole app, even built my own router. If you've got an existing app I'd recommend dipping your toe in the water, as Polymer works great composed into other apps to see if it's to your liking.

Peter Burns
  • 44,401
  • 7
  • 38
  • 56
1

Let me give this another try:

The key behind web-components (and thus Polymer) is, that they are self-contained. You have a web-component somewhere, you import it, and (if you're lucky) it just works, wherever it comes from. The web-component will NOT interfere other components. So doing things like MVC is not Polymers business (although it provides a data-binding mechanism), as this belongs to the process of tying things together. It is considered to be best practice that these kind of things are solved by creating new elements too, that create and react to events. When it comes to the model you code non-visual web-components, that don't have/need a template. TodoMVC has an (outdated) example for that (https://github.com/tastejs/todomvc/tree/gh-pages/examples/polymer).

So Angular gives you a path to follow on how to do MVVM, whereas it is up to you on how to do the "logic" in your app when using Polymer. IMHO Angular is for more complex and rather enclosed apps, whereas Polymer is for any kind of app, that embraces the web. You even can use Polymer, if you're not writing an app at all ;)

st_efan
  • 90
  • 7