News for hackers. Stuff that matters.
Re:A day without JavaScript by sametmax on Wednesday June 07, 2017 @08:36AM (#14505782)
Polyfill. So new lib.

And even then. You need to encode params manually.

And of course no middleware, so for special decoding or repeating headers, you end up writting a wrapper.

Re:A day without JavaScript by megous on Wednesday June 07, 2017 @09:23AM (#14506170)
Programming is mostly creating functions and interfaces to decompose problems into reusable parts where reuse makes sense. Nothing wrong with creating a simple function for making XMLHttpRequests or for fetch API. Most of the time there's no need for the level of generality of jQuery interfaces.

Just by making a function you're not creating a library. Sometimes I find DOM API verbose too. Nevertheless the fix does not need to be a interface like jQuery to completely hide DOM API under another interface. It may be enough to extend the HTMLElement prototype a bit or write a function to "compress" the code a bit and make it more readable.

Re:A day without JavaScript by forgottenpass on Wednesday June 07, 2017 @12:04PM (#14507481)
Just by making a function you're not creating a library.

Have you seen what passes for a library on npm?

Re:A day without JavaScript by megous on Wednesday June 07, 2017 @01:48PM (#14508382)
Good point. :D
Re:A day without JavaScript by sametmax on Wednesday June 07, 2017 @01:53PM (#14508433)
> it may be enough to extend the HTMLElement prototype a bit

You lost me here. Anybody extending standard objects cannot be taken seriously.

Re:A day without JavaScript by megous on Wednesday June 07, 2017 @02:41PM (#14508812)
Do you realize JavaScript is a prototype based programming language? It is a major and very useful feature of the language. There's no reason not to use it. There are some things to be careful about with interop if you need it, but that's it.
Re:A day without JavaScript by jamiepenney on Wednesday June 07, 2017 @05:27PM (#14510014)
We've already learned from our past mistakes changing the prototype of the standard library - the Ruby community learned the same thing with monkey patching their standard lib too. The maintenance overhead far outweighs any immediate benefits.
Re:A day without JavaScript by megous on Wednesday June 07, 2017 @05:46PM (#14510112)
What maintenance overhead? Current and future costs are reduced by making code simpler and cleaner in the first place by using prototypes efficiently.

Also, to be clear, I'm suggesting adding new methods to DOM object prototypes, not changing behavior of existing methods.

Re:A day without JavaScript by ehsanu1 on Wednesday June 07, 2017 @09:29PM (#14511213)
Applications may be able to do this in a controlled manner. Library authors never should.
Re:A day without JavaScript by shakna on Wednesday June 07, 2017 @09:40AM (#14506335)
> Polyfill. So new lib.

So, you don't like the polyfill, created to the specification. Fine, but depending who you target, you might not need it. Plenty of modern browsers have good support.

> And even then. You need to encode params manually.

Or use the Request constructor.

> And of course no middleware, so for special decoding or repeating headers, you end up writing a wrapper.

Request constructor will let you handle the headers quite nicely.

Re:A day without JavaScript by inimino on Wednesday June 07, 2017 @09:24AM (#14506173)
No, a polyfill is not a library. It's a dozen lines, not a thousand.
Re:A day without JavaScript by dragonwriter on Wednesday June 07, 2017 @09:26AM (#14506192)
> No, a polyfill is not a library

Yes, it is.

> It's a dozen lines, not a thousand

A polyfill can be any size, but there's no size minimum to be a library.

Re:A day without JavaScript by inimino on Sunday June 11, 2017 @12:19PM (#14532531)
Overly-literal response.

A polyfill is a short snippet to implement a missing feature. Notably almost all recent additions to JS and DOM have been designed to be polyfillable where possible. Generally that means under a thousand lines, by the way.

A library in this context means a set of functionality built on top of the platform, like jQuery, with its own API, etc. "Use a library" and "use a polyfill" are not the same advice.

A polyfill is not a library.

Re:A day without JavaScript by AstralStorm on Wednesday June 07, 2017 @12:30PM (#14507727)
Some people are mistaking a book (actually a module) for a library.