4 ms·
Why? What is the thing you can do in ES6 that you can't in ES5? Features that affect execution speed or real memory consumption positively. Leave hipster featur
by atirip 11y ago
Why? What is the thing you can do in ES6 that you can't in ES5? Features that affect execution speed or real memory consumption positively. Leave hipster features out.
- tragic 11y agoThat's an extraordinarily reductive view of improvements to a programming language. A basic example: cleaner syntax for anonymous functions will have (presumably) almost no effect on speed/memory either which way, but will make code more readable. Which is not a 'hipster' concern.
- coev 11y agoAlso: "this" is bound for you in fat arrow functions without having to resort to function.prototype.bind or "var that = this;" trickery. That's an issue I've seen bite many people before and it'll be nice to have an easy way to avoid that.
- TazeTSchnitzel 11y agoIt's the difference between var map = function (f) { return function (list) { return list.map(f); }; }; and const map = f => list => list.map(f);
- VeejayRampay 11y agoUpvoted your comment so that everyone can see it. ES6 has template strings, destructuring assignment, Map and Set data structures (and more). While you're right and it is not NEEDED, this is something that dramatically improves on the weakest aspects of ECMASscript. Based on your comment, it feels like no addition is ever a good addition if you can express it with the building bricks you already have. With such a way of seeing things, we'd all be coding with assembly language, cause nothing really affects speed or memory consumption for the better.
- atirip 11y agoNo-no, there has been lot of features added to Javascript (i started writing it around 2003) that were not shimmable in earlier versions.
- etimberg 11y agoMap and set are much nicer in ES6 as built in objects.
- btd 11y agoimo map and set useless. Real advantage of maps only that you can use any type of keys, but really why not convenrt them to string represntation and put to simple object? Map .has method uses === for object search. For set the same, just use object with keys and dummy values.
- realistschuckle 11y agoProxies. You can't shim in the Proxy object. Ain't no hipster feature there.
- spion 11y agoYou can't even transpile it without massively different output from the transpiler, which is a bit bad.
- karoladamiec 11y agoOne reason to rule them all: Generator functions. Why it is a big deal one might ask. It is the BIGGEST deal in history of Javascript in my book because it allows you to do async that looks sync. No more callback hell. It is the single most important feature, as it eliminates async issues completely. And EVERYTHING in js is async. But in reality, you want to drop into async only sometimes. Now you are forced into it 100% time, even when you need the result of async call to decide what to do next. It gets tricky really fast.
- CoryG89 11y agoI guess to each their own then. I really just want the new syntax features, modules, classes, const,maybe template strings will be nice too. I work with async ES5 code all the time and I don't have many problems with async when using promises. I know promises are also coming with ES6, but almost everyone uses them today in ES5.
- karoladamiec 11y agoWell promises help. And then they stop :). Stop helping. They just break under the weight. If you have promise chain that gets too long, you will feel the pain. The whole thing is, when some IO returns 1 or 2. And your next step is to do a or b depending on the reply. How is your neat promise chain looking now? Then repeat 100 times :( Not even mentioning error handling... and stack traces. So i do agree that it depends what you do a lot. Maybe there are domains where it is not important... but i still need to see that one. And i will take blocking IO with try/catch 10 times out of 10. Even when it is not critical. It is just nicer and easier to reason about.
- babby 11y agorequire('bluebird').coroutine function*() {} Promises + Generators = The sweet spot. Check out https://www.npmjs.com/package/coroutiner https://www.npmjs.com/package/coroutiner to make it stupid-easy to coroutine your entire app.
- 11y ago