Re: Is polyfilling future web APIs a good idea?

On Tue, Aug 4, 2015 at 8:22 PM, Glen Huang <curvedmark@gmail.com> wrote:

There's actually a lot of questions in here, so let me take them one
at a time...

> On second thought, what's the difference between prollyfills and libraries
A major difference is that it's hard to translate libraries into
standards regardless of the approach they use.  We just don't do it.
We have libraries like jQuery that are as successful as we can ever
reasonably expect anything to get - it's inarguable that jQuery is
used more than any single browser, for example - and yet we didn't
just standardize jQuery.   What's more, we wouldn't for lots of
technical and political reasons.  jQuery wasn't made with becoming a
standard in mind and it didn't propose things in same standards sense
before hand or early -- a lot of the approach/style matter too (see
below).  Aspects of it could have been - jQuery has individuals
representing in standards committees (me, for example) and prollyfills
give us a way to do this - ecma, for example, produces a lot of
prollyfills as they go and actually get use and feedback before it's
way too late.

> exposed web APIs in a functional style (e.g., node1._replaceWith(node2) vs replaceWith(node2, node1)? Or in a wrapper style like jquery does? Prefixing APIs doesn't seem to be that different from using custom APIs?

It could be, but the further you get from the actual way it will be
used, the more we will debate on what will happen if you change its
surface.  A prollyfill is as close as we can approximate to the real
proposal without shooting ourselves in the foot.  It lets developers
and standards people work together, answer questions about uptake and
confusion, identify use cases and edgecases, etc.

>You might say the prefixing approach resembles native APIs more closely, but when changing your code to use native APIs, modifying one character or several doesn't really make much difference (they are the same if you find & replace), as long as you have to modify the code.

Definitely not as simple if you change the whole pattern - asking
someone to grep an entire codebase is a bigger ask than a nice simple
pattern that lets you just say something like:

// Hey, our prollyfill matches native, now it's a polyfill!
HTMLElement.prototype.foo = HTMLElement.prototype._foo;



-- 
Brian Kardell :: @briankardell :: hitchjs.com

Received on Wednesday, 5 August 2015 02:32:25 UTC