Posts

Showing posts with the label ES6

Yet Another Reason To Drop __proto__

I know it might sound boring but I really want to put everything down and laugh, or cry harder, the day TC39 will realize __proto__ was one of the most terrible mistakes. A Simple Dictionary Attack ES6 says that Object.create(null) should not be affected anyhow from Object.prototype . I've already mentioned this in the 5 Reasons You Should Avoid __proto__ post but I forgot to include an example. You can test all this code with Chrome Canary or Firefox/Nightly and the most basic thing you need to know is this: var n = Object.create(null); n.__proto__ = {}; for (var k in n) console.log(k); // __proto__ !!! Object.keys(n); // ["__proto__"] !!! Got it? So, __proto__ is enumerable in some browser, is not in some other but it will be in all future browsers. Let's go on with examples ... // store values grouped by same key function hanldeList(key, value) { if (!(key in n)) { n[key] = []; } n[key].push(value); } // the Dictionary as it is in ES6 var n = Object....

ES6 Harmony Collections Fast Polyfill

Well, just in case you read RSS and you missed my tweet ... everything you need to know in github repository . Have fun with Harmony Collections

Please, Give Us Back __noSuchMethod__ !

For those who don't know what __noSuchMethod__ is here the quick summary: it was a bloody handy non-standard method able to provide a fallback whenever we invoked an object method that did not exist. var o = {}; o.__noSuchMethod__(function (name, args) { alert(name); // "iDoNotExist" alert([].slice.call(args)); // 1,2,3 }); o.iDoNotExist(1, 2, 3); // will produce above alerts A Bit Of Background Well, if you are patient enough, you may consider to read this never-ending post in Mozilla mailing list. The reason that post is called Proxies: get+fn vs. invoke is because Proxy supposes to be the new way to go able to bring us much more power than we probably ever need ... but hey, this is welcome, while what is not welcome, is that Proxy may not be implemented first, which means browsers vendors should have waited to remove __noSuchMethod__ 'cause right now we may not have a pseudo equivalent, and second, but surely not less important, , Proxy does not provid...

Dear Brendan, Here Was My Question

I had the honor to personally shake the hand of the man that created my favorite programming language: Brendan Eich ! I also dared to ask him a question about ES6 and I would like to better explain the reason of that question. I have 99 problems in JS, syntax ain't one I don't know who said that but I completely agree with him. Here the thing: one of the main ES6 aim is to bring new, non breaking, shimmable, native constructors such StructType , ArrayType , and ParallelsArray . We have all seen a demo during Brendan presentation and this demo was stunning : an improvement from 3~7 to 40~60 Frames Per Second over a medium complex particles animation based, I believe, on WebGL. These new native constructors are indeed able to simplify the JS engine job being well defined, known, and "compilable" runtime in order to reach similar C/C++ performances. These new constructors can also deal directly behind the scene, without repeated and redundant "boxing/unboxing" ...

ES6, Harmony, and JS++

... where JS++ is simply metaphoric, in the meaning of "empowered JS" :) Here the slides I have showed last friday during another team meeting, enjoy!