moving web forward: part i — ecmascript 201x

63
Moving Web forward part i — ECMAScript 201x Sergey Rubanov JavaScript Samurai November 5-6, 2016 KharkivJS #7

Upload: sergey-rubanov

Post on 12-Jan-2017

99 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Moving Web forward: Part I — ECMAScript 201x

Moving Web forwardpart i — ECMAScript 201x

Sergey Rubanov

JavaScript Samurai

November 5-6, 2016

KharkivJS #7

Page 2: Moving Web forward: Part I — ECMAScript 201x

previously on moving web forward

part 0 — harmony

2

Page 3: Moving Web forward: Part I — ECMAScript 201x

1996

3

Page 4: Moving Web forward: Part I — ECMAScript 201x

Netscape: we need a language to be able to change pictures in browsers!

Brendan: pfff lol easy

Microsoft: NOT BAD4

Page 5: Moving Web forward: Part I — ECMAScript 201x

Brendan: Holy shhh…

Microsoft: NOT BAD5

Page 6: Moving Web forward: Part I — ECMAScript 201x

2000s

6

Page 7: Moving Web forward: Part I — ECMAScript 201x

Brendan: Yo! I wanna add classes, a module system, optional type annotations and static typing! And algebraic data types!

NO7

Page 8: Moving Web forward: Part I — ECMAScript 201x

Brendan: BUT…

NONO8

Page 9: Moving Web forward: Part I — ECMAScript 201x

Brendan: But listen…

NONO9

NOI like it

Page 10: Moving Web forward: Part I — ECMAScript 201x

I like it

Page 11: Moving Web forward: Part I — ECMAScript 201x

2015

11

Page 12: Moving Web forward: Part I — ECMAScript 201x

12

💩Harmony

Unicode*

Page 13: Moving Web forward: Part I — ECMAScript 201x

ES2015 (ES6) support13

Page 14: Moving Web forward: Part I — ECMAScript 201x

ES2016

14

Page 15: Moving Web forward: Part I — ECMAScript 201x

ES2016 features• Exponetiation operator (**)

• Array.prototype.includes

15

Page 16: Moving Web forward: Part I — ECMAScript 201x

ES2016 support16

Page 17: Moving Web forward: Part I — ECMAScript 201x

ES2017

17

Page 18: Moving Web forward: Part I — ECMAScript 201x

ES2017 features• Object.values / Object.entries

• String padding

• Object.getOwnPropertyDescriptors

• Trailing commas in function parameter lists and calls

• Async Functions18

Page 19: Moving Web forward: Part I — ECMAScript 201x

Object.values / Object.entries

19

Page 20: Moving Web forward: Part I — ECMAScript 201x

String padding

20

Page 21: Moving Web forward: Part I — ECMAScript 201x

Object.getOwnPropertyDescriptors

• Object.assign directly accesses properties and symbols instead of their descriptors

• composition over classes

21

Page 22: Moving Web forward: Part I — ECMAScript 201x

Trailing commas in function syntax

22

Page 23: Moving Web forward: Part I — ECMAScript 201x

Async functions

• based on promises and generators

• make asynchronous things look like synchronous

23

Page 24: Moving Web forward: Part I — ECMAScript 201x

ES2017 support24

Page 25: Moving Web forward: Part I — ECMAScript 201x

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

Page 26: Moving Web forward: Part I — ECMAScript 201x

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

Page 27: Moving Web forward: Part I — ECMAScript 201x

Unlikely ES2017likely later

27

Page 28: Moving Web forward: Part I — ECMAScript 201x

Stage 3• SIMD

• global

• Rest/Spread Properties

• Asynchronous Iteration

• Function.prototype.toString revision

• Lifting Template Literal Restriction

28

Page 29: Moving Web forward: Part I — ECMAScript 201x

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

Page 30: Moving Web forward: Part I — ECMAScript 201x

SISD vs SIMD

30

Page 31: Moving Web forward: Part I — ECMAScript 201x

SIMD

31

Page 32: Moving Web forward: Part I — ECMAScript 201x

global

• System.global previously

• no more Function('return this’)()!

• adds portability

32

Page 33: Moving Web forward: Part I — ECMAScript 201x

33

Page 34: Moving Web forward: Part I — ECMAScript 201x

34

Browsers: window.global

Node.js: global.global

Page 35: Moving Web forward: Part I — ECMAScript 201x

35

Browsers: window.global

Node.js: global.global.global.global.global.gl

Page 36: Moving Web forward: Part I — ECMAScript 201x

36

Page 37: Moving Web forward: Part I — ECMAScript 201x

global is

• writable

• non-enumerable

• configurable

37

Page 38: Moving Web forward: Part I — ECMAScript 201x

38

Rest properties

Spread properties

Page 39: Moving Web forward: Part I — ECMAScript 201x

Asynchronous iteration

39

Sync iterator:

Async iterator:

Page 40: Moving Web forward: Part I — ECMAScript 201x

Asynchronous iteration

40

• Symbol.asyncIterator well-known symbol

• for-await-of statement

Page 41: Moving Web forward: Part I — ECMAScript 201x

Async generator functions

41

Page 42: Moving Web forward: Part I — ECMAScript 201x

Definitely ES2018

or never

or later

42

Page 43: Moving Web forward: Part I — ECMAScript 201x

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

Page 44: Moving Web forward: Part I — ECMAScript 201x

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

Page 45: Moving Web forward: Part I — ECMAScript 201x

Public class fields

• static properties

• class fields

45

Page 46: Moving Web forward: Part I — ECMAScript 201x

Static properties

46

Page 47: Moving Web forward: Part I — ECMAScript 201x

Class fields

47

Page 48: Moving Web forward: Part I — ECMAScript 201x

Decorators

48

@frozen class Foo { @configurable(false) @enumerable(true) method() {} }

decorators

Page 49: Moving Web forward: Part I — ECMAScript 201x

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

Page 50: Moving Web forward: Part I — ECMAScript 201x

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

Page 51: Moving Web forward: Part I — ECMAScript 201x

Stage 1• of and from on collection constructors

• WeakRefs

• Frozen Realms

• Private Fields

• Observable

• Cancelable Promises

51

Page 52: Moving Web forward: Part I — ECMAScript 201x

Private fields

52

Page 53: Moving Web forward: Part I — ECMAScript 201x

Observable

53

Page 54: Moving Web forward: Part I — ECMAScript 201x

Observable

54

Page 55: Moving Web forward: Part I — ECMAScript 201x

Observable

55

Page 56: Moving Web forward: Part I — ECMAScript 201x

Observable

56

Page 57: Moving Web forward: Part I — ECMAScript 201x

Observable

57

Page 58: Moving Web forward: Part I — ECMAScript 201x

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

Page 59: Moving Web forward: Part I — ECMAScript 201x

Stage 0

• don’t use it in production

• it is not a maturity stage

• no guarantees

59

Page 60: Moving Web forward: Part I — ECMAScript 201x

babel-preset-env✨ Autoprefixer for Babel ✨

60

Page 61: Moving Web forward: Part I — ECMAScript 201x

babel-preset-env• browserlist

• ECMAScript compatibility tables (ES2015 and ES2016+ tabs)

• Babel plugins

61

Page 62: Moving Web forward: Part I — ECMAScript 201x

babili✨ ES6+ minificator ✨

62

Page 63: Moving Web forward: Part I — ECMAScript 201x

Thank you@chicoxyzzy

63