JavaScriptã®ç¾ç¶ã¨å°æ¥ã¨ããã¿ã¤ãã«ã§çºè¡¨ãã¦ãã
the present and future of JavaScript
æ
å ±å¦çå¦ä¼ã®è¥æã®ä¼ã§çºè¡¨ãã¦ãã¾ããã
ä¸åç®ã®åå ã§ãäºåé£ç¶30minã®ã»ãã·ã§ã³ãããã¦é ãã¾ããã
ååã¯3å¹´åã«çºè¡¨ãã¦ãã®é ã¯ã¾ã å¦çã§ããð¨âð
å®ã¯ãã®é±ãã¹ã©ã¤ãã«ãæ¸ãã¦ããéããã³ã¯ã¼ãã§Node Interactiveã¨Nodeé¢ä¿è
ããã¤ã¾ãNode.js Collaborator Summitãéããã¦ã¾ããã
ãã¡ãã®æ
å ±ã¯ä»ã®æ¹ãä½ãããå ±åãã¦ãããã¨æãã¾ãã®ã§ããããæå¾
ãã¦ãã¾ãð
ãã¦ãããã§ã¯ã¹ã©ã¤ãã®å 容ãå°ãèªã¿ç ãã¾ããã
ECMAScriptã¨ã¯ï¼
ECMAScriptã¨ã¯ãEcma Internationalã«ãã£ã¦ç®¡çãããJavaScriptã®æ¨æºåä»æ§ã§ãã
JavaScriptã¨ã¯ãECMAScriptã«åºã¥ãå®è£
ãæãã¾ãã
ã¨ãã£ã·ã§ã³
ãã®ããã«é¸å®ãããä»æ§ãã¾ã¨ãããã®ãã¨ãã£ã·ã§ã³ã§ãã
1997/06ã«æåã®ECMAScript 1ãåºã¾ããã
ããã¦ã2015/06 ããã¯æ¯å¹´ã§ãããã«å¤ããã¾ããã (from ES2015)
TC39
ECMA-262ã¨ECMA-402ã管çãã¾ãã JSã®æ§æã¨å½éåAPIã§ãã
https://developer.mozilla.org/ja/docs/Web/JavaScript/Language_Resources
ããã®å§å¡ä¼ã¡ã³ãã¼ã¯åãã©ã¦ã¶ã®ä¸»è¦ãã³ãã¼ã¨ä¼ç¤¾(e.g. Airbnb, FaceBook, PayPal, Bocoup, etc...)ã§ãã
ã¾ããå§å¡ä¼ã¡ã³ãã¼ã®æ¨è¦ã§æå±ãã¦ãã人ããã¾ãã
TC39ããã»ã¹
æ¨æºåãããã¾ã§ã«5ã¤ã®ããã»ã¹ãè¸ãå¿
è¦ãããã¾ãã(stage-0 to stage-4)
ãã®stageã¯äºã¶æã«ä¸åãããã¼ãã£ã³ã°ã«ãããå¤åãã¦ãããstage-4ã«å
¥ã£ãã次ã®ãªãªã¼ã¹ã§æ£å¼ã«ä»æ§ã¨ãã¦çµã¿è¾¼ã¾ãã¾ãã
ä»å¹´ã®ã¹ã±ã¸ã¥ã¼ã«ã¯ä»¥ä¸ã®ã¨ããã§ãã
Dates | Location | Host |
2017-01-24 to 2017-01-26 | San Jose, CA | PayPal |
---|---|---|
2017-03-21 to 2017-03-23 | Portland, OR | Mozilla |
2017-05-23 to 2017-05-25 | New York, NY | |
2017-07-25 to 2017-07-27 | Redmond, WA | Microsoft |
2017-09-26 to 2017-09-28 | Boston, MA | Bocoup |
2017-11-28 to 2017-11-30 | San Francisco, CA | Airbnb |
å種stageã®èª¬æ
stage-0(Strawman)
ã¢ã¤ãã£ã¢ã®ãã§ã¤ãºã§ãã
ããã¯å§å¡ä¼ã¡ã³ãã¼ã§ã¯ãªãã¦ããæåºãå¯è½ã§ãã
æåºãã©ã¼ã ããæåºãã¾ãã
ããã¦ãããã¥ã¡ã³ããä½ããtc39/proposalsã®æ¹ã¸ãã®ãªã³ã¯ã追å ããPRãæåºããå¿
è¦ãããã¾ãã
stage-1(Proposal)
ããªãã£ã«ããã¢ããããæ½å¨çãªåé¡ã®ç¹å®ãå¿
è¦ã§ãã
ãã®ã¹ãã¼ã¸ã§ã¯ãã£ã³ããªã³ã¨å¼ã°ãããã®ãå¿
ãå¿
è¦ã§ãã
ãã£ã³ããªã³ã¯ãæåºè
ã¾ãã¯å
±åãã£ã³ããªã³(çæ¹ãTC39ã¡ã³ãã¼)ã§ãªããªãã¦ã¯æ¬¡ã®ã¹ãã¼ã¸ã«ã¯é²ãã¾ããã
stage-2(Draft)
ä»æ§ã«å«ã¾ããæåã®ãã¼ã¸ã§ã³ã§ãã
ãã®stageã«ãããã¨ã§ä»æ§ã¨ãã¦å«ã¾ããå¯è½æ§ãé«ãã§ãã
æ£å¼ãªæ§æè¨è¿°ã®è¿½å ãå¿
è¦ã§ãã
stage-3(Candidate)
ãã®ãããã¼ã¶ã«ã®çµç¤ã§ãã
å種ãã³ãã¼ã¨ã¦ã¼ã¶ããã®ãã£ã¼ãããã¯ãããã«æ±ãã¾ãã
ã¾ããæ£å¼ãªä»æ§ã®ããã¥ã¡ã³ãã¯å®æãã¦ãããTC39ã®ã¬ãã¥ã¯ã¼ã¨ECMAScriptã®ã¨ãã£ã¿ã«ãããã¬ãã¥ã¼ã¨ãµã¤ã³ãªããããå¿
è¦ãããã¾ãã
stage-4(Finished)
次ã®ãªãªã¼ã¹ã§æ£å¼ãªä»æ§ã¨ãã¦å«ã¾ããã§ãããã
test262ã«åæ ¼ãã¦ãã¦ããã©ã¦ã¶ãã³ãã¼ã®2ã¤ä»¥ä¸ã§å®è£
ãçµã¿è¾¼ã¾ããå¿
è¦ãå¿
ãããã¾ãã
ã¾ããECMAScriptã®ã¨ãã£ã¿ã¯ä»æ§æ¸ã«ç½²åãããå¿
è¦ãããã¾ãã
test262ãBabylonã«çµ±åããã¾ããã
Babylonã¨ã¯Babelã®JSãã¼ãµã§ãã
ä»åã®MTG(60th)ã§å¤æ´ãããããã¼ã¶ã«ä¸è¦§
ç´2é±éåã«å¤åãããããã¼ã¶ã«ã®ä¸è¦§ã§ãã
Proposal | Stage | Description |
mport.meta | 2 â 3 | |
---|---|---|
export ns from 'mod'; | 2 â N/A | it moved to https://github.com/tc39/ecma262/pull/1005 |
Array.prototype.flat{Map,ten} | 1 â 2 | |
throw Expressions | 1 â 2 | |
String.prototype.matchAll | 1 â 2 | |
Extensible numeric literals | 0 â 1 | |
First-Class Protocols | 0 â 1 | it was called `Interfaces` in stage-0 |
JSON superset | 0 â 1 | |
nullary coalescing | 0 â 1 | |
Partial application | 0 â 1 | |
Pipeline Operator | 0 â 1 | |
ArrayBuffer.transfer | N/A â 0 | |
Builtins.typeOf() and Builtins.is() | N/A â 0 | |
Object Shorthand Improvements | N/A â 0 |
ES2015 - ES2017
ã¹ã©ã¤ããè¦ã¦ãã ããã
ã¾ããããã¯ä¸ã®ä¸ã«æ²¢å±±ããè¨äºãããã®ã§çãã¾ãã
ES2018
ç¾å¨ãstage-4ã«ããã®ã¯ãTemplate Literal Revision
ã®ã¿ã¨ãªã£ã¦ãã¾ãã
Template Literal Revision
ES2015ã«ããString Templateã®ä¸ã«ãTagged Templateã¨ããæ¸ãæ¹ãããã¾ãããããã«ã¯å¶éãããã¾ããã
Tagged Templateã¨ããã®ã¯ãæåãªlibraryã ã¨styled-componentsãyo-yoãæ¡ç¨ãã¦ãã¾ãã
ãã®å¶éã¨ããã®ããLatexãwindowsã®path, 8é²æ°ã®ã¨ã¹ã±ã¼ããªã©ã表ç¾ã§ããªã(ã¨ã©ã¼ã§è½ã¡ã)åé¡ã§ãã
const tag = (obj) => ({ Raw: obj.raw, Cooked: obj }); tag`\u{4B}`; // ES2015 ~ // { Raw: [ '\\u{4B}' ], Cooked: [ 'K' ] } // ES2018 ~ tag`\uu ${1} \xx`; // a Unicode escape // { Raw: [ '\\uu ', ' \\xx' ], Cooked: [ undefined, undefined ] } tag`\100`; // an octal escape
ãã®ãªãªã¼ã¹ã§ã¯ããã®å¶éããªãããã¤ã¬ã®ã¥ã©ã¼ãªã¨ã¹ã±ã¼ãã¯undefined
ã¨ãã¦ãCookedã«å
¥ãããã¾ãã
åè£
ç¾å¨ãstage-3ã«ã¯ä»¥ä¸ã®ãããã¼ã¶ã«ããããES2018ã¨ãã¦çµã¿è¾¼ã¾ããå¯è½æ§ãé«ãã§ãã
- Asynchronous Iteration
- BigInt
- Class Fields
- global
- Function.prototype.toString revision
- import()
- import.meta
- Legacy RegExp features in JavaScript
- Optional catch binding
- Promise.prototype.finally
- RegExp Lookbehind Assertions
- RegExp named capture groups
- Rest/Spread Properties
- s (dotAll) flag for regular expressions
é¢ç½ãããªãããã¼ã¶ã«
èå³ãããããã¼ã¶ã«ã話ãã¾ããã
stage-1ãå¤ããSyntaxãå¤åããå¯è½æ§ãããã®ã§æ³¨æãã¦ãã ããã
Binary ASTã¯ä»ã®å ´æã§è©±ãã¾ãð
Class Fields
class Counter extends HTMLElement { x = 0; // public fields #y = 0; // private fields constructor() { super(); this.onclick = this.clicked.bind(this); } clicked() { this.x++; this.#y++; window.requestAnimationFrame(this.render.bind(this)); } render() { this.textContent = this.#y.toString(); } }
Promise.prototype.finally
let finished = false; fetch() .then((res) => { // finished = true; }) .catch((err) => { // finished = true; }) .finally(() => { finished = true; });
åãå¦çãthenã¨catchã§æ¸ããªãã¦è¯ããªãã¾ããã
Optional Chaining
Pipeline Operator
Partial Application Syntax
function add(x, y) { return x + y; } // before const addOne = add.bind(null, 1); // this, the left(x = 1), the right(y = undefined) addOne(2); // 3 // after const addOne = add(1, ?); // apply from the left(x) addOne(2); // 3 const addTen = add(?, 10); // apply from the right(y) addTen(2); // 12 const f = (...x) => x; const g = f(..., 9, ...); g(1, 2, 3); // [1, 2, 3, 9, 1, 2, 3] const res = a |> f(?, 1) |> g(?, 2); // const res = g(f(a, 1), 2);
ä»ã¾ã§ã¯ES5ã®bind
ã§é¨åé©ç¨ãã¦ãã¾ããããããããã¯?
ãããå ´åã«åºå®åããã¾ãã
ã¾ããspread operatorã§ãå±éã§ãã¾ãã
Promise.try
bluebirdã¨åããtryã§ãã
function getUserById(id) { return Promise.try(() => { if (typeof id !== 'number') { throw new Error('id must be a number'); } return db.getUserById(id); }); }
Temporal
æ¥ä»ã®è¨ç®çã®æ±ããç°¡åã«ãªãã¾ãã
let myCivilDate = new CivilDate(2016, 2, 29); let newCivilDate = myCivilDate.plus({years: 1, months: 2}); //results in civil date with value 2017-4-28
ã¾ã¨ã
- ECMAScriptã¯æ¯å¹´æ´æ°ããã¾ã
- 誰ã§ããããã¼ã¶ã«åºãããï¼ï¼
- 次ã®ãªãªã¼ã¹(ES2018)ã¯2018/06ã§ãï¼
宣ä¼
2017/11/25 - 26 ã§æ±äº¬Nodeå¦åç¥2017ãããã®ã§æ¯éæ¥ã¦ãã ããã;)
The End
ããã§ã¯JavaScriptã©ã¤ãã楽ããã§ï¼ð