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

Denoの仕組み / How deno works as TypeScript runtime

linyows
August 23, 2021

Denoの仕組み / How deno works as TypeScript runtime

Fukuoka.ts#3 Aug 23, 2021 での発表です。

linyows

August 23, 2021
Tweet

More Decks by linyows

Other Decks in Programming

Transcript

  1. Fukuoka.ts #3 TS How deno works as TS runtime Tomohisa

    Oda — GMO Pepabo, Inc. / Aug 23th 2021
  2. Fukuoka.ts #3 linyows / Tomohisa Oda GMO Pepabo, Inc.: Senior

    Engineering Lead Blog: https://tomohisaoda.com 2
  3. Fukuoka.ts #3 3 Private Projects ΞϓϦέʔγϣϯࣗ਎͕ϦϙδτϦ͔ Β࠷৽ͷίʔυΛݕ஌ͯࣗ͠ಈͰσϓϩ ΠͱσϦόϦʔΛߦ͏πʔϧ linuxͷuser໊લղܾΛGitHubͷ Teamϝϯόʔ΍ϦϙδτϦͷΞΫηε

    ݖݶऀ͔Βߦ͏πʔϧ ϝʔϧૹ৴༻ͷಁաܕSMTPϓϩΩγͰ ϦΫΤετͱϨεϙϯεΛϩά΍σʔλ ϕʔεʹग़ྗ͢Δ͜ͱ͕Ͱ͖Δ New!!
  4. Fukuoka.ts #3 Denoͱ͸ʁ Deno͸ɺ@ry͕nodejsͰޙչ͍ͯ͠Δ͜ͱʢgyp΍node_modules΍promiseͳͲʣ͔ΒϓϩδΣΫ τΛ։࢝ɻV8Λϥοϓͨ͠Rust੡ͷTypeScript/JavaScript ϥϯλΠϜɻϥϯλΠϜ୯ମͱ͍͏ΑΓ͸ ͦΕΛؚΊͨπʔϧνΣʔϯɻ ҎԼɺΦϑΟγϟϧ͔Βɻhttps://deno.land/ • σϑΥϧτͰηΩϡΞ

    👉 deno run —allow-net —allow-read foo.ts • TypeScriptΛͦͷ··αϙʔτ 👉 tsc΍swc͕಺෦Ͱ࢖ΘΕ͍ͯΔ • γϯάϧϑΝΠϧͷΈͰಈ͘ 👉 deno compile foo.ts => file • ґଘؔ܎ݕࠪ΍ϑΥʔϚοτ༻ͷπʔϧͳͲಉࠝ 👉 deno info, deno fmt, deno test… • ಈ࡞อূͷඪ४Ϟδϡʔϧ 5
  5. Fukuoka.ts #3 Denoͷߏ੒ ෳ਺ͷίϯϙʔωϯτʹ෼ׂ͞Ε͍ͯͯɺ3rd Party͕ଟ༻͞Ε͍ͯΔɻ3rd Party͕ॏཁͳϙδγϣϯʹΔͨΊɺͦΕΒΛִ཭͢ΔϨΠϠʔߏ੒ʹͳͬ ͍ͯΔɻ deno_core(rusty_v8(v8(js & wasm)))

    Έ͍ͨͳײ͡ɻ • RustͷඇಉظϥϯλΠϜTokioΛ࢖͍ͬͯΔ • RustͱV8ͷBindingsʹ͸rusty_v8͕୲͍ͬͯͯͦΕ΋3rd Party • TS͸ඪ४Ϟδϡʔϧ 6
  6. Fukuoka.ts #3 V8ͱRustͷ໾ׂ෼୲ deno͸༷ʑͳίϯϙʔωϯτ͕͋ΓଞݴޠͰߏ੒͞Ε͍ͯΔɻ௒ઈࡶʹ͍͏ͱɺdeno͸V8ͷϥούʔ Ͱ͋Δ͕ɺRust͸ԿΛ͍ͯ͠Δͷ͔ɻ • V8͕Ͱ͖Δͷ͸Sandbox಺ͰECMAScriptͷղऍͰɺͦΕҎ֎ͷωοτϫʔΫ΍ϑΝΠϧૢ࡞ͳͲ͸ RustଆͰߦ͏ • ωοτϫʔΫ΍ϑΝΠϧૢ࡞͸ηΩϡϦςΟͷ੍ݶΛड͚ɺ࣮ߦ࣌ʹڐՄ͓ͯ͘͠ඞཁ͕͋Δ

    • V8ͱRust͸͋Β͔͡Ίఆٛͨؔ͠਺Ͱ૬ޓʹ΍ΓͱΓ͢Δ͜ͱ͕Ͱ͖Δ • σʔλ͸ϙΠϯλʔΛ࢖͍ίϐʔ͸͠ͳ͍ʢจࣈྻ΍਺஋Ͱ͸ͳ͍ͷͰύϑΥʔϚϯεͷ໰୊͕͓͖ͳ ͍ʣ • ॳظ͸RustͰͳ͘GoͰ࣮૷͞Ε͍͕ͯͨGoͱV8ͷ̎ॏGCͷ໰୊͔ΒRustʹஔ͖׵͑ΒΕͨ 8
  7. Fukuoka.ts #3 ·ͱΊ • Deno͸node.jsͰͷܦݧ͔ΒV8ͱͷ݁߹ʹந৅ϨΠϠʔΛ࡞Δ͜ͱͰ҆શʹ͍ͯ͠Δ • V8Ҏ֎ʹ΋tokio΍tscɺswcͳͲ3rd Party͕ଟ͘࢖ΘΕҰൠతͳݴޠϥϯλΠϜͰ͸ෳࡶ Ͱ͋Δ͕ίϯϙʔωϯτΛࡉ͔͘෼ׂ͢Δ͜ͱͰӨڹΛখ͍ͯ͘͞͠Δ •

    ϑΝΠϧૢ࡞΍ωοτϫʔΫͳͲV8ͷείʔϓ֎͸rust͕୲͍ͬͯͯϗϫΠτϦετͷη ΩϡϦςΟͰ҆શΛ୲อ͍ͯ͠Δ • V8ͱRustͷؒʹσʔλίϐʔ͸ͳͦ͘ͷଞͷύϑΥʔϚϯεʹ஫ྗͰ͖ΔΑ͏ʹ͍ͯ͠Δ 15