What's the point of promises being part of ES6? I understand them and use them quite a bit. I just don't understand why they're in the language spec. They don't add anything new to the language ( vs say generators or symbols ). Is it purely for performance?
ES6: The features I'm most excited about
101–110 of 144 posts
Re: ES6: The features I'm most excited about
#102I don't understand why everyone considers classes controversial. If you look at code in the wild, it already does what classes desugar to: everyone already writes constructor function and attaches properties to their prototypes. At least now with classes, users coming from other languages wont be as tempted to make their own completely incompatible object systems.
It is more the "extends" than "class" that is controversial because it eschews other pattern like mixins.
Re: ES6: The features I'm most excited about
#103Earlier quoted context omitted.
I see. Not sure what the best practice is for the losing scope in then chains issue with promises. I ended up creating something along the lines of a message object designed for each chain, which felt like a smell.
Feels like an un-compiler-assisted State monad. IMO threading an object through is probably the best method, unfortunately. You could use an Immutable Record or something to help keep it under control. I would personally just use async/await to more explicitly handle the sequencing/binding.
Re: ES6: The features I'm most excited about
#104I'm a bit worried about ES6 making the language harder to understand. For example, scoping: For backwards compatibility reasons, var has to stay function scoped. But now we also have let, which has different scoping rules. Also, Symbols: [Symbol.iterator]() - what? Why?! On the other hand, stuff like arrow functions, template strings, modules and tail optimization are awesome.
Can someone explain the reasoning behind having any kind of backwards compatibility? Who would pick a worse-but-compatible ES6 over a better incompatible version? For example, the scoping rules: why have two separate scoping rules for let and var? To put it another way, would ES6 have let and var with differing scoping rules if it was designed today? If not, then it's a flaw (any difference from what a clean redesign…
Re: ES6: The features I'm most excited about
#105I'm a bit worried about ES6 making the language harder to understand. For example, scoping: For backwards compatibility reasons, var has to stay function scoped. But now we also have let, which has different scoping rules. Also, Symbols: [Symbol.iterator]() - what? Why?! On the other hand, stuff like arrow functions, template strings, modules and tail optimization are awesome.
Can someone explain the reasoning behind having any kind of backwards compatibility? Who would pick a worse-but-compatible ES6 over a better incompatible version? For example, the scoping rules: why have two separate scoping rules for let and var? To put it another way, would ES6 have let and var with differing scoping rules if it was designed today? If not, then it's a flaw (any difference from what a clean redesign…
Not breaking millions of websites.
Re: ES6: The features I'm most excited about
#106Re: ES6: The features I'm most excited about
#107I was just talking to my friend who works at NetFlix on the frontend team about ES6, he is most excited about destructuring `let { name, age, gender } = user;`. I however advocate that the new class syntax is the best part of ES6. Take the following trivial OOP example, which I think reads so much easier a lot like PHP. "use strict"; class Vehicle { constructor(name) { this.kind = 'Vehicle'; this.name = name; } print…
> he is most excited about destructuring `let { name, age, gender } = user;`. Why is this a big deal? Seems pretty trivial.
Example code: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Additionally, it's nice sugar for module loading, for modules that export multiple values.
Re: ES6: The features I'm most excited about
#108What's the point of promises being part of ES6? I understand them and use them quite a bit. I just don't understand why they're in the language spec. They don't add anything new to the language ( vs say generators or symbols ). Is it purely for performance?
This also means more feature-rich implementations can just extend the native promises instead of implementing everything from scratch, though for me this pretty much spells the end of third-party promise implementations.
In other words, they've been added for the same reason as the various new helper methods: not because they add new functionality, but because they provide a reliable well-defined and consistent solution to a very common problem.
Re: ES6: The features I'm most excited about
#109Earlier quoted context omitted.
Can someone explain the reasoning behind having any kind of backwards compatibility? Who would pick a worse-but-compatible ES6 over a better incompatible version? For example, the scoping rules: why have two separate scoping rules for let and var? To put it another way, would ES6 have let and var with differing scoping rules if it was designed today? If not, then it's a flaw (any difference from what a clean redesign…
> Can someone explain the reasoning behind having any kind of backwards compatibility? Not breaking millions of websites.
Maybe even orders of magnitude more than that.
Re: ES6: The features I'm most excited about
#110Earlier quoted context omitted.
It's possible to get power without flexibility. Flexibility is bad -- it creates code that is idiomatic to the person who wrote it. Rust and Go are so exciting because they've intentionally rejected flexibility without compromising power.
Flexibility is not 'bad' - it's a tradeoff. More flexible languages are better for writing DSLs, etc; but using them means a lot of self discipline regarding code style. One thing I wish JS had is a PEP8-style canonical style document. I would find that more useful than classes. On classes, I am among the less excited about them; however, we are in a ridiculous situation where there are about 500 different library im…
Citation needed, or, I'm not quite sure I agree with you there. In fact, I think I believe the exact opposite (to a degree).