by shadowmint · 9y ago · 0 comments
Most people don't actually derive much benefit from writing custom UI widget primitives.
Certainly, that's a useful thing for a UI toolkit builder to be able to do, but tangibly, for most people, it's not actually useful.
I don't have time to invest hours implementing `ImageDropDownSpinner` as a custom element. <select> is good enough for me, and heck, maybe I'll use some 3rd party widget if I need something special.
That's not why react, vue, angular, etc. are winning the mind share of 'how to build web apps'; building UI widget is far less interesting than the ability to decompose your UI into a custom hierarchy of re-usable self contained units of functionality, that only at the lowest level actually involve UI components, is extremely powerful.
They might look like custom widgets, but <PageFoo> isn't a UI widget, it's your entire application; that's the difference.
It's easy to say this was a revolutionary idea, before its time, and it would have flown today instead of vanished into obscurity... but I think it missed the mark; it didn't solve problems people were actually having.
...but to be fair, it's easy to look at 'Web Component' efforts (like Polymer...) and go... yeah, this seems very familiar...
They are fully supported on Chrome and Safari, and hopefully Firefox and EDGE will eventually catch up with them.
And they have to, because Chrome and Safari own the mobile web.
Polymer is transitioning to being a thin layer on top of what the browsers support, which basically means a Polyfill for Firefox and Edge, and utility classes to make writing components easier.
Web Components is what is making me finally get to love web development again.
If it is to make an application platform out of browsers, then give me a platform, not an application for doing hypertext documents that we try to bend for something else.
Chrome settings panel, the new You Tube, all new EA gaming portals are already using Web Components.
I look forward to have something like Blend for Web Components.
https://www.youtube.com/watch?v=otcmcNY-3pk&t=17s
EDIT: fixed a few grammar issues
XHTML was "already there" too.
>They are fully supported on Chrome and Safari, and hopefully Firefox and EDGE will eventually catch up with them.
With React, Vue etc going strong, I don't see them going anywhere even after that. They solve less problems in a messier way.
It's much like JQuery. It was very much necessary when it came out in 2006. But then browsers got querySelectorAll, classList, uniform event handling, uniform dimensions, fetch, animations, transitions, data-attributes, and basically all the other functionality in JQuery.
The JQuery API is still more convenient in many cases, and several loyalists are still like "You'll pry JQuery out of my cold, dead fingers." But they build worse sites - for the same functionality, their sites are slower, take longer to load, and have more things that can go wrong. The market usually flushes such loyalists out eventually, and we may see a similar situation with React/Vue/Angular when components are standardized across browsers.
If that's the big benefit, then it will be increasingly irrelevant (assuming its not already), including on the mobile space.
Especially since those 132K (for React, Angular, and the like) are not "basic platform functionality" but give tons of things that Web Components do not.
I would like to see sources supporting these claims, please.
You can use custom elements in React and you can even use React in custom elements, so they are not designed to be competing technologies. Quite the opposite.
The component models are largely analogous. React and Vue could use custom elements if they chose to.
React, for instance, has changed a lot since its first release, mostly to do what devs need it to do with a bare minimum of coding on their part. That is in stark contrast to Polymer, which requires devs to write out a lot of the logic that you simply get "for free" with React. Writing a pure JS class that "just works" just because it has the two words "extends Component" is a hugely winning benefit, for example.
Take something like https://codelabs.developers.google.com/codelabs/polymer-firs... - it certainly does the job, the code is clean, and the separation of concern follows the traditional HTML/CSS/JS model. But as a developer, what I see is an inefficient implementation that requires me to put loads of stuff in that should be taken care of for me: "Why would you need to say what my component 'is'? Tooling should see that already.". Also, all browsers already handle arbitrary properties, so "Why would you need say which properties can be used, except for schema enforcement". (if I say <div cats="yes"> then every browser already sets that attribute key:value correctly). And of course: "Why would you need to specify which events to listen to instead of just implementing the relevant function hook? Tooling should take care of the rest".
So what I _want_ to write as a developer who's used to efficient web-component-like libraries is something like:
import { register, Component } from 'polymer' register('icon-toggle', class IconToggle extends Component { onAttributeChange(attr) { if (attr.name === 'toggleIcon') { ... } } onPressed(evt) { this.pressed = !this.pressed; } });
And we're done, that should tell the library everything it needs to know.
It really is just a matter of "what lets me do the most while saying the least". Polymer requires me to write a book where React or Vue let me write a memo. Does it make it harder for a search engine to index my site? Sure. But that's what seo/og is for. Does it make it harder for a user to inspect-element? Sure, but that's their problem, not mine. Does it make it harder for someone else to learn how I did something if I don't host the code on github or something? Sure, but I am under no obligation to write code that, in production, is easy to debug and replicate.
So while Polymer is super strong for all of those, realistically: I only care at the academic level, because that's not where my time and efforts lie.
No. Polymer is here. As Rob Dodson said, "Polymer is the jQuery of WebComponents".
No one in their right mind would even think about writing and using WebComponents in vanilla JS.
Hence we're coming back to the problem with WebComponents: they are a solution in search of a problem.
Why not? I have written a complete widget toolkit [1] this way. With vanilla APIs the code is a bit more verbose and repetitive, but in turn you get more options for speed optimization and fine-tuning.
As for optimization, vanilla won't be faster than a framework unless you write one from scratch. That means having a scheduler in place that orders dom read/writes, pooled events listening from a single source (the main document), a prioritizer that can cull, something that diffs state in order to render the minimal set of components, etc. Many don't realize the effort that goes into these libs to render as efficient as possible. Even if some stuff is baked into the browser, the field is moving so fast that we get higher benefits from community driven optimizations. And that is an understatement if you look at things like React Fiber.
Exactly. Just the code for syncing attributes and properties is enough to never ever use vanilla JS for WCs
I'd love to see that problem statement written anywhere in any of the webcomponent-related specs or sites.
If it were true, they would not have such cumbersome APIs, for example.
On the contrary, WebComponents, as they turn out to be, realise next to none of their original goals: https://fronteers.nl/congres/2011/sessions/web-components-an...
> but react seeks to provide more structure and functionality to the foundation of web components.
React has nothing to do with web components. Until less than a year ago React team was set against WebComponents in any shape or form: https://docs.google.com/document/d/1QZxArgMwidgCrAbuSikcB2iB...
What React was, and is, is a library with a specific goal that solved a specific problem, and it's basically this: "Build encapsulated components that manage their own state, then compose them to make complex UIs."
No one really knows what WebComponents are, and what problems they solve. I know what Polymer is and what it attempts to solve though.
How about x-tag, a competing WP framework from Mozilla/Microsoft? I don't see any any mention of that.
If you go to webcomponents.org, you'll see that the overwhelming majority of components there are Polymer components.
I remember implementing an "<iron-ajax>" tag, and thinking that this is so wild and "Out There" that I may simply never understand.
Annoyingly, there is a whole "Hybrid" mode as well. So there is no distinction between V1 and V2. If you are confused,you go to the docs, they aren't giving you what you need, so you go to one of the sample elements, and it is written in V1. So you have to read the migration guide to translate what is actually happening....
Then Polymer Summit happens, and now it is all JS based which, is far better for me but now it seems pointless to stay on Polymer 2.0, and Polymer 3 is a preview with no docs...
So I aborted this path, went to Angular and to be honest, it is beautiful. It is almost trivial compared to the bag of questions and confusion I had going on with Polymer.
I do look forward to going back there though when 3.0 is available.
Polymer of all the frameworks i've had to use has had the most breaking changes. That they're turning the ship for each and every major forcing you to rewrite the entire application is kind of ironic given that their motto is "use the platform" as if suggesting stability and standard behavior.
Polymer is not the standard, just another arbitrary driver (as in: their own syntax, their own structures, their own api) for a pretty harmless spec that sets out to solve issues we haven't faced for at least 5 years.
The actual issue was that very few people was doing any serious frontend development back then. Netscape and IE had completely different DOMs and the environments were not super stable. But there was an attitude that frontend was for designers and "real programmers" were backend-only.
So the real programmer found a backend component for ASP.NET or GWT and wasn't interested in the frontend sausage.
(This article reminded me of the DHTML Dude column[1], and yeah some of us unreal programmers were doing this bleeding edge IE-specific front-end stuff for clients. Then we spent many years atoning for our sins. However, I think 90% of "IE-only" apps never used this stuff, they just had the wrong box model or some dopey ActiveX upload component or something.)
[1] https://msdn.microsoft.com/en-us/library/bb263969(v=vs.85).a...
I guess it's ultimately about how web development is actually two things: web pages (posters) and web apps ("software")
Maybe when you're working on some one-off pages you don't feel much need for encapsulation, and in the end it's more trouble than it's worth.
Let's say you are working on a social network though. You'll need to display a "person widget" a bunch, in different contexts. Of course you want to have it be consistent throughout your app. Of course you want it to look the same. Of course you want encapsulation!
When you're writing a web app, your HTML isn't just layout but the entire interface. You're usually working with a huge team and need consistency. You want to be DRY.
If you have a style guide, you probably could benefit some from this. The proof is that things like JQuery UI exist, even if it's activated more through JS.
HTML is basically unreadable in so many cases because you can't encapsulate layout code into widgets. Having these tools lets you stay a bit sane when you need to build out a lot of workflows in a consistent manner.
This is what Progress Web Application tries[0](PWA https://en.wikipedia.org/wiki/Progressive_web_app), a fairly new spec, attempts to bridge the gap. Basically a normally web page will virtually be indistinguishable from a web app.
I think jQuery's massive success was precisely because it was a simple and concise API on top of the verbose and confusing DOM API.
Bingo. Most won't and shouldn't. There's a different between building casual widgets for personal vs for business production use. jQuery UI got some widely popular components such as Select2 and jqGrid, Datatables etc. They will never be developed by non-developers or business users. The tool should be really reserved for code crafters.
Imagining those crafters started creating tools with WP that are modular and self-cotained, work across whatever browsers threw at them.
* It's cumbersome to install. apt-get install npm && npm install bower && bower install ... this is about when I give up. Why not just include a 'polymer.js' file that just does all the work, no installs needed, no questions asked, CDN provided, batteries included, like every other client-side JavaScript library on the planet? Even the appropriate CSS can be loaded by the JavaScript itself, but it isn't.
* Bloated. You end up downloading several hundred kilobytes of JavaScript if your webapp uses more than a few different types of UI elements.
* Polymer components don't behave like native components. For example, you cannot swipe between tabs like a ViewPager does on Android. Implementing any kind of swipe-based feedback is hard, including pull-to-refresh. Back to native programming, I guess.
* For having so much marketing and PR and a camel-cased name "WebComponents", you would think it would be productized enough that it employ the appropriate native Android elements at least in Google Chrome on Android, and use the HTML5 substitutes on iOS and desktop. For example, you should replace the Polymer button with an actual styled Android button instead of a nested div hell. Chrome should have worked with the Polymer team on this. Not doing this has serious performance implications when you display thousands of items (e.g. lists of results, contact lists) each with their own nested div hell. Back to native programming, I guess.
* There is no framework to make apps look iOSish on iOS and Androidish on Android. Back to native programming, I guess.
A quick CDN get-started would be convenient I agree. There is Polymer-CDN for demos/code-pens: https://github.com/download/polymer-cdn
The 'native' stuff in your comment I don't agree with. You want browsers to start implementing native Android ListViews/Buttons etc? Browsers have a hard enough time implementing web standards.
Google's Flutter certainly creates apps (using mostly web technologies) that have the correct look and feel for Android and iOS from the same codebase.
Keynote: Flutter (Dart Developer Summit 2016)»https://www.youtube.com/watch?v=Mx-AllVZ1VY
Half the things I've ever installed were far more complicated than that.
Smaller scale but for fun, in vanilla WebComponents (as implemented in Chrome) I put together a Slider that can then accept and consume child elements that add behaviour, like this:
<x-slider data-config="{autoplay:true}">
<img src="some.jpg" />
<img src="some.jpg" />
<x-slider-controls /> //Introduces left and right slider controls
<x-slider-dots /> //Introduces slider dots
</x-slider>One of the very real issues WebComponents solve is encapsulating the component functionality and styling away from everything else in a typical web page; you know, the basic separation of concerns stuff.
Certainly nothing that Microsoft proposed then has today's comparability and flexibility of today's offerings.
Microsoft didn't lack good ideas back then when they cared about the web; they were clueless about interoperability across devices and platforms. (IE for the Mac had a better but different rendering engine than IE for Windows did.) And because of their monopoly status then, they weren't to be trusted.
I also want to correct something the article mentioned, that Netscape was irrelevant back then due to Microsoft's cool features--not true. In fact, on any big project, developers had to essentially make two sites--one for Netscape users and one for IE users.
The "new" Microsoft it much better with getting their ideas out and working with other companies.
I'm specifically criticising the focus polymer has on creating user interaction elements.
My point is that this sort of low level functionality isn't the right place to focus; most low level components you need already exist. What people is a way to build robust application UIs (and yeah, that includes having a root level <App/> component).
For comparison, read:
https://www.polymer-project.org/2.0/start/
'build custom ui widgets' <-- wrong, this isn't a problem most people have.
vs.
https://vuejs.org/v2/guide/#Composing-with-Components
'build your application from components' <-- right.
If it just was fully styleable. Browsers really should implement better selection of customizable standard widgets. Currently it requires too many hacks to re-style the built-in input elements. Web components feel a bit overkill for most cases.
Accessibility is one reason why css-themeable native widgets would be a win for everyone, their look will match with the branding (customer happy) and behaviour will be consistent (end user happy), and standardization would make developers happy.