Общо показвания

юли 16, 2014

Polymer vs. Dart polymer (and a bit of Chrome Dev Editor)

It is no secret that I am a fan of Dart. Having used it for more than few projects already it had speed up my work flow tremendously. It was only natural to check out the new core and paper elements from Google after the demos and talks from Google I/O 2014.

The problem one faces with that is the complexity of the work flow one suddenly has to manage. It's no fun at all, opposite of what I was expecting after working with Dart for several months.

I have to include the html via import, but then again I have to include the dart files of those imports in the dart file of the polymer element. Ahem... I have to use those strange annotations (CustomTag for example). Hum... I was a bit confused and knowing it all will boil down to HTML and JavaScript anyway I decided to give it a try in JavaScript.

What a surprise it was! All of a sudden I did not have to think about annotations and I could work in the same file for my whole component. I could actually understand what was going on and how it all will work out in the browser.

For testing I also used Chrome Dev Editor (needs more polishing by the way and it needs to be faster, with multiple open tabs I could see very clearly delay when switching between the tabs and opening files, creating new file/directory does not put the focus in the input, pressing Enter does not trigger the creation and so on, lack of polishing describes it very well). On the surface it does not provide much more than any other editor. It uses ACE internally and does not provide alternative color schemes at this time. It has few settings, but it has features no other editor I have seen (especially for ChromeOS). One of those is clone from GitHub which is awesome! Another one is Deploy to Mobile! Makes it ultra easy to work on your Chromebook and just attach your phone to test. Combined with the debug and dev tools in Chrome itself it makes for a cool, well integrated development environment.

I have built a whole mobile web app in under a day. It has what a robust modern development platform has: well built universal UI controls (tabs, lists, checkboxes, switches, buttons etc) that are easy to understand and use. For the first time in a very long period I had what other (read non-web) developers have had in years - I could use stable and reliable UI components and write only application logic. And that is what I did - I had to only write the parsing logic for the server responses (because it speak no json). Data bindings are awesome and declarative event handlers are double awesome!

Now back to Dart. I happen to miss the editor's understanding of my code. I had to rename a variable and it was a pain!!! I am so much used to the IDE handling this for me as well as omitting the 'this' keyword that I actually had few bugs related to not using 'this' where I should have.

But as a whole I do not see any advantages of using Dart over pure HTML/JS when creating simple polymer elements. Maybe it would be helpful if the element's logic is much more complex (actually I bet it would help in this case), but the cumbersome way of making elements in Dart should really improve IMO.

I have showed the workflow to my colleagues and after some initial resistance (because of the somewhat more complex css selectors for the styling) all agreed that working this way is faster and much more pleasant. This means a win for polymer in my opinion.

Finally I want to address the ranting from some individuals about the fact that Google pushes polymer so hard that it sounds like polymer is what a web components are. The fact is that polymer provides a declarative way to create web components. This makes the creation of a new component so much easy to understand and faster! For a lot of developers JavaScript is jQuery as well, does it mean that we should rant against it (as often as I do!). No, it only means that there will always be those who have better and deeper understanding of the platform and its features and those who just want to use the free way and get there faster using any tool available. I would not go and write custom component using JavaScript to access the shadow root and set its inner HTML - this is insanity! On the other hand I could write a template and declare my bindings. So to those people I want to say: whatever floats your boat, but stop attacking Google for being too loud about their accomplishments. All companies do that. Apple released a feature that was there for Linux and Windows a decade ago and still they have the nerve to say that it was a great innovation. Why not rant about that?
Публикуване на коментар