5 ms·
> Javascript > you complain about objects > don't magically solve > raw WCs vs helpers etc. etc. etc. And then you wonder why I'm so set against WebComponents
by dmitriid 9y ago
> Javascript
> you complain about objects
> don't magically solve
> raw WCs vs helpers
etc. etc. etc.
And then you wonder why I'm so set against WebComponents. Because you (and Rob Dodson and other WebComponent proponents) are entirely blind to how bad WebComponent APIs are. I dunno, maybe your goal isn't to "sell" WebComponents, but to sell Polymer.
WebComponent API is bad not because "we complain about how Javascript objects are". We complain because WebComponents API is horrendously bad, and that was a deliberate design choice.
Current line of defence is "oh, it's just low level API" or "oh, it's just how Javascript is", both of which are at best patently false.
Here's code to create one single property with one single synced attribute. One. single. property/attribute pair. One.
set transitionDuration(value) {
this.setAttribute('transition-duration', value);
}
get transitionDuration() {
return this.getAttribute('transition-duration');
}
static get observedAttributes() {
return ['transition-duration'];
}
attributeChangedCallback(name, oldVal, newVal) {
if (name === 'transition-duration') {
// do something
}
}
There is no reality where this is good API design. There is no reality where "this is how objects work in Javascript" is an excuse.
This is objectivly bad API design. Bad developer experience. However, you and all other webcomponent proponents completely ignore this fact, and dismiss any and all complaints out of hand.
Of course you do. You've got Polymer to promote [1]. If WebComponents had better APIs, there would be no need for Polymer, would there. Because here's how Polymer solves the problem, despite this being "oh, that's how Javascript works".
static get properties() {
return {
transitionDuration: {
type: Number,
readOnly: false,
reflectToAttribute: true,
observer: 'methodName'
}
}
}
Oh. My. God. This is doable without any excuses about how Javascript works? Really? Who would've thunk it?
[1] Hell, even in your "rebuttal" of criticism towards WebComponents here's what you write:
> To show how absolutely easy this is, and how off-base the DX complain is, here's how easy a Polymer 2 + TypeScript element is
Were we talking about the bad DX of Polymer? No. You are totally entirely absolutely blind to the fact though. Because in your mind WebComponents === Polymer. And, sadly, for all intents and purposes it's true.
edit: removed some erroneously pasted code
- nawitus 9y ago"maybe your goal isn't to "sell" WebComponents, but to sell Polymer." The goal of Web Components are to sell a interop layer that is supported by many (or even all) frameworks. It's not supposed to be a framework that has the best developing experience. The Polymer API is better than the Web Components API. The Polymer API is more high level than the Web Components API. This is not by mistake, it's by design. The higher level the Web Components API is, the more difficult it is to use by a large number of wildly different frameworks. "We complain because WebComponents API is horrendously bad, and that was a deliberate design choice." I don't think it matters much to be honest, because developers should use frameworks, just like they are using frameworks at the moment. "Here's code to create one single property with one single synced attribute. One. single. property/attribute pair. One." You need a "synced attribute" only for some frameworks, not all. Also, your example is misleading, because the two last methods are only needed to be defined once, so if you want 2 synced properties, the total number of methods is 6, not 8. "Bad developer experience." Use a framework. "If WebComponents had better APIs, there would be no need for Polymer, would there." The risk is too high to use the Polymer API for the Web Componenets API. In addition, the more complex the API is, the more likely it is for the browsers not to implement the API. It's better to have a simple native API and provide different frameworks for a good user experience. "Because in your mind WebComponents === Polymer." Or maybe he thinks that frameworks should be used, as intended.
- dmitriid 9y ago> The goal of Web Components are to sell a interop layer that is supported by many > Or maybe he thinks that frameworks should be used, as intended. Translation: instead of providing a good DX we're going to sell Polymer > The Polymer API is more high level than the Web Components API. This is not by mistake, it's by design. Indeed. By crappy design with horrible developer experience > The higher level the Web Components API is, the more difficult it is to use by a large number of wildly different frameworks. Hmm... How about "let's reduce the need for and dependency on multiple frameworks"? When will that ever be a goal? > You need a "synced attribute" only for some frameworks, not all. Surprise, Polymer's API provides a possibility to define that. > Also, your example is misleading, because the two last methods are only needed to be defined once, so if you want 2 synced properties, the total number of methods is 6, not 8. Oh. Right. 6, not 8. I wonder if I ever complained about the number of methods required? Nope, what I complained about is the amount of tedious boilerplate you need to write to implement the most basic and common of things. If I need 1 more synced property/attribute pair, I will need: - 1 extra setter - 1 extra getter - 1 extra item in the attributes list - 1 extra if clause in the callback. >> "Bad developer experience." > Use a framework. How about: platform provides a well-designed API that doesn't require a framework for the most basic and common functionality? As an example: - DOM APIs are horrible, and quickly devolve into tedious error-prone boilerplate - jQuery API is amazing - Does this mean that DOM APIs suddenly become developer friendly? Does this mean they are beyond any criticism? Same with WCs