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

Node.js / Deno 徹底討論の時のスライド

Node.js / Deno 徹底討論の時のスライド

2022/3/17 Node学園38時限目のスライドです。

Yosuke Furukawa

March 31, 2022
Tweet

More Decks by Yosuke Furukawa

Other Decks in Programming

Transcript

  1. ͜ͷରஊͷૂ͍
    • ʮ஌Βͳ͍͠ɺͲͬͪΛબΜͩΒྑ͍͔Θ͔Βͳ͍ʯ
    ͱ͍͏ঢ়گΛݮΒ͢ɻ
    ஌্ͬͨͰ/PEFKTΛ࢖͏
    ஌্ͬͨͰٕज़બ୒ͱͯ͠ਖ਼
    ͍͠ํΛέʔεʹ߹Θͤͯऔ
    ࣺબ୒Ͱ͖Δ
    ஌Βͳ͍͠ɺͲͪΒΛબΜͩ
    Βྑ͍͔Θ͔Βͳ͍
    ஌্ͬͨͰ%FOPΛ࢖͏

    View full-size slide

  2. Node.js ͷྑ͍ͱ͜Ζ
    deno ͷྑ͍ͱ͜Ζ

    View full-size slide

  3. Α͍ͱ͜Ζ
    • Node.js: αϙʔτମ੍ɺಛʹLTS͕͋Γɺ2೥ؒαϙʔτ͞ΕΔ
    • deno: πʔϧ͕ຊମʹϏϧτΠϯͰؚ·Ε͍ͯͯɺೖΕͨ͋ͱ͍͖ͳ
    Γ։ൃ͕ਐΊΒΕΔ
    • ಛʹܕ͸ඇৗʹڧ͍

    View full-size slide

  4. Node.js ͷѱ͍ͱ͜Ζ
    deno ͷѱ͍ͱ͜Ζ

    View full-size slide

  5. ΘΔ͍ͱ͜Ζ
    • deno: αϙʔτମ੍͕ऑ͍
    • deno: ࠷৽ʹ্͛ͯ͘Εͱ͍͏ݴ͍ํʹͳΔ
    • ͪΐͬͱલͷϚΠφʔόʔδϣϯΛαϙʔτͯ͠΄͍͠ͱ͍͏࿩ʹͳΓ͕ͪ
    • ࠷৽ʹ͍ͭͯདྷΕΔମྗ͕ඞཁʹͳΔ
    • Node.js: ܕͷαϙʔτ
    • Node.js: ϞδϡʔϧγεςϜ͕ΰλΰλ
    • CJS / ESM ͷରԠʹ͍ͭͯ

    View full-size slide

  6. Node.js ͷվળ఺
    deno ͷվળ఺

    View full-size slide

  7. վળ఺
    • Node.js => Deno : Deno ͬͯ npm ϞδϡʔϧΛαϙʔτ͢Δͬͯݴ͚ͬͯͨͲɺΰλΰλ͸
    Ͳ͏͢Δͷ͔ʁ
    • Deno: ΰλΰλ͝ͱड͚ೖΕͯ΍Δ
    • Node.js: ͦͨ͠ΒͲͬͪ΋ΰλΰλʹͳΔͷͰ͸ɾɾɾʁ
    • import fs from "node:fs"; ͜Μͳײ͡ʁ
    • import fs from "https://deno.land/std/fs/mod.ts";
    • Deno: ίϛϡχςΟଆ͸ npm Ϟδϡʔϧͷޓ׵ੑʹ͸൓ରҙݟͩͬͨɻͰ΋Ϧʔμʔ͸ޓ׵
    ੑΛਪਐͨ͠ɻͻͷ͞Θ͞Μͷҙݟ͸͸͖ͬΓ۠ผ͢ΔϥΠϯ͕͋Ε͹ྑ͍ͱࢥ͍ͬͯΔ

    View full-size slide

  8. Web Standard ΁ͷऔΓ૊Έ

    View full-size slide

  9. Web Standard ΁ͷऔΓ૊Έํ
    • Deno: Web Standard ΛੵۃతʹऔΓೖΕΑ͏ͱ͢Δɻ
    • ੵۃతʹऔΓೖΕա͗ͳͷͰ͸ʁ
    • ·ͩWICGͷϨϕϧͰऔΓೖΕΔͷ͸͍ͩͿૣ͗͢Δؾ͕͢Δ

    View full-size slide

  10. Tooling ʹ͍ͭͯ

    View full-size slide

  11. tooling
    • deno: deno task ͱ͍͏ͷ͕ೖͬͨ (npm run Έ͍ͨͳ΍ͭ)
    • deno.json ʹίϚϯυΛॻ͘ͱ࣮ߦ͞ΕΔ

    View full-size slide

  12. Permission ʹ͍ͭͯ

    View full-size slide

  13. Permission ʹ͍ͭͯ
    • mizchi: ࠷ॳ͸ؤு͚ͬͯͭͯΔɺͰ΋ import ͨ͠ઌͰଞͷϝϯόʔ͔Β permission ͕ଞʹඞཁʹͳͬͯ͘Δɻ
    • ѱҙͷ͋Δϝϯόʔ͕ͦΕΛݴ͖ͬͯͨΒ࣮ࡍ๷͙ͷ͸೉͍͠
    • kt3k: mizchi ͞ΜʢίʔυΦʔφʔʣ͕ඞཁͱࢥͬͨ permission ͚ͩ෇༩͢Ε͹ྑ͍ͷͰɺͦΕΛڧݻʹकΔ΂͖
    • mizchi: ͦΕ͸Θ͔Δ͕ɺαϓϥΠνΣʔϯΞλοΫΛकΔʹ͸࡞Δଆͱ࢖͏ଆͷ྆ํͰͷέΞ͕ඞཁͳͷͰ͸ͳ͍͔ͱࢥ͍ͬͯ
    Δ
    • ݖݶ͕ංେԽ͢Δͷ͸ΤίγεςϜͷதͰΑ͋͘Δ΋ͷɺ Android ͱ͔͸ΞϓϦΛΠϯετʔϧ͢Δͱ͖ʹશͯͷݖݶΛཁ
    ٻ͖ͯͨ͠Γ͢Δ
    • martin: Node.js policy ػೳ͕͋ΔɻηΩϡϦςΟ͸ίϛϡχςΟͷ໰୊Ͱ͋ͬͯҰͭͷςʔϚͰ͋Δ
    • policy.json ͰΞϐʔϧͰ͖ΔͷͰ͋Ε͹ͦΕΛίϯτϦϏϡʔτͯ͠ଞͷਓʹͪΌΜͱηΩϡϦςΟ΁ͷ഑ྀΛΞϐʔϧͨ͠
    ͍
    • ͨͩ࢒೦ͳ͕Βࠓ͸ policy ͷػೳ͸ͦ͜·Ͱͳ͍ͬͯͳ͍ɻ

    View full-size slide

  14. Node.js ͷਪ͠৽ػೳ
    deno ͷਪ͠৽ػೳ

    View full-size slide

  15. ਪ͠ػೳ
    • ݹ઒: Single Executable Application
    • Martin: webcrypto ͕࣮૷͞ΕͨΑʂ
    • kt3k: Deno task ͕࣮૷͞ΕͨΑʂ
    • mizchi: deno fetch ͕ϩʔΧϧʹରͯ͠Ͱ͖Δ wasmpack Λͦͷ··
    ಡΈࠐΊͨ

    View full-size slide

  16. Governance ʹ͍ͭͯ

    View full-size slide

  17. Governance ʹ͍ͭͯ
    • deno: BDFL ϞσϧɺϦʔμʔ͕ܾఆΛ͢Δ
    • node.js: Open Governance ϞσϧɺϦʔμʔෆࡏɺεςΞϦϯάίϛοςΟʔ͕
    ܾΊΔɻ
    • martin: deno ͸ inc Ͱɺձࣾʹͳ͍ͬͯΔɺϦʔμʔ͕ܾΊΔ͚ͩͰ͸ͳ͓ͯۚ͘
    ʹΑͬͯࠨӈ΋͞ΕΔ
    • kt3k: ͦΕ͸͔ͨ͠ʹͦ͏ɻϢʔβʔ਺Λ্͛ΔΑ͏ʹͯ͠ɺ͓ۚΛՔ͙ඞཁ͕͋Δ
    • node ͷϞδϡʔϧΛαϙʔτ͢Δͷ͸Ϣʔβʔ਺Λ্͛Δඞཁ͕͋ΔͨΊ

    View full-size slide

  18. Node.js ͷࠓޙ
    deno ͷࠓޙ

    View full-size slide

  19. ࠓޙ
    • mizchi: ͓ޓ͍௥Ճ͢Δػೳ͕ࣅ͍ͯΔɺӨڹΛड͚͍͋ͬͯΔɺ޷͖ͳํΛબ΂͹Α͍ͱ͍͏ະདྷʹͳΔɻ
    • ઈରަΘΒͳ͍ϥΠϯΛMicrosoft͕ʹ͗ͬͯΔɻ
    • ֦ுࢠͷলུՄ൱ϥΠϯ
    • kt3k: Node.jsޓ׵͕Ͱ͖ΔΑ͏ʹͳΓɺϢʔβʔ͕denoʹ૿͑Δɺདྷ೥͸΋ͬͱ፰߅͢Δɻ
    • martin: Node.js ͷະདྷ͸ Web Standard ͷػೳ͕΋ͬͱ૿͍͑ͯ͘ɻfetch ͷଞʹ΋ Event Emitter ͱ͔৭ʑ૿
    ͍͑ͯ͘ɻ΋ͬͱϒϥ΢βϓϥοτϑΥʔϜؒͷޓ׵ੑ͕ߴ͘ͳΔ͸ͣɻ
    • test runner ͕ Node.js ʹೖΔ
    • deno ͷ࡞ઓ => deno inc ͕ microsoft ʹങΘΕΔ
    • furukawa:

    View full-size slide