moving web forward: part i — ecmascript 201x
TRANSCRIPT
Moving Web forwardpart i — ECMAScript 201x
Sergey Rubanov
JavaScript Samurai
November 5-6, 2016
KharkivJS #7
previously on moving web forward
part 0 — harmony
2
1996
3
Netscape: we need a language to be able to change pictures in browsers!
Brendan: pfff lol easy
Microsoft: NOT BAD4
Brendan: Holy shhh…
Microsoft: NOT BAD5
2000s
6
Brendan: Yo! I wanna add classes, a module system, optional type annotations and static typing! And algebraic data types!
NO7
Brendan: BUT…
NONO8
Brendan: But listen…
NONO9
NOI like it
I like it
2015
11
12
💩Harmony
Unicode*
ES2015 (ES6) support13
ES2016
14
ES2016 features• Exponetiation operator (**)
• Array.prototype.includes
15
ES2016 support16
ES2017
17
ES2017 features• Object.values / Object.entries
• String padding
• Object.getOwnPropertyDescriptors
• Trailing commas in function parameter lists and calls
• Async Functions18
Object.values / Object.entries
19
String padding
20
Object.getOwnPropertyDescriptors
• Object.assign directly accesses properties and symbols instead of their descriptors
• composition over classes
21
Trailing commas in function syntax
22
Async functions
• based on promises and generators
• make asynchronous things look like synchronous
23
ES2017 support24
Next TC39 Meetings• 55th meeting of TC39
• Host: Facebook, Menlo Park, CA
• Dates: Tuesday, 29 November 2016 to Thursday, 01 December 2016
• 56th meeting of TC39
• Host: TBD
• Dates: 2017-01-?? to 2017-01-??
25
Spec revisions and scheduling
• February 1: Candidate Draft is produced.
• February - March: 60 day royalty-free opt-out period.
• March TC39 Meeting: stage 4 proposals are incorporated, final semantics are approved, and the new spec version is branched from master. Only editorial changes are accepted from this point forward.
• April-June: ECMA CC and ECMA GA review period.
• July: Approval of new standard by the ECMA General Assembly
26
Unlikely ES2017likely later
27
Stage 3• SIMD
• global
• Rest/Spread Properties
• Asynchronous Iteration
• Function.prototype.toString revision
• Lifting Template Literal Restriction
28
SIMD• proposed by Google and Intel
• came from Dart
• based on Typed Arrays
• x86 with SSE, ARMv7 with Neon
• may be useful in 3D graphics, video processing, physics simulations, cryptography, and other domains
29
SISD vs SIMD
30
SIMD
31
global
• System.global previously
• no more Function('return this’)()!
• adds portability
32
33
34
Browsers: window.global
Node.js: global.global
35
Browsers: window.global
Node.js: global.global.global.global.global.gl
36
global is
• writable
• non-enumerable
• configurable
37
38
Rest properties
Spread properties
Asynchronous iteration
39
Sync iterator:
Async iterator:
Asynchronous iteration
40
• Symbol.asyncIterator well-known symbol
• for-await-of statement
Async generator functions
41
Definitely ES2018
or never
or later
42
Stage 2• function.sent metaproperty
• Legacy RegExp features in JavaScript
• RegExp Unicode Property Escapes
• String.prototype.trimStart and String.prototype.trimEnd
• Shared memory and atomics
• Promise.prototype.finally
• Public Class Fields
• Decorators
• import()
43
Promise.proptotype.finally
• pass callback once instead of declaring one function twice or create a variable for it
• callback will not receive any arguments
• will be resolved or rejected with previous promise’ value
• or will reject if it throws or returns rejected promise
44
Public class fields
• static properties
• class fields
45
Static properties
46
Class fields
47
Decorators
48
@frozen class Foo { @configurable(false) @enumerable(true) method() {} }
decorators
import()• dynamic imports
• returns promise for the module namespace object
• specifier can be an expression
• works in both scripts and modules
• System.import() previously
• await import form (instead of nested import declarations)
49
Stage 1• Date.parse fallback semantics
• export * as ns from "mod"; statements
• export v from "mod"; statements
• String.prototype.matchAll
• Math Extensions
• Generator arrow functions (=>*)
50
Stage 1• of and from on collection constructors
• WeakRefs
• Frozen Realms
• Private Fields
• Observable
• Cancelable Promises
51
Private fields
52
Observable
53
Observable
54
Observable
55
Observable
56
Observable
57
Cancelable Promises• a new class, Cancel, which does not
derive from Error
• try { ... } else (e) { ... } syntax, which ignores instances of Cancel
• a new Promise method, promise.else(onRejected), which ignores instances of Cancel
58
Stage 0
• don’t use it in production
• it is not a maturity stage
• no guarantees
59
babel-preset-env✨ Autoprefixer for Babel ✨
60
babel-preset-env• browserlist
• ECMAScript compatibility tables (ES2015 and ES2016+ tabs)
• Babel plugins
61
babili✨ ES6+ minificator ✨
62
Thank you@chicoxyzzy
63