Upgrade to Pro — share decks privately, control downloads, hide ads and more …

io.js 東京Node学園 15時限目

io.js 東京Node学園 15時限目

io.js 東京Node学園の15時限目の資料です。

D76231a2114896dfcc7b79ac69558b79?s=128

Yosuke Furukawa

February 10, 2015
Tweet

Transcript

  1. io.js !ZPTVLF@GVSVLBXB ౦ژ/PEFֶԂ࣌ݶ໨ࢿྉ

  2. !ZPTVLF@GVSVLBXB /PEFKT೔ຊϢʔβʔάϧʔϓ୅ද%F/"ॴଐ

  3. վΊ…

  4. !ZPTVLF@GVSVLBXB /PEFJPKT೔ຊϢʔβʔάϧʔϓ୅ද%F/"ॴଐ

  5. io.jsͱ͸Կ͔

  6. Node.jsͷ friendly fork

  7. friendly fork?? લ͸sporkͬͯॻ͍ͯ͋ͬͨ

  8. fork

  9. spork

  10. spork fork͸͢Δ͚ͲɺϑΥʔΫ΄Ͳઌ͕Θ͔Ε͍ͯͳ͍ɻ ࢥ͍͸ಉ͡ɺͱ͍͏ҙຯͰͷfriendly fork

  11. Node.jsͱͷҧ͍

  12. ϓϩδΣΫτͷऔΓ૊Έํ

  13. io.js͸ΦʔϓϯΨόφϯεϞσϧ issue΍featureͷղܾΛΦʔϓϯʹ͢Δ࢓૊Έ

  14. io.js͸ΦʔϓϯΨόφϯεϞσϧ ೋिؒʹҰճ͘Β͍ͷλΠϛϯάͰTC Meeting͕ߦΘΕɺϋϯάΞ΢τͷ࿥ ըͱٞࣄ࿥͕ల։͞ΕΔɻissue΍featureΛॲཧ͢Δͷ͸جຊతʹ߹੍ٞɺͨ ͩ͠ҙݟׂ͕ΕͨΒvoteͰܾΊΔɻ

  15. ΦʔϓϯΨόφϯεʹΑͬͯissue/ featureͷಁ໌ੑΛ֬อ͠ɺίϯτϦ Ϗϡʔτ͠΍͘͢͢Δ

  16. ΦʔϓϯΨόφϯεʹΑͬͯissue/ featureͷಁ໌ੑΛ֬อ͠ɺίϯτϦ Ϗϡʔτ͠΍͘͢͢Δ 1݄͚ͩͰ294ίϛοτ

  17. None
  18. ৽͘͠Committer͕6ਓ௥Ճ

  19. ΦʔϓϯΨόφϯεʹΑΔಁ໌ੑͷ֬อ ͱio.js΁ͷظ଴͔Βίϛοτ਺ɺίϯτ ϦϏϡʔλʔ਺͕૿͑ͯΞΫςΟϒʹɻ

  20. Node.jsͱͷ
 ػೳ໘Ͱͷҧ͍

  21. v8ͷόʔδϣϯ v4.1.0.14

  22. σϑΥϧτͰ࢖͑Δ let/const generators Binary/Octal Literal Template String Literal String new

    methods
  23. "use strict"; // const const koa = require('koa'); const app

    = koa(); // generator app.use(function *(next){ // let block scope let start = new Date; // yield ඇಉظݺͼग़͠ΛݮΒͤΔ yield next; let ms = new Date - start; // template string literal this.set('X-Response-Time', `${ms}ms`); }); app.use(function *(next){ let start = new Date; yield next; let ms = new Date - start; console.log(`{this.method} {this.url} - ms`); }); ͜Μͳ෩ʹॻ͚Δ
  24. --es_stagingΛ͚ͭΕ͹࢖͑Δ class Enhanced Object Literal Symbol.toStringTag

  25. "use strict"; // class class Person { constructor(name, age) {

    this.name = name this.age = age } getInfo() { let name = this.name; let age = this.age; let nextAge = this.age + 1; // enhanced object literal return { name, age, nextAge }; } } // @@toStringTag ෇͚ͳ͍ͱ [object object] Person.prototype[Symbol.toStringTag] = "Person"; var alice = new Person('alice', 13); var bob = new Person('bob', 15); console.log('' + alice); console.log(bob.getInfo()); ͜Μͳ෩ʹॻ͚Δ
  26. ҎԼͷػೳ͸ݸผʹϑϥά͕ඞཁ arrow_functions proxy Array new methods unicode ΋͏͠͹͓͠଴ͪΛɻ

  27. ৽API௥Ճ V8

  28. heap౷ܭ͕औΕΔ v8Φϓγϣϯ͕adhocʹઃఆͰ͖Δ

  29. "use strict"; const v8 = require('v8'); // gcΛtrace͢ΔΦϓγϣϯΛONʹ͢Δ v8.setFlagsFromString('--trace-gc'); for

    (let i=0; i< 10000; i++) { // ώʔϓͷ౷ܭΛऔΔ console.log(v8.getHeapStatistics()); global.gc(); } // 10ඵ͚ؒͩv8ͷGCΛtrace͠ɺ͕࣌ؒա͗ͨΒOFFʹ͢Δ setTimeout(function(){ v8.setFlagsFromString('--notrace-gc'); }, 10 * 1000);
  30. ͋ͱ͸ࡉ͔͘… simple creatation Stream
 assert.deepStrictEqual util.debuglog etc…

  31. Node.jsͱͷ
 ੑೳ໘Ͱͷҧ͍

  32. http͚ͩͰbench

  33. http͚ͩͰbench 4%΄Ͳ޲্ http_parser͸ಉ͡(2.3.0)ͷͨΊɺ
 ͦ͜·ͰมԽ͸ແ͍ɻ

  34. fs, net, tlsΛؚΊͯ

  35. fs, net, tlsΛؚΊͯ શମతʹ10%ఔ౓ͷ޲্ɻ

  36. ͦͷଞ io.jsͷ࠷৽ χϡʔε

  37. ͜ΕݟΕ͹
 ͍͍ͩͨҰൃ https://www.youtube.com/watch?v=1IOukA10QeQ

  38. Atom/NW.js͕io.jsʹ Travis CI΋ io.jsΛαϙʔτ Codeship΋io.jsΛαϙʔτ Tessel΋αϙʔτ…

  39. io.jsͷ׆ಈΛNode Ϣʔβʔάϧʔϓ͸Ͳ ͏͢Δ͔ɻ

  40. ੵۃతʹਐΊ͍ͯ͘

  41. ಛʹࠓ͸Nodeͱiojs Ͳͬͪ࢖ͬͨΒ͍͍ ͔ࠞཚͯ͠Δ࣌ظ

  42. օͰٞ࿦ΛਐΊ͍ͨ NodeͱiojsͷࠞཚΛ ೔ຊͰ͸๷͍͗ͨɻ

  43. iojsͷ຋༁Λߦ͏ nodeͱiojsͷੑೳΛܧଓͯ͠ଌΔ ΑΓΞΫςΟϒʹٞ࿦Λߦ͑ΔΑ ͏ʹ͢Δ ۩ମతʹ

  44. https://iojs-jp-slack.herokuapp.com/