600 points · by samerbuna · 9y ago · 241 comments
* Object.values/Object.entries - https://github.com/tc39/proposal-object-values-entries
* String padding - https://github.com/tc39/proposal-string-pad-start-end
* Object.getOwnPropertyDescriptors - https://github.com/ljharb/proposal-object-getownpropertydesc...
* Trailing commas - https://github.com/tc39/proposal-trailing-function-commas
* Async functions - https://github.com/tc39/ecmascript-asyncawait
* Shared memory and atomics - https://github.com/tc39/ecmascript_sharedmem
The first five have been available via Babel and/or polyfills for ~18 months or so, so they’ve been used for a while now.
[0] https://github.com/tc39/proposals/blob/master/finished-propo...
I consider the fact that a stupid-simple package was depended-upon by so many mature libraries as an indication it should be a language feature.
Working with network protocols I find myself needing padding functions all the time, and there isn't really an elegant way to do so inline, so I welcome this addition.
Unfortunately neither the npm module nor the browser version really do what most people want and string handling in javascript is still a minefield.
'\u{1F4A9}'.padStart(5, '1') => "111" // oops (\u{1F4A9} is at the end of this, HN filter)
'\u{1F4A9}'.length => 2
[...'\u{1F4A9}'].length => 1 //WTF?
'mañana'.padStart(7, '1') => "1mañana" // ok
'man\u0303ana'.padStart(7, '1') => "mañana" // oops
'man\u0303ana'.length => 7
[...'man\u0303ana'].length => 7 // WTF? Why doesn't this match the behavior of [...'\u{1F4A9}'].length ?
'man\u0303ana'.normalize('NFC').padStart(7, '1') => "1mañana" // OK
I do understand the unicode issues here, but the inconsistency in the APIs from a user perspective and lack of any fully cross browser support for sane string processing in Javascript means we still have only a few options:
1) Don't do string processing in javascript at all.
2) Include a library to make it sane, these are usually huge as they usually need large lookup tables.
3) Accept that things won't always be correct.
This is one example but the lack of a sane standard library in Javascript is one of the biggest problems the web has right now. I'd be curious to know how many bytes of JS are loaded on the average website just to work around the lack of standard library support for basic functionality, I'd bet it's a very large number. Another fun one: Try to parse a URL and append extra query params to it, correctly.
I'm basing this on the assumption that the desire for trailing commas is making editing easier and reducing noise in diffs.
Just curious if there are niches where people are spending a lot of time manually editing JSON or if the use case is something else entirely.
I love them in code, despite initial resistance.
...but in my experience usage of ES6/ES7/ES8 as names far outweighs usage of ES2015/ES2016/ES2017. Calling it ES2017, while technically correct, would in my opinion be far more confusing to most people than calling it ES8.
I personally prefer the terse version, but there are advantages to using the year-based naming.
What matters is the ongoing standardisation process. New JS features are proposed, then graduate through four stages. Once at stage four, they are "done" and guaranteed to be in the next annual ES edition write-up. Engines can confidently implement features as soon as they hit stage 4, which can happen at any time of year.
For example, async functions just missed the ES2016 boat. They reached stage 4 last July [1]. So they're officially part of ES2017 – but they've been "done" for almost a year, and landed in Chrome and Node stable quite a while ago.
[1] https://ecmascript-daily.github.io/2016/07/29/move-async-fun...
ECMAScript is more a thing for backwards compatibly.
Things get proposed and HAVE to be implemented in runtimes before they get into ECMAScript.
They want to know if things can be implemented nicely before they standardize them.
This is more a game between ECMA and Browser vendors, JS compilers (like Babel) and vendors of other JS runtimes like Node.js.
If you are an enduser, i.e. a user of Babel, it's more a question of the support you get from the Babel devs.
They say JSX is on? No matter what ECMA says, as long as Babel gets this compiled into ECMAScript conforming JS.
That means that you're not imposing an unusual configuration on downstream users, and depending on the environments you support, at some point you won't even need to run Babel at all.
With IE11 approaching end of life, and more and more sites dropping support for it, we're rapidly approaching a time when we can assume the vast majority of users are on a modern, evergreen browser. And the last version of node that didn't have full ES6 support just went out of long term support.
That's what stage 4 means. Completely finalised. Appearing in the next 'edition' document is just a formality. Once it's stage 4, it's effectively in the standard. If you restrict yourself to stage 4 features, you have all the same guarantees you mentioned. If you restrict yourself to the last published edition, you'd have missed out on async functions until almost a year after they were completely finalised, for example.
> the last version of node that didn't have full ES6 support
No version of Node supports ES6 imports yet, which is a huge part of ES6, and it won't be supported for at least another year. This emphasises the point that following ES editions is pointless.
All that matters is what combination of individual features is supported by your engine. Thinking in editions has pretty much no benefit.
You, several years from now.
The inclusion of features in the standard is an important part of the evolution of the language. But it's just one part. More recent browsers have already implemented many of these features, and there will come a day when they're pretty much everywhere. Just be patient.
(source: I'm old and remember the era when our sites had to work with Netscape 4 due to its market share)
Not so long ago, we had to support IE8. Before that, IE6. If you go back a little further IE5 for Mac was the biggest pain point. Before that, Netscape 4 and IE4, which were often mutually incompatible.
There will always be a legacy system many people have to support at any given time. But over time the number of people that has to worry about it will shrink along with its market share. You probably don't see many support tickets about Netscape 4 these days anymore.
Having these standards today means the next generation of legacy browsers will support them when you're stuck with them in the future. That you're not chasing the bleeding edge doesn't mean you don't benefit from these advancements, just that you'll do so with a delay, and likely far less gradually than those privileged enough only to care about the evergreens.
People writing internal tools.
People writing software for tech-savvy users with modern hardware.
People using babel to compile to a supported version.
A spec is never symbolic. If a library claims it implements ES2017 then its consumer expects the library to follow the entire spec.
And JavaScript engines don't implement ES editions, they implement ES features. These features now have a five stage process ending with their inclusion in the next edition of the language spec.
Most engine vendors want to be on the bleeding edge, so they start implementing features long before they are fully stable.
The reason the editions are symbolic at this point is that they are just snapshots of the collection of features that have reached stage 4 by the time they are published.
Object.entries(obj).map((prop, value) => ...).reduce((newOdj, [prop, value]) => newObj[prop] = value);
I see your point about verbosity :)So you have weird things like `'foo'.map()`, `( 42 ).map()`, `new WeakMap().map()`, `false.map()`, etc.
'foo' is a string and can be iterated over.
42 is a number that can be provided to a function. Not sure about this one tbh. Could be useful for passing a number to a function if-and-only-if the number is valid (not NAN)
WeakMap(), I don't know what it is but I assume it's a map that can be iterated over.
mapping 'false' would fit well the Maybe monad.
WeakMap is a new-ish type whose keys are objects. The references to those objects are weakly held, which means that an object `x` whose only reference is a WeakMap key will still be eligible for garbage collection. They are non-iterable for exactly that reason.
Also: how do you iterate over `false` or a function? What about user-created classes?
There are so many cases where the behavior would either be nonsensical or at least unintuitive that (in my personal and completely subjective opinion) they outweigh the slight convenience of being able to "map" a plain old JavaScript object.
https://kripken.github.io/emscripten-site/docs/porting/pthre...
Granted it may be limited to consumption via Emscripten, it is nevertheless now within the realm of possibility.
For this that cannot grok the gravity of this -- proper concurrent/parallel execution just got a lot closer for those targeting the browser.
Not only are these difficult to reason about and program against, introducing locks over mutable memory causes performance problems and are a speed bump to high concurrency. (Heck, just yesterday on HN, a story was published "24-core CPU and I can't move my mouse" [0] - the culprit? Low-level locks.)
Creating too many threads introduces performance problems, too, thanks to CPU context switching; pools must be created and threads reused from those pools.
And now in JS land we're trying to introduce threads and mutable shared memory? Are we just going to learn these lessons over again?
[0]: https://randomascii.wordpress.com/2017/07/09/24-core-cpu-and...
Joe Duffy, who had originally done quite a bit of initial work on the TPL, argues in favor of this paradigm[0] of raising the abstraction level.
I feel like introducing the low-level tools without providing a raised abstraction level may be beneficial in the long run (you need low-level tools to build high-level abstractions), however, without these abstractions I suspect a generation of JS developers will need to re-learn all the multi-threading lessons of the last few decades.
[0]: http://joeduffyblog.com/2016/11/30/15-years-of-concurrency/
It would be nice if EcmaScript could give us a middle ground -- ability to use 32/64 bit integers without having to go all the way down to asm.js or wasm.
But yes, 100% agreed; this is a major pain point of the language right now. Nice to hear that there's finally some movement on fixing it (as per arthurdenture's comment)!
I'd like to see TC39 tackling the big problems of JS like the lack of static type checking. I'm tired of looking at a method and having to figure out if it is expecting a string, or an object.
We had EcmaScript4 about 10 years ago with plenty of great features but TC39 killed it. And yeah, it probably made sense since the browser vendor landscape was very different back then. Today it would be possible to implement significant changes to the language much like the WebAssembly initiative.
How well major breaking changes like that work out on the web can be seen by the massive success (cough) of XHTML -- I dare you find me one notable site correctly using XHTML with the appropriate MIME type (rather than just sending XHTML as HTML tagsoup using `text/html`).
Web Assembly works because it is not a breaking change to JavaScript. It's actually defined in a way that is mostly orthogonal to JavaScript -- it shares some of the APIs but most likely there will be (low-level) APIs only Web Assembly code can use and some (high-level) APIs that only exist for JS.
So you see, they're following long-standing industry practice :-)
Surface Pro. Surface Pro 2 (note: Surface Pro is now surface pro 1!), Surface Pro 3, Surface Pro 4, Surface Pro. By the way we also have Surfaces (1, 2, and 3?) as well as Surface Books, and Surface Laptops! :D
Android: here's a bunch of fucking candy
OS: here's a bunch of fucking animals. By the way, sometimes people call your macbooks 10,1 or some shit.
whose initials follow alphabetical order
I can find some references to "Javascript" being an implementation of ECMAScript, but doesn't appear to true [1]. Mozilla's implementation is SpiderMonkey, Google's is V8, and Microsoft has Chakra and JScript.
[1] https://en.wikipedia.org/wiki/ECMAScript#Implementations
Netscape created a language which they called LiveScript when it first shipped in a beta build, largely influenced by Java. By the time of Netscape Navigator 2.0 beta 3, they had negotiated a license for the Java name from Sun and renamed the language JavaScript (and, as wamatt pointed out, Sun owned the JavaScript trademark, now owned by Oracle following the Sun acquisition).
IE3 shipped a reverse-engineered copy of JavaScript, which they called JScript because they didn't have a license to the JavaScript trademark.
Later in the same year that Netscape Navigator 2.0 and IE3 shipped, Netscape submitted a specification of their JavaScript language to Ecma. What followed, as far as I'm aware, was a bit of a debate about naming: JavaScript was basically out of the question due to it being a Sun trademark, JScript was a MS term that Netscape didn't want to legitimise, and hence the compromise was ECMAScript (why this uses the pre-1994 capitalisation of Ecma is a good question!).
So, essentially, JavaScript, JScript, and ECMAScript are three names for the same language.
This then gets a bit complicated as Netscape and then Mozilla referred to ECMAScript revisions as JavaScript versions, and then started adding non-standard extensions as new JavaScript versions, though they've basically killed that now.
This is a little wrong/misleading.
ECMAScript is the specification; JavaScript, JScript, and ActionScript, are various implementations of the specification. Each implementation provides additional features not described in ECMA specs, such as access to ActiveX and the local computer in JScript.
I believe that's backwards. Javascript was based on Scheme & Self, the Java resemblance is only superficial; added later for marketing purposes when they picked up the JavaScript name.
Javascript, JS, ES2015, ES2016, ES2017, ES5, ES6, ES7, ES8, Ecmascript 2015, Ecmascript 2016, Ecmascript 2017, HTML, HTML5, CSS, CSS3.... etc.
I worked as a recruiter so I know it's necessary because 1: recruiters ctrl+f like a mofo, and also your resume won't pop up on linkedin/ other sites if you don't hit their tags, and 2: recruiters will scan the "technologies" section to make sure you "have" the language that was given to them on their spec sheet.
Spec sheet will look like:
Web Developer 3+ years experience Knowledge of Javascript, HTML, CSS3
If you have CSS but not CSS3 the recruiter may not realize the difference (or may not realize that pretty much the most important thing on that spec is "Web Developer") and probably won't call.
So in short is calling it Javascript correct? shrug Nothing is correct in this mad world!
- Oracle own the trademark on JavaScript (though buying what was left of Sun, through the Sun Netscape Alliance)
- Nobody trusts Oracle
A good idea proposed is just to call the language itself 'JS' and have it not stand for anything.
"Eich commented that "ECMAScript was always an unwanted trade name that sounds like a skin disease.""
JavaScript, that's a scriptable version of Java, right?
/sarcasm
The last one is for ES6.
ES6 (very comprehensive!) http://es6-features.org/#Constants
ES7 (succint, easy to read) https://h3manth.com/new/blog/2015/es7-features/
If applicable there are examples of both before and after conventions as well as links to more technical external resources.
His blog is full of useful and specific deep dives into individual ES proposals as they reach certain stages.
And some interesting tweets by Kent C. Dodds: https://twitter.com/kentcdodds/status/880121426824630273
Edit: fixed KCD's name. Edit #2: No, really.
Everything is supported, except "Shared memory and atomics"
https://github.com/tc39/proposals/blob/master/finished-propo...
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
But I may be able to use Proxy just to capture object changes. I will try it out
>BT: Assuming we get standard modules?
>AWB: We'll get them.
lol
Am I the only one who finds this ironic..
What's the feature you're most excited about?
has been possible with babel on older versions of the JS, but nice to have it after all officially.