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

ある日「Webエンジニアなら、Webサーバーは作れますよね」と言われたら? ~ 3つのJVM言語で作って学ぶ

ある日「Webエンジニアなら、Webサーバーは作れますよね」と言われたら? ~ 3つのJVM言語で作って学ぶ

技育CAMP 2021-05-20 の発表資料です。

9aba2147bb6e43333fcc42e2afc570f2?s=128

Shunsuke Tadokoro

May 20, 2021
Tweet

Transcript

  1. ͋Δ೔
 
 ͱݴΘΕͨΒʁ ʙͭͷ+7.ݴޠͰ࡞ֶͬͯͿʙ ٕҭ$".1 !UPEPLS 8FCΤϯδχΞͳΒ
 8FCαʔόʔ͸࡞Ε·͢ΑͶ

  2. ഑ଐ͞Εͯ਺ϲ݄͕ܦͬͨ͋Δ೔ͷ͜ͱ ͋Δ೔ɺَڧ͍ઌഐΤϯδχΞ͕χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠

  3. ഑ଐ͞Εͯ਺ϲ݄͕ܦͬͨ͋Δ೔ͷ͜ͱ ͋Δ೔ɺَڧ͍ઌഐΤϯδχΞ͕χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠ ాॴ͘Μ͸8FCΤϯδχΞͩΑͶʁ

  4. ഑ଐ͞Εͯ਺ϲ݄͕ܦͬͨ͋Δ೔ͷ͜ͱ ͋Δ೔ɺَڧ͍ઌഐΤϯδχΞ͕χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠ ాॴ͘Μ͸8FCΤϯδχΞͩΑͶʁ ϋΠʂ

  5. ഑ଐ͞Εͯ਺ϲ݄͕ܦͬͨ͋Δ೔ͷ͜ͱ ͋Δ೔ɺَڧ͍ઌഐΤϯδχΞ͕χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠ ాॴ͘Μ͸8FCΤϯδχΞͩΑͶʁ 8FCΤϯδχΞͬͯ͞ɺ8FCΤϯδχΞ͡ΌΜʁ ϋΠʂ

  6. ഑ଐ͞Εͯ਺ϲ݄͕ܦͬͨ͋Δ೔ͷ͜ͱ ͋Δ೔ɺَڧ͍ઌഐΤϯδχΞ͕χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠ ాॴ͘Μ͸8FCΤϯδχΞͩΑͶʁ 8FCΤϯδχΞͬͯ͞ɺ8FCΤϯδχΞ͡ΌΜʁ 8FCαʔόʔ࡞Βͳ͍ͱʂʂʂ ϋΠʂ

  7. ഑ଐ͞Εͯ਺ϲ݄͕ܦͬͨ͋Δ೔ͷ͜ͱ ͋Δ೔ɺَڧ͍ઌഐΤϯδχΞ͕χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠ ాॴ͘Μ͸8FCΤϯδχΞͩΑͶʁ 8FCΤϯδχΞͬͯ͞ɺ8FCΤϯδχΞ͡ΌΜʁ 8FCαʔόʔ࡞Βͳ͍ͱʂʂʂ ϋΠʂ ΞοɺϋΠ

  8. ͓࿩͢͠Δ͜ͱ w 8FCαʔόʔͬͯԿͯ͠Δͷʁ w 4DBMB $MPKVSFʹ͍ͭͯ w 8FCαʔόʔΛ࡞Γͳ͕Βͭͷ+7.ݴޠΛֶ΅͏ w ͬ͘͟ΓΞʔΩςΫνϟ

    w ֤ݴޠͰ࣮૷ͯ͠ΈΔ w 4PDLFUͷѻ͍ w ਖ਼نදݱ w จࣈྻͷѻ͍ w Ϧιʔεͷ؅ཧ w ฒྻॲཧ w 8FCαʔόʔΛ࡞ͬͯɺԿΛಘͨʁ
  9. ͜͏ͯ͠
 8FCαʔόʔΛ࡞Δ೔ʑ͕
 ࢝·ͬͨ

  10. ͱ͸͍͑

  11. 8FCαʔόʔͬͯԿͯ͠Δͷʁ

  12. 8FCαʔόʔ͕΍͍ͬͯΔ͜ͱ w ΫϥΠΞϯτ͔Βͷ઀ଓΛ଴ͪड͚Δ w ΫϥΠΞϯτ͔ΒૹΒΕ͖ͯͨ)551ϦΫΤετΛύʔε͢Δ w ϦΫΤετʹج͍ͮͯ)551ϨεϙϯεΛੜ੒͢Δ w ΫϥΠΞϯτʹϨεϙϯεΛฦ͢

  13. )551ͷن֨Λཧղ͠Α͏ ௐ΂෺Λ͍ͯ͠Δͱɺ·ͨͯ͠΋َڧ͍ઌഐΤϯδχΞ͕
 χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠

  14. )551ͷن֨Λཧղ͠Α͏ ௐ΂෺Λ͍ͯ͠Δͱɺ·ͨͯ͠΋َڧ͍ઌഐΤϯδχΞ͕
 χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠ ʢʮ)551Θ͔Γ΍͘͢ʯͰݕࡧͱʣ

  15. )551ͷن֨Λཧղ͠Α͏ ௐ΂෺Λ͍ͯ͠Δͱɺ·ͨͯ͠΋َڧ͍ઌഐΤϯδχΞ͕
 χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠ 8FCΤϯδχΞͳΒҰ࣍৘ใʹ౰ͨΒͳ͍ͱʂ ʢʮ)551Θ͔Γ΍͘͢ʯͰݕࡧͱʣ

  16. )551ͷن֨Λཧղ͠Α͏ ௐ΂෺Λ͍ͯ͠Δͱɺ·ͨͯ͠΋َڧ͍ઌഐΤϯδχΞ͕
 χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠ 8FCΤϯδχΞͳΒҰ࣍৘ใʹ౰ͨΒͳ͍ͱʂ 3'$Λಡ΋͏ͥʂʂʂ ʢʮ)551Θ͔Γ΍͘͢ʯͰݕࡧͱʣ

  17. )551ͷن֨Λཧղ͠Α͏ ௐ΂෺Λ͍ͯ͠Δͱɺ·ͨͯ͠΋َڧ͍ઌഐΤϯδχΞ͕
 χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠ 8FCΤϯδχΞͳΒҰ࣍৘ใʹ౰ͨΒͳ͍ͱʂ 3'$Λಡ΋͏ͥʂʂʂ ʢʮ)551Θ͔Γ΍͘͢ʯͰݕࡧͱʣ ΞοɺϋΠ

  18. )551ͷن֨Λཧղ͠Α͏ ௐ΂෺Λ͍ͯ͠Δͱɺ·ͨͯ͠΋َڧ͍ઌഐΤϯδχΞ͕
 χίχί͠ͳ͕Β࿩͔͚͖ͯͨ͠ 8FCΤϯδχΞͳΒҰ࣍৘ใʹ౰ͨΒͳ͍ͱʂ 3'$Λಡ΋͏ͥʂʂʂ ʢʮ)551Θ͔Γ΍͘͢ʯͰݕࡧͱʣ ΞοɺϋΠ ʢ3'$JTԿʣ

  19. 3'$ʢ3FRVFTU'PS$PNNFOUTʣ w *&5'ʹΑΔٕज़࢓༷ͷอଘɺެ։ܗࣜ w ϓϩτίϧ΍ϑΝΠϧϑΥʔϚοτͳͲ͕த৺ w )551͸3'$d

  20. IUUQTUPPMTJFUGPSHIUNMSGD

  21. IUUQIUUQXHPSH

  22. ؆қͳ࣮૷ͳΒ਺ඦߦఔ౓👍

  23. 1ZUIPOͷ4JNQMF)5514FSWFS w 1ZUIPOͷ4JNQMF)5514FSWFSͷڍಈΛࢀߟʹ͢Δͷ΋ྑ͍ w ܥ w ܥ $ python -m

    SimpleHTTPServer $ python -m http.server
  24. w 4DBMB w +BWB w 1ZUIPO w $MPKVSF w $PNNPO-JTQ

    w &MJYJS w %BSU
  25. w 4DBMB w +BWB w 1ZUIPO w $MPKVSF w $PNNPO-JTQ

    w &MJYJS w %BSU
  26. 8FCαʔόʔΛ࡞Γͳ͕Β ͭͷ+7.ݴޠΛֶ΅͏ʂ

  27. 4DBMB$MPKVSF

  28. 4DBMB

  29. 4DBMB w +BWBͱͷ૬ޓӡ༻ੑ w γʔϜϨεͳݺͼग़͠ɺ+BWBඪ४ϥΠϒϥϦͷ࠶ར༻ w ؆ܿੑ w লུՄೳͳߏจɺܕਪ࿦ɺڧྗͳඪ४ϥΠϒϥϦ w

    ந৅౓ͷߴ͍ίʔυɺ৽੍͍͠ޚߏจΛఆٛͰ͖Δදݱྗ w 8IBUͷڧௐɺ)PXͷӅณ w ੩తܕ෇͚ w ݕূՄೳੑɺϦϑΝΫλͷ͠΍͢͞ɺυΩϡϝϯτੑ
  30. IUUQTXXXMJIBPZJDPNQPTU'SPN'JSTU1SJODJQMFT8IZ4DBMBIUNM

  31. "$PNQJMFE-BOHVBHFUIBUGFFMT%ZOBNJD requests.post( "https://api.github.com/repos/lihaoyi/test/issues", data = ujson.Obj("title" -> "hello"), headers =

    Map("Authorization" -> s"token $token") )
  32. 4DBMBܕͷදݱྗ // `@`͔Β࢝·ͬͯ3จࣈҎ্16จࣈҎ಺ɺ@admin΍@Admin͸ڐ༰͠ͳ͍ type UserIdRule = StartsWith["@"] And MinSize[3] And

    MaxSize[16] And Not[MatchesRegex["(?i)@admin"]] val userId1: String Refined UserIdRule = "@todokr" // ҎԼ͸ίϯύΠϧΤϥʔ val userId2: String Refined UserIdRule = "@admin" val userId3: String Refined UserIdRule = "todokr" val userId4: String Refined UserIdRule = "@uryyyyyyyyyyyyyy"
  33. IUUQTFOHJOFFSJOHWJTJPOBMJODCMPHTDBMBSFpOFEOFXUZQF

  34. $MPKVSF

  35. $MPKVSF w -JTQ w จ๏͕গͳ͍ɺσʔλͱͯ͠ͷίʔυ w ؔ਺ܕϓϩάϥϛϯάͷͨΊͷݴޠ w ୈҰڃؔ਺ɺΠϛϡʔλϒϧͳσʔλߏ଄ɺ࠶ؼతͳϧʔϓ w

    +BWBͱͷ૬ޓӡ༻ੑ w ฒߦॲཧͷͨΊʹઃܭ w 3&1-Λ׆͔ͨ͠ΠϯλϥΫςΟϒΠϯΫϦϝϯλϧͳ։ൃ
  36. ϙʔϧɾάϨΞϜ 7JBXFC૑ۀऀ :$PNCJOBUPS૑ઃऀ IUUQTVQMPBEXJLJNFEJBPSHXJLJQFEJB DPNNPOTFF1BVMHSBIBN@YKQH

  37. -JTQͰྑ͍ϓϩάϥϜ͕ॻ͚ΔͳΒɺ࢖͏΂͖ͳΜͩɻ ͦ͏Ͱͳ͍ͳΒ͍͍ͬͨԿͷ໾ʹཱͭ ϙʔϧɾάϨΞϜ 7JBXFC૑ۀऀ :$PNCJOBUPS૑ઃऀ IUUQTVQMPBEXJLJNFEJBPSHXJLJQFEJB DPNNPOTFF1BVMHSBIBN@YKQH

  38. ී௨ͷౕΒͷ্Λߦ͚ɻ -JTQͰྑ͍ϓϩάϥϜ͕ॻ͚ΔͳΒɺ࢖͏΂͖ͳΜͩɻ ͦ͏Ͱͳ͍ͳΒ͍͍ͬͨԿͷ໾ʹཱͭ ϙʔϧɾάϨΞϜ 7JBXFC૑ۀऀ :$PNCJOBUPS૑ઃऀ IUUQTVQMPBEXJLJNFEJBPSHXJLJQFEJB DPNNPOTFF1BVMHSBIBN@YKQH

  39. ී௨ͷౕΒͷ্Λߦ͚ɻ -JTQͰྑ͍ϓϩάϥϜ͕ॻ͚ΔͳΒɺ࢖͏΂͖ͳΜͩɻ ͦ͏Ͱͳ͍ͳΒ͍͍ͬͨԿͷ໾ʹཱͭ :BIPPʹച٫ ϙʔϧɾάϨΞϜ 7JBXFC૑ۀऀ :$PNCJOBUPS૑ઃऀ IUUQTVQMPBEXJLJNFEJBPSHXJLJQFEJB DPNNPOTFF1BVMHSBIBN@YKQH

  40. ී௨ͷౕΒͷ্Λߦ͚ɻ -JTQͰྑ͍ϓϩάϥϜ͕ॻ͚ΔͳΒɺ࢖͏΂͖ͳΜͩɻ ͦ͏Ͱͳ͍ͳΒ͍͍ͬͨԿͷ໾ʹཱͭ Θͨ͠ ී௨ͷϓϩάϥϚ -JTQͰ΢ΣϒαʔϏεΛͭ͘Δͱ :BIPPʹԯԁͰങͬͯ΋Β͑Δʂʂʂ :BIPPʹച٫ ϙʔϧɾάϨΞϜ 7JBXFC૑ۀऀ

    :$PNCJOBUPS૑ઃऀ IUUQTVQMPBEXJLJNFEJBPSHXJLJQFEJB DPNNPOTFF1BVMHSBIBN@YKQH
  41. ίϯηϓτ͕໘ന͍ w ঢ়ଶʹ͍ͭͯͷߟ͑ํɺ*EFOUJUZ 4UBUF 7BMVFͷ෼཭ w γϯϓϧ͞ʹ͍ͭͯ ͍Ζ͍Ζܹࢗత

  42. IUUQTKBQBODMPKVSJBOTHJUIVCJPDMPKVSFTJUFKBBCPVUSBUJPOBMF

  43. IUUQTKBQBODMPKVSJBOTHJUIVCJPDMPKVSFTJUFKBBCPVUSBUJPOBMF

  44. IUUQTFFETJODPNKBTJNQMJDJUZNBUUFST

  45. IUUQCPYPGQBQFSTIBUFOBCMPHDPNFOUSZTJNQMF@NBEF@FBTZ

  46. -JTQͷγϯλοΫε ׅހͷ࢝·Γ͔ΒऴΘΓ·Ͱ͕୯Ґ (ԿΒ͔ͷॲཧ ॲཧͷର৅ͳͲ…)

  47. $MPKVSF͸Χοίͷछྨ͕ଟ͘ɺಡΈ΍͍͢ ͨͱ͑͹ؔ਺ͷҾ਺ $PNNPO-JTQ 4DIFNF $MPKVSF (defun square (x) (* x

    x)) (define (square x) (* x x)) (defn square [x] (* x x))
  48. 😌 େৎ෉

  49. 😌 ৴͍ͯͩ͘͡͞

  50. جຊจ๏Ͱ΢ΥʔϛϯάΞοϓ

  51. ࢛ଇԋࢉ

  52. ࢛ଇԋࢉ 12 + 40 10 - 1 2 * 3

    5 / 2 +BWB 4DBMB
  53. ࢛ଇԋࢉ 12 + 40 10 - 1 2 * 3

    5 / 2 +BWB 4DBMB (+ 12 40) (- 10 1) (* 2 3) (/ 5 2) ; -> 5/2 ෼਺Λѻ͏Ratioܕ $MPKVSF
  54. ม਺એݴ

  55. ม਺એݴ int x = 10; +BWB

  56. ม਺એݴ int x = 10; +BWB val x = 10

    val x: Int = 10 4DBMB
  57. ม਺એݴ int x = 10; +BWB val x = 10

    val x: Int = 10 4DBMB (def x 10) (let [y 10] (+ y 3)) ; y͸letͷׅހ಺͚ͩͰࢀরͰ͖Δ $MPKVSF
  58. ϝιουɾؔ਺એݴ

  59. ϝιουɾؔ਺એݴ public int f(int x) { return x + 1;

    } +BWB
  60. ϝιουɾؔ਺એݴ public int f(int x) { return x + 1;

    } +BWB def f(x: Int) = x + 1 4DBMB
  61. ϝιουɾؔ਺એݴ public int f(int x) { return x + 1;

    } +BWB (defn f [x] (+ x 1)) $MPKVSF def f(x: Int) = x + 1 4DBMB
  62. 👍

  63. ࠓճ༻ҙ࣮ͨ͠૷ w ىಈ͠ɺMPDBMIPTUͷಛఆͷϙʔτͰ)551ϦΫΤετΛ଴ͪड͚Δ w ରԠ͢Δ)551ϦΫΤετϝιου͸(&5ͷΈ
 ͦΕҎ֎ͷϝιου΋(&5ͱΈͳ͢ w QVCMJDσΟϨΫτϦΑΓ্ͷ֊૚΁ͷϦΫΤετʹ͸
 'PSCJEEFOΛฦ͢ w

    Ϧιʔεͷ.*.&͸֎෦ϑΝΠϧͰઃఆͰ͖Δ w ϦΫΤετΛϒϩοΫ͠ͳ͍ʢϚϧνεϨουʣ w ,FFQ"MJWF͸͠ͳ͍ɻίωΫγϣϯ͸౎౓DMPTF͢Δ w )551$BDIF͸͠ͳ͍ɻ͸ฦ͞ͳ͍
  64. IUUQTHJUIVCDPNUPEPLSTJNQMFIUUQTFSWFS

  65. ͭ͘Γʹ͍ͭͯͬ͘͟Γͱ ᵓᴷᴷ.JNF%FUFDUPSKBWB ᵓᴷᴷ3FRVFTUKBWB ᵓᴷᴷ3FRVFTU)BOEMFSKBWB ᵓᴷᴷ3FRVFTU1BSTFSKBWB ᵓᴷᴷ3FTQPOTFKBWB ᵓᴷᴷ4JNQMF+BWB)UUQ4FSWFSKBWB ᵋᴷᴷ8PSLFS5ISFBEKBWB 8FCαʔόʔΞϓϦέʔγϣϯ 3FRVFTU

    *OQVU4USFBN 3FTQPOTF 0VUQVU4USFBN )551ϦΫΤετͷύʔε ϦΫΤετʹԠͨ͡
 Ϩεϙϯεͷੜ੒ )551Ϩεϙϯεͷฦ٫
  66. ͭ͘Γʹ͍ͭͯͬ͘͟Γͱ ᵓᴷᴷ.JNF%FUFDUPSKBWB ᵓᴷᴷ3FRVFTUKBWB ᵓᴷᴷ3FRVFTU)BOEMFSKBWB ᵓᴷᴷ3FRVFTU1BSTFSKBWB ᵓᴷᴷ3FTQPOTFKBWB ᵓᴷᴷ4JNQMF+BWB)UUQ4FSWFSKBWB ᵋᴷᴷ8PSLFS5ISFBEKBWB 8FCαʔόʔΞϓϦέʔγϣϯ 3FRVFTU

    *OQVU4USFBN 3FTQPOTF 0VUQVU4USFBN )551ϦΫΤετͷύʔε ϦΫΤετʹԠͨ͡
 Ϩεϙϯεͷੜ੒ )551Ϩεϙϯεͷฦ٫
  67. ͭ͘Γʹ͍ͭͯͬ͘͟Γͱ ᵓᴷᴷ.JNF%FUFDUPSKBWB ᵓᴷᴷ3FRVFTUKBWB ᵓᴷᴷ3FRVFTU)BOEMFSKBWB ᵓᴷᴷ3FRVFTU1BSTFSKBWB ᵓᴷᴷ3FTQPOTFKBWB ᵓᴷᴷ4JNQMF+BWB)UUQ4FSWFSKBWB ᵋᴷᴷ8PSLFS5ISFBEKBWB 8FCαʔόʔΞϓϦέʔγϣϯ 3FRVFTU

    *OQVU4USFBN 3FTQPOTF 0VUQVU4USFBN )551ϦΫΤετͷύʔε ϦΫΤετʹԠͨ͡
 Ϩεϙϯεͷੜ੒ )551Ϩεϙϯεͷฦ٫
  68. ͭ͘Γʹ͍ͭͯͬ͘͟Γͱ ᵓᴷᴷ.JNF%FUFDUPSKBWB ᵓᴷᴷ3FRVFTUKBWB ᵓᴷᴷ3FRVFTU)BOEMFSKBWB ᵓᴷᴷ3FRVFTU1BSTFSKBWB ᵓᴷᴷ3FTQPOTFKBWB ᵓᴷᴷ4JNQMF+BWB)UUQ4FSWFSKBWB ᵋᴷᴷ8PSLFS5ISFBEKBWB 8FCαʔόʔΞϓϦέʔγϣϯ 3FRVFTU

    *OQVU4USFBN 3FTQPOTF 0VUQVU4USFBN )551ϦΫΤετͷύʔε ϦΫΤετʹԠͨ͡
 Ϩεϙϯεͷੜ੒ )551Ϩεϙϯεͷฦ٫
  69. ͭ͘Γʹ͍ͭͯͬ͘͟Γͱ ᵓᴷᴷ.JNF%FUFDUPSKBWB ᵓᴷᴷ3FRVFTUKBWB ᵓᴷᴷ3FRVFTU)BOEMFSKBWB ᵓᴷᴷ3FRVFTU1BSTFSKBWB ᵓᴷᴷ3FTQPOTFKBWB ᵓᴷᴷ4JNQMF+BWB)UUQ4FSWFSKBWB ᵋᴷᴷ8PSLFS5ISFBEKBWB 8FCαʔόʔΞϓϦέʔγϣϯ 3FRVFTU

    *OQVU4USFBN 3FTQPOTF 0VUQVU4USFBN )551ϦΫΤετͷύʔε ϦΫΤετʹԠͨ͡
 Ϩεϙϯεͷੜ੒ )551Ϩεϙϯεͷฦ٫
  70. ֤ݴޠͰ΍ͬͯΈΔ w 4PDLFUͷѻ͍ w ਖ਼نදݱ w จࣈྻͷѻ͍ w Ϧιʔεͷ։์ w

    ฒߦॲཧ
  71. 4PDLFUͷѻ͍

  72. 4PDLFU

  73. 4PDLFU w ௨৴ʹ͓͚ΔΤϯυϙΠϯτΛදݱͨ͠σʔλϞσϧ ֤ΤϯυϙΠϯτΛࣝผ͢Δ̎ͭͷ஋ɺ
 ͢ͳΘͪ*1ΞυϨεͱϙʔτ൪߸͸ɺ
 ଟ͘ͷ৔߹ιέοτ TPDLFU ͱݺ͹ΕΔɻ ʮ6/*9ωοτϫʔΫϓϩάϥϛϯάʯIUUQTXXXTFTIPQDPNQSPEVDUEFUBJM

  74. 4PDLFU௨৴ͷ໛ࣜਤ ΫϥΠΞϯτ αʔόʔ

  75. 4PDLFU௨৴ͷ໛ࣜਤ ΫϥΠΞϯτ αʔόʔ αʔόʔιέοτ

  76. 4PDLFU௨৴ͷ໛ࣜਤ ΫϥΠΞϯτ αʔόʔ αʔόʔιέοτ ΫϥΠΞϯτιέοτ

  77. 4PDLFU௨৴ͷ໛ࣜਤ ΫϥΠΞϯτ αʔόʔ αʔόʔιέοτ ΫϥΠΞϯτιέοτ ઀ଓཁٻ

  78. 4PDLFU௨৴ͷ໛ࣜਤ ΫϥΠΞϯτ αʔόʔ αʔόʔιέοτ ΫϥΠΞϯτιέοτ ઀ଓ

  79. 4PDLFU௨৴ͷ໛ࣜਤ ΫϥΠΞϯτ αʔόʔ αʔόʔιέοτ ΫϥΠΞϯτιέοτ 😂 😂

  80. 4PDLFUͷѻ͍ // αʔόʔιέοτͷੜ੒ ServerSocket serverSocket = new ServerSocket(8080); while (true)

    { // ઀ଓΛ଴ͪड͚Δɻ઀ଓ͞ΕΔ·ͰϒϩοΫɻ Socket socket = serverSocket.accept(); InputStream in = socket.getInputStream(); OutputStream out = socket.getOutputStream(); ... } ιέοτͷੜ੒ͱ઀ଓͷ଴ͪड͚
  81. 4PDLFUͷѻ͍ // αʔόʔιέοτͷੜ੒ val serverSocket = new ServerSocket(8080) while (true)

    { // ઀ଓΛ଴ͪड͚Δɻ઀ଓ͞ΕΔ·ͰϒϩοΫ val socket = serverSocket.accept val in = s.getInputStream val out = s.getOutputStream ... } ιέοτͷੜ੒ͱ઀ଓͷ଴ͪड͚
  82. 4PDLFUͷѻ͍ (let [server-socket (new ServerSocket 8080)] (while true (let [socket

    (.accept server-socket) in (.getInputStream socket) out (.getOutputStream socket)] ...))) ιέοτͷੜ੒ͱ઀ଓͷ଴ͪड͚
  83. 4PDLFUͷѻ͍ʹֶ͍ͭͯΜͩ͜ͱ w 4FSWFS4PDLFUΦϒδΣΫτΛੜ੒͠ɺ
 ΫϥΠΞϯτ͔Βͷ઀ଓΛBDDFQUͰ଴ͪड͚Δ w 4PDLFUΦϒδΣΫτʢΫϥΠΞϯτιέοτʣ͔Β
 *O0VUQVU4USFBN͕औಘͰ͖Δ w *OQVU4USFBN͔Β)551ϦΫΤετΛ3FBE͠ɺ
 0VUQVU4USFBNʹ)551ϨεϙϯεΛ8SJUF͢Δ

  84. ਖ਼نදݱ

  85. ਖ਼نදݱ w 4PDLFUͷ*OQVU4USFBNΛҰߦಡΉ
 ˠSFRVFTUMJOF w ֤ཁૉΛநग़͍ͨ͠

  86. ਖ਼نදݱ w 4PDLFUͷ*OQVU4USFBNΛҰߦಡΉ
 ˠSFRVFTUMJOF w ֤ཁૉΛநग़͍ͨ͠

  87. ਖ਼نදݱ w 4PDLFUͷ*OQVU4USFBNΛҰߦಡΉ
 ˠSFRVFTUMJOF w ֤ཁૉΛநग़͍ͨ͠

  88. ໊લ෇͖άϧʔϓ

  89. ໊લ෇͖άϧʔϓ w ਖ਼نදݱͷάϧʔϓʹ໊લΛ෇͚Δ͜ͱ͕Ͱ͖Δ w άϧʔϓͷॱং͕มΘͬͨͱͯ͠΋औΓग़͢ॲཧ͸ͦͷ··Ͱྑ͍ import java.util.regex.*; String regex =

    "(?<year>\\d+)/(?<month>\\d+)/(?<day>\\d+)"; Pattern p = Pattern.compile(regex); Matcher m = p.matcher("2017/11/18"); if (m.find()) { System.out.println(m.group("year")); // 2017 System.out.println(m.group("month")); // 11 System.out.println(m.group("day")); // 18 }
  90. public static Pattern requestLinePattern = Pattern.compile("(?<method>.*) (?<path>.*?) (?<version>.*?)"); public Request

    fromInputStream(InputStream in){ BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String requestLine = reader.readLine(); Matcher matcher = requestLinePattern.matcher(requestLine); if (!matcher.find()) return null; String method = matcher.group("method"); String targetPath = matcher.group("path"); String httpVersion = matcher.group("version"); return new Request(method, targetPath, httpVersion); } ໊લ෇͖άϧʔϓ ϦΫΤετϥΠϯͷ֤ཁૉʹ໊લΛ෇͚ͯநग़
  91. ύλʔϯϚον S

  92. ύλʔϯϚον w +BWBͷTXJUDIจʹࣅ͍ͯΔ͕ɺΑΓॊೈͰڧྗ w ஋ʹҰக͢Δ͔͚ͩͰͳ͘ɺܕ΍ߏ଄Ͱ෼ذͤ͞Δ͜ͱ͕Ͱ͖Δ 0 match { case 0

    => "Zero" // "Zero" case _ => "Other" } List(1, 2, 3) match { case List(_, x, _) => x // 2 case _ => -1 } 1 match { x: Int => s"$x͸Int" // 1͸Int x: String => s"$x͸String" x => s"$x͸???" }
  93. ύλʔϯϚον w ਖ਼نදݱΦϒδΣΫτʹରͯ͠΋Ϛονͤ͞Δ͜ͱ͕Ͱ͖Δ val Pattern = "(.+)/(.+)/(.+)".r //.rͰregexܕ “2021/05/20" match

    { case Pattern(y, m, d) => s"${y}೥${m}݄${d}೔" case _ => "???" }
  94. ύλʔϯϚον val Pattern = "(.+) (.+) (.+)".r requestLine match {

    case Pattern(method, path, version) => Some(Request(method, path, version)) case _ => None } 3FRVFTU1BSTFSTDBMBʢൈਮҰ෦վมʣ
  95. 0QUJPOܕ requestLine match { case pattern(method, path, version) => Some(Request(method,

    path, version)) case _ => None } w +BWBͰ͍͏0QUJPOBMʢΈ͍ͨͳ΋ͷʣ w )BTLFMMͰ͍͏.BZCF w 4PNFͱ/POF͔ΒͳΔܕʢ୅਺తσʔλܕʣ w ஋͕͋Δ͔ͳ͍͔෼͔Βͳ͍ঢ়ଶΛද͢ w ஋͕ଘࡏ͢Δ͔ͷνΣοΫΛڧ੍Ͱ͖Δ
  96.  SFpOE

  97. SFpOE w ਖ਼نදݱʹϚονͨ͠จࣈྻΛऔಘ w Ҿ਺ʹάϧʔϓԽͨ͠ਖ਼نදݱΦϒδΣΫτΛ౉͢ͱɺ
 ઌ಄ʹ͸Ϛονͨ͠จࣈྻશମɺҎ߱ʹΩϟϓνϟ͞ΕͨจࣈྻͷϕΫλʔ ;; #"" ͸java.util.regex.PatternͷϦςϥϧ (re-find

    #"(.+)/(.+)/(.+)" "2017/11/18") ;; => ["2017/11/18" "2017" "11" "18"] ;; restͰઌ಄Ҏ֎ͷཁૉΛऔಘ (rest (re-find #"(.+)/(.+)/(.+)" "2017/11/18")) ;; => ("2017" "11" "18")
  98. [JQNBQ w ڧྗͳίϨΫγϣϯϥΠϒϥϦ͸$MPKVSFͷಛ௃ w [JQNBQ͸ͭͷίϨΫγϣϯ͔Β.BQΛ࡞Δ w $MPKVSFͰ͸ΫϥεΑΓ΋.BQΛ޷Ή (zipmap [:a :b

    :c] [1 2 3]) ;; => {:a 1, :b 2, :c 3}
  99. SFpOE [JQNBQ (let [line "GET / HTTP/1.1"] (zipmap [:method :path

    :version] (rest (re-find #"(.+) (.+) (.+)" line)))) ;; => {:method "GET", :path "/", :version "HTTP/1.1"} ϦΫΤετϥΠϯͷ֤ཁૉΛ.BQʹม׵
  100. SFpOE [JQNBQ <NFUIPEQBUIWFSTJPO> <(&5)551> (let [line "GET / HTTP/1.1"] (zipmap

    [:method :path :version] (rest (re-find #"(.+) (.+) (.+)" line)))) ;; => {:method "GET", :path "/", :version "HTTP/1.1"} ϦΫΤετϥΠϯͷ֤ཁૉΛ.BQʹม׵
  101. SFpOE [JQNBQ <NFUIPEQBUIWFSTJPO> <(&5)551> (let [line "GET / HTTP/1.1"] (zipmap

    [:method :path :version] (rest (re-find #"(.+) (.+) (.+)" line)))) ;; => {:method "GET", :path "/", :version "HTTP/1.1"} ϦΫΤετϥΠϯͷ֤ཁૉΛ.BQʹม׵
  102. SFpOE [JQNBQ <NFUIPEQBUIWFSTJPO> <(&5)551> (let [line "GET / HTTP/1.1"] (zipmap

    [:method :path :version] (rest (re-find #"(.+) (.+) (.+)" line)))) ;; => {:method "GET", :path "/", :version "HTTP/1.1"} ϦΫΤετϥΠϯͷ֤ཁૉΛ.BQʹม׵
  103. ਖ਼نදݱʹֶ͍ͭͯΜͩ͜ͱ

  104. ਖ਼نදݱʹֶ͍ͭͯΜͩ͜ͱ ໊લ෇͖άϧʔϓ

  105. ਖ਼نදݱʹֶ͍ͭͯΜͩ͜ͱ ໊લ෇͖άϧʔϓ ఴࣈͰΞΫηε͢ΔΑΓ҆৺

  106. ਖ਼نදݱʹֶ͍ͭͯΜͩ͜ͱ ໊લ෇͖άϧʔϓ ύλʔϯϚον
 S ఴࣈͰΞΫηε͢ΔΑΓ҆৺

  107. ਖ਼نදݱʹֶ͍ͭͯΜͩ͜ͱ ໊લ෇͖άϧʔϓ ύλʔϯϚον
 S ఴࣈͰΞΫηε͢ΔΑΓ҆৺ ߏ଄ͷ෼ղʹ΋࢖͑Δ

  108. ਖ਼نදݱʹֶ͍ͭͯΜͩ͜ͱ ໊લ෇͖άϧʔϓ ύλʔϯϚον
 S SFpOE
  ఴࣈͰΞΫηε͢ΔΑΓ҆৺ ߏ଄ͷ෼ղʹ΋࢖͑Δ

  109. ਖ਼نදݱʹֶ͍ͭͯΜͩ͜ͱ ໊લ෇͖άϧʔϓ ύλʔϯϚον
 S SFpOE
  ఴࣈͰΞΫηε͢ΔΑΓ҆৺ ߏ଄ͷ෼ղʹ΋࢖͑Δ ݁Ռ͸ίϨΫγϣϯɺίϨΫγϣϯૢ࡞ͱ૊Έ߹Θͤͯ

  110. จࣈྻͷѻ͍

  111. จࣈྻ݁߹ w ϨεϙϯεʢΦϒδΣΫτϚοϓʣ͔Β
 )551ϨεϙϯεϔομΛ૊Έཱ͍ͯͨ public class Response { public final

    Status status; public final String contentType; public final int contentLength; public final byte[] body; }
  112.  4USJOH#VJMEFS

  113. 4USJOH#VJMEFS String response = "HTTP/1.1 " + status.statusCode + CRLF

    + "Server: SimpleJavaHttpServer" + CRLF + "Content-Type: " + contentType + CRLF + "Content-Length: " + 
 String.valueOf(contentLength) + CRLF + "Connection: Close" + CRLF + CRLF; 3FTQPOTFΦϒδΣΫτΛ)551Ϩεϙϯε΁ม׵
  114. 4USJOH*OUFSQPMBUJPO 5SJQMF2VPUF

  115. 4USJOH*OUFSQPMBUJPO w จࣈྻϦςϥϧͷલʹTΛ෇͚Δͱɺม਺Λల։Ͱ͖Δ val price = 1000 s"Price is $price"

    // => Price is 1000
  116. 5SJQMF2VPUF "Hello triple quote!\nHello stripMargin!" """Hello triple quote! Hello stripMargin!"""

    """|Hello triple quote! |Hello stripMargin!""".stripMargin w վߦΛؚΉจࣈྻΛຒΊࠐΉʹ͸ɺΛ࢖͏ w ΠϯσϯτΛଗ͑Δʹ͸Πϯσϯτจࣈ c ͱTUSJQ.BSHJOΛ࢖͏
  117. 4USJOH*OUFSQPMBUJPOͱ5SJQMF2VPUF val response = s"""HTTP/1.1 ${status.value} |Date: ${rfc1123Formatter.format(now)} |Server: SimpleScalaHttpServer

    |Content-Type: $contentType |Content-Length: ${body.length.toString} |Connection: Close | |""".stripMargin 3FTQPOTFΦϒδΣΫτΛ)551Ϩεϙϯε΁ม׵
  118. TUS

  119. w $MPKVSFͰ͸จࣈྻͷ݁߹͸ Ͱ͸ͳ͘TUS w Մม௕Ҿ਺ɺ4ࣜͳΒͰ͸ TUS (+ "hoge" "fuga") ClassCastException

    java.lang.String cannot be cast to java.lang.Number clojure.lang.Numbers.add (Numbers.java:128) (str "hoge" "fuga" "piyo") // => hogefugapiyo
  120. TUS (let [header (str "HTTP/1.1" SP status SP reason-phrase CRLF

    "Content-Length:" (count body) CRLF "Content-Type:" content-type CRLF "Connection: Close" CRLF CRLF)] ...) 3FTQPOTFΦϒδΣΫτΛ)551Ϩεϙϯε΁ม׵
  121. จࣈྻ݁߹ʹֶ͍ͭͯΜͩ͜ͱ

  122. จࣈྻ݁߹ʹֶ͍ͭͯΜͩ͜ͱ 
 4USJOH#VJMEFS

  123. จࣈྻ݁߹ʹֶ͍ͭͯΜͩ͜ͱ 
 4USJOH#VJMEFS ࠷దԽʹࣗ৴͕ͳ͚Ε͹KBWBQD

  124. จࣈྻ݁߹ʹֶ͍ͭͯΜͩ͜ͱ 
 4USJOH#VJMEFS 4USJOH*OUFSQPMBUJPO
 5SJQMF2VPUF ࠷దԽʹࣗ৴͕ͳ͚Ε͹KBWBQD

  125. จࣈྻ݁߹ʹֶ͍ͭͯΜͩ͜ͱ 
 4USJOH#VJMEFS 4USJOH*OUFSQPMBUJPO
 5SJQMF2VPUF ࠷దԽʹࣗ৴͕ͳ͚Ε͹KBWBQD ͪΐͬͱͨ͠ςϯϓϨʔτΤϯδϯΈ͍ͨʹ࢖͑Δ

  126. จࣈྻ݁߹ʹֶ͍ͭͯΜͩ͜ͱ 
 4USJOH#VJMEFS 4USJOH*OUFSQPMBUJPO
 5SJQMF2VPUF TUS ࠷దԽʹࣗ৴͕ͳ͚Ε͹KBWBQD ͪΐͬͱͨ͠ςϯϓϨʔτΤϯδϯΈ͍ͨʹ࢖͑Δ

  127. จࣈྻ݁߹ʹֶ͍ͭͯΜͩ͜ͱ 
 4USJOH#VJMEFS 4USJOH*OUFSQPMBUJPO
 5SJQMF2VPUF TUS ࠷దԽʹࣗ৴͕ͳ͚Ε͹KBWBQD ͪΐͬͱͨ͠ςϯϓϨʔτΤϯδϯΈ͍ͨʹ࢖͑Δ 4ࣜͳΒͰ͸

  128. Ϧιʔεͷ؅ཧ

  129. Ϧιʔεͷ؅ཧ w ετϦʔϜ΍%#ίωΫγϣϯɺιέοτ͸࢖͍ऴΘͬͨΒDMPTF w ๨ΕΔͱϝϞϦϦʔΫͷݪҼʹͳΔ͜ͱ͕͋Δ w खͰDMPTFॻ͖ͨ͘ͳ͍ʂ😫

  130. 5SZXJUI3FTPVSDFT

  131. 5SZXJUI3FTPVSDFT try (InputStream in = new FileInputStream(file)) { // Կ͔ϦιʔεΛѻ͏ॲཧ

    } // try۟Λൈ͚ͨΒclose w USZ۟Λൈ͚ͨΒࣗಈͰDMPTF w ର৅͸KBWBJP$MPTFBCMF KBWBMBOH"VUP$MPTFBCMFͷ࣮૷Ϋϥε
  132. -PBO1BUUFSO

  133. -PBO1BUUFSO w ʮआΓͨΒฦ͢ʯΛ࣮֬ʹߦ͏ͨΊͷΠσΟΦϜ w ͔͋ͨ΋ݴޠ੍͕࣋ͭޚߏ଄ͷΑ͏ͳϝιουΛɺ
 ϓϩάϥϚ͕؆୯ʹఆٛͰ͖Δͷ΋4DBMBͷΑ͍ͱ͜Ζ val reader = new

    BufferedReader(...) using(reader) { r => // readerΛ࢖ͬͨԿ͔ͷॲཧ } // ϒϩοΫΛൈ͚ͨΒreader͸close͞Ε͍ͯΔ ˞4DBMB͔Βඪ४ϥΠϒϥϦʹˢͱ΄΅ಉ౳ͷTDBMBVUJM6TJOH͕௥Ճ͞Ε·͕ͨ͠ɺ
 ΠϝʔδΛ௫ΉͨΊʹࣗ෼Ͱ࣮૷ͯ͠Έ·͢
  134. -PBO1BUUFSOͷ࣮૷ def using[A, R <: Closeable](resource: R)(f: R => A):

    A = { try { f(resource) } finally { resource.close() } }
  135. -PBO1BUUFSOͷ࣮૷ def using[A, R <: Closeable](resource: R)(f: R => A):

    A = { try { f(resource) } finally { resource.close() } } ܕม਺3͸$MPTFBCMF͔ͦͷαϒλΠϓɻDMPTFϝιουΛ࣋ͭ͜ͱΛอূɻ
  136. -PBO1BUUFSOͷ࣮૷ def using[A, R <: Closeable](resource: R)(f: R => A):

    A = { try { f(resource) } finally { resource.close() } } 3ܕͷԿ͔Λड͚औΓɺԿΒ͔ͷܕ"Λฦؔ͢਺ΛҾ਺ʹͱΔ
  137. -PBO1BUUFSOͷ࣮૷ def using[A, R <: Closeable](resource: R)(f: R => A):

    A = { try { f(resource) } finally { resource.close() } } Ϧιʔεʹରͯؔ͠਺Λద༻
  138. -PBO1BUUFSOͷ࣮૷ def using[A, R <: Closeable](resource: R)(f: R => A):

    A = { try { f(resource) } finally { resource.close() } } ࠷ޙʹDMPTF
  139. -PBO1BUUFSO using(socket) { s => val in = s.getInputStream val

    out = s.getOutputStream val request = parser.fromInputStream(in) val response = request.map(handleRequest) response.foreach(_.writeTo(out)) } VTJOHϒϩοΫΛൈ͚ͨΒɺTPDLFUΛDMPTF͢Δ
  140. XJUIPQFO

  141. w -PBO1BUUFSOʹࣅͨXJUIPQFOͱ͍͏ϚΫϩ w MFUͱಉ͡Α͏ͳײ͡Ͱ࢖͏ XJUIPQFO (with-open [f (io/file "test.txt")] ...)

  142. XJUIPQFO (with-open [s socket] (-> (request-parser/from-input-stream (.getInputStream s)) (request-handler/handle-request) (response-writer/write

    (.getOutputStream s)))) XJUIPQFOΛൈ͚ͨΒɺTPDLFUΛDMPTF͢Δ
  143. Ϧιʔεͷ؅ཧʹֶ͍ͭͯΜͩ͜ͱ

  144. Ϧιʔεͷ؅ཧʹֶ͍ͭͯΜͩ͜ͱ 5SZXJUI3FTPVSDFT

  145. Ϧιʔεͷ؅ཧʹֶ͍ͭͯΜͩ͜ͱ 5SZXJUI3FTPVSDFT USZ۟Λൈ͚Δ࣌ʹDMPTF

  146. Ϧιʔεͷ؅ཧʹֶ͍ͭͯΜͩ͜ͱ 5SZXJUI3FTPVSDFT -PBO1BUUFSO USZ۟Λൈ͚Δ࣌ʹDMPTF

  147. Ϧιʔεͷ؅ཧʹֶ͍ͭͯΜͩ͜ͱ 5SZXJUI3FTPVSDFT -PBO1BUUFSO USZ۟Λൈ͚Δ࣌ʹDMPTF ؔ਺͕஋Ͱ͋Δ͜ͱΛ׆͔͠ɺ੍ޚߏจͷΑ͏ʹݟͤΔ

  148. Ϧιʔεͷ؅ཧʹֶ͍ͭͯΜͩ͜ͱ 5SZXJUI3FTPVSDFT -PBO1BUUFSO XJUIPQFO USZ۟Λൈ͚Δ࣌ʹDMPTF ؔ਺͕஋Ͱ͋Δ͜ͱΛ׆͔͠ɺ੍ޚߏจͷΑ͏ʹݟͤΔ

  149. Ϧιʔεͷ؅ཧʹֶ͍ͭͯΜͩ͜ͱ 5SZXJUI3FTPVSDFT -PBO1BUUFSO XJUIPQFO USZ۟Λൈ͚Δ࣌ʹDMPTF ؔ਺͕஋Ͱ͋Δ͜ͱΛ׆͔͠ɺ੍ޚߏจͷΑ͏ʹݟͤΔ DMPTFͯ͘͠ΕΔMFUΈ͍ͨͳΠϝʔδ

  150. ฒߦॲཧ

  151. ฒߦॲཧ w ϦΫΤετΛγϦΞϧʹॲཧ͢ΔͱଞͷϦΫΤετΛ଴ͨͤͯ͠·͏ w ίϯϏχͷϨδͰ͓ห౰ΛԹΊͯ΋Β͏ྫ͕Πϝʔδ͠΍͍͢

  152. ͋ͨͨΊϦΫΤετ ͋ͨͨ·͓ͬͨห౰ w ͓٬͞Μ͕গͳ͚Ε͹ɺిࢠϨϯδ͕୆Ͱ΋े෼·͔ͳ͑Δ ίϯϏχͷϨδΛྫʹߟ͑ͯΈΔ

  153. ͋ͨͨΊϦΫΤετ ͋ͨͨ·͓ͬͨห౰ w ͓٬͞Μ͕ଟ͘ͳΔͱɺϨδ͕٧·ͬͯ͠·͏ ίϯϏχͷϨδΛྫʹߟ͑ͯΈΔ

  154. ͋ͨͨΊϦΫΤετ ͋ͨͨ·͓ͬͨห౰ w ిࢠϨϯδͷ਺Λ૿΍ͤ͹ղܾʂ ίϯϏχͷϨδΛྫʹߟ͑ͯΈΔ

  155. 5ISFBE &YFDVUPS4FSWJDF

  156. 5ISFBE class HogeThread extends Thread { public void run() {

    // Կ͔ඇಉظʹ࣮ߦ͍ͨ͠ॲཧ } } HogeThread h = new HogeThread(); h.start(); class FugaRunnable implements Runnable { public void run() { // Կ͔ඇಉظʹ࣮ߦ͍ͨ͠ॲཧ } } FugaRunnable f = new Thread(new FugaRunnable()); f.start(); 5ISFBEΛFYUFOET3VOOBCMFΛJNQMFNFOUT
  157. 5ISFBE public class WorkerThread extends Thread { private Socket socket;

    private RequestParser parser; private RequestHandler handler; public WorkerThread( Socket socket, RequestParser parser, RequestHandler handler) { ... 5ISFBEͷఆٛ 5ISFBEͷىಈ Thread worker = new WorkerThread(socket, parser, handler); worker.start();
  158. &YFDVUPS4FSWJDF ExecutorService cachedPool = Executors.newCachedThreadPool(); cachedPool.execute(runnable); ExecutorService fixedPool = Executors.newFixedThreadPool(4);

    fixedPool.execute(runnable); w ΑΓߴਫ४ͳฒྻॲཧͷͨΊͷ࢓૊Έ w εϨουϓʔϧͷछྨ΋ࢦఆͰ͖Δ
  159. 'VUVSF

  160. 'VUVSF w 'VUVSFBQQMZ͸౉͞ΕͨॲཧΛඇಉظʹ࣮ߦ w ͍ͭͲͷΑ͏ʹඇಉظʹ࣮ߦ͢Δ͔͸&YFDVUJPO$POUFYU࣍ୈ import scala.concurrent.Future // ForkJoinPoolɺσϑΥϧτͰ͸ίΞ਺෼ͷฒྻ౓Ͱॲཧ
 import

    scala.concurrent.ExecutionContext.Implicits.global val result: Future[User] = Future { // .apply͸লུͰ͖Δ userRepository.fetch(userId) } result.map(user => user.id) result.flatMap(user => tweetRepository.fetch(user.id))
  161. &YFDVUJPO$POUFYU͸Ͳ͏ड͚औΔʁ w 'VUVSFBQQMZʹ͸Ҿ਺ϒϩοΫ͕ͭ w ͭ໨ͷҾ਺ϒϩοΫͰ&YFDVUJPO$POUFYUΛड͚औΔ object Future { ... def

    apply[T](body: => T)(implicit executor: ExecutionContext): Future[T] = unit.map(_ => body) ... } Future { userRepository.fetch(user) } // ↑͸Future#applyͷݺͼग़͠
  162. 8IBUͱ)PXͷ෼཭ w ୈҰҾ਺ϒϩοΫlCPEZ5z w 8IBUʮԿΛ࣮ߦ͢Δ͔ʯ w ୈೋҾ਺ϒϩοΫlJNQMJDJUFYFDVUPS&YFDVUJPO$POUFYUz w )PXʮͲͷΑ͏ʹ࣮ߦ͢Δ͔ʯ w

    JNQMJDJUΩʔϫʔυ͕͍͍ͭͯΔͷͰɺ໌ࣔతʹҾ਺ͱͯ͠౉͢ඞཁͳ͠ w 'VUVSF EP4PNFUIJOH FYFDVUPS object Future { ... def apply[T](body: => T)(implicit executor: ExecutionContext): Future[T] = unit.map(_ => body) ... }
  163. JNQMJDJU8IBUͱ)PXͷ෼཭ w )PX͕ڊେʹͳΔͱɺίʔυͷຊདྷͷҙਤ͕ຒ΋Εͯ͠·͏ w JNQMJDJUͷେ͖ͳϞνϕʔγϣϯ͸)PXͷӅณ w 8IBUͱ)PXΛ෼཭͢Δ͜ͱͰɺ໨తΛ୺తʹࣔ͢͜ͱ͕Ͱ͖Δ val values: Seq[(String,

    Option[Int])] val sorted = sort(values)( tuple2Comparator( stringComparator, optionComparator(intComparator))) val sorted = sort(values) // implicit
  164. IUUQHBLV[[[[HJUIVCJPTMJEFTJNQMJDJU@SFJOUSPEVDUJPO

  165. UISFBE

  166. $MPKVSFͷฒߦॲཧؔ਺ w $MPKVSFͷฒߦॲཧؔ਺͸ͨ͘͞Μ͋Δ w HP w UISFBE w TFOE w

    TFOEPGG w GVUVSF w FUD
  167. $MPKVSFͷฒߦॲཧؔ਺ εϨουϓʔϧ εϨου਺ TFOE 'JYFE5ISFBE1PPM  ίΞ਺ TFOEPGG $BDIFE5ISFBE1PPM ੍ݶͳ͠

    GVUVSFGVUVSFDBMM QNBQQDBMMT $BDIFE5ISFBE1PPM ੍ݶͳ͠ HP 'JYFE5ISFBE1PPM ίΞ਺   UISFBE
 UISFBEDBMM $BDIFE5ISFBE1PPM ੍ݶͳ͠ SFEVDFST 'PSL+PJO1PPM ࣗಈ੍ޚ
  168. *0ό΢ϯυ$16ό΢ϯυ ΞϓϦέʔγϣϯͷʮෛՙʯ͸ɺ
 *0ό΢ϯυͱ$16ό΢ϯυͷछྨʹେผ͞ΕΔ w *0ό΢ϯυ w *0͕ύϑΥʔϚϯεͷϘτϧωοΫ w $16͸ʮ଴ͪʯ͕ଟ͘ͳΔ w

    σΟεΫΞΫηε΍ϦϞʔτ௨৴ͳͲ w$16ό΢ϯυ w $16͕ύϑΥʔϚϯεͷϘτϧωοΫ w $16͸ϑϧՔಇ w େن໛ͳՊֶܭࢉͳͲ
  169. $MPKVSFͷฒߦॲཧؔ਺ εϨουϓʔϧ εϨου਺ TFOE 'JYFE5ISFBE1PPM  ίΞ਺ TFOEPGG $BDIFE5ISFBE1PPM ੍ݶͳ͠

    GVUVSFGVUVSFDBMM QNBQQDBMMT $BDIFE5ISFBE1PPM ੍ݶͳ͠ HP 'JYFE5ISFBE1PPM ίΞ਺   UISFBE
 UISFBEDBMM $BDIFE5ISFBE1PPM ੍ݶͳ͠ SFEVDFST 'PSL+PJO1PPM ࣗಈ੍ޚ
  170. $MPKVSFͷฒߦॲཧؔ਺ εϨουϓʔϧ εϨου਺ TFOE 'JYFE5ISFBE1PPM  ίΞ਺ TFOEPGG $BDIFE5ISFBE1PPM ੍ݶͳ͠

    GVUVSFGVUVSFDBMM QNBQQDBMMT $BDIFE5ISFBE1PPM ੍ݶͳ͠ HP 'JYFE5ISFBE1PPM ίΞ਺   UISFBE
 UISFBEDBMM $BDIFE5ISFBE1PPM ੍ݶͳ͠ SFEVDFST 'PSL+PJO1PPM ࣗಈ੍ޚ
  171. UISFBE (thread (with-open [s socket in (.getInputStream s) out (.getOutputStream

    s)] (-> (request-parser/from-input-stream in) (request-handler/handle-request) (response-writer/write out)))) $BDIFE5ISFBE1PPMΛ࢖ͬͨฒྻॲཧ
  172. ฒߦॲཧʹֶ͍ͭͯΜͩ͜ͱ

  173. ฒߦॲཧʹֶ͍ͭͯΜͩ͜ͱ 5ISFBE
 &YFDVUPS4FSWJDF

  174. ฒߦॲཧʹֶ͍ͭͯΜͩ͜ͱ 5ISFBE
 &YFDVUPS4FSWJDF FYUFOET5ISFBEJNQMFNFOUT3VOOBCMF

  175. ฒߦॲཧʹֶ͍ͭͯΜͩ͜ͱ 5ISFBE
 &YFDVUPS4FSWJDF 'VUVSF FYUFOET5ISFBEJNQMFNFOUT3VOOBCMF

  176. ฒߦॲཧʹֶ͍ͭͯΜͩ͜ͱ 5ISFBE
 &YFDVUPS4FSWJDF 'VUVSF FYUFOET5ISFBEJNQMFNFOUT3VOOBCMF 5ISFBE্ཱͪ͛Ͱ͸ͳ͍ɻ
 Ͳ͏࣮ߦ͢Δ͔͸&YFDVUJPO$POUFYU࣍ୈɻ

  177. ฒߦॲཧʹֶ͍ͭͯΜͩ͜ͱ 5ISFBE
 &YFDVUPS4FSWJDF 'VUVSF UISFBE FYUFOET5ISFBEJNQMFNFOUT3VOOBCMF 5ISFBE্ཱͪ͛Ͱ͸ͳ͍ɻ
 Ͳ͏࣮ߦ͢Δ͔͸&YFDVUJPO$POUFYU࣍ୈɻ

  178. ฒߦॲཧʹֶ͍ͭͯΜͩ͜ͱ 5ISFBE
 &YFDVUPS4FSWJDF 'VUVSF UISFBE FYUFOET5ISFBEJNQMFNFOUT3VOOBCMF 5ISFBE্ཱͪ͛Ͱ͸ͳ͍ɻ
 Ͳ͏࣮ߦ͢Δ͔͸&YFDVUJPO$POUFYU࣍ୈɻ *0$16ό΢ϯυ͔Λҙࣝ͠Α͏

  179. 8FCαʔόʔΛ࡞ͬͯ ԿΛಘͨʁ

  180. ͪΐͬͱਂ͘જΔ༐ؾ

  181. ϓϩάϥϛϯάݴޠ΍8FCϑϨʔϜϫʔΫ͸
 ͜Ε·ͰͲͷΑ͏ʹมԽ͖͔ͯͨ͠ʁ

  182. ʮ3FBEBCMF4DBMBʯJO4DBMB.BUTVSJ
 !HBLV[[[[ ϓϩάϥϛϯάݴޠͷਐԽͷྺ࢙͸ɺ ͍͔ʹ)PXΛӅ΃͍ͯ͠
 8IBUΛ୺తʹදݱͰ͖ΔΑ͏ʹ͢Δ͔ɺͷ
 ྺ࢙Ͱ΋͋Γ·͢

  183. ྫ͑͹+BWBͷ4USFBN"1*

  184. ྫ͑͹+BWBͷ4USFBN"1* ʮϦετΛॱ൪ʹ͞Β͍ɺ
 ɹۮ਺ͩͬͨΒϦετʹ٧ΊΔʯ ɹͱ͍͏खଓ͖ʢ)PXʣ

  185. ྫ͑͹+BWBͷ4USFBN"1* खଓ͖ΛӅṭ͠ɺ
 ʮۮ਺ͷΈͷϦετΛ࡞Δʯ ɹͱ͍͏໨తʢ8IBUʣʹϑΥʔΧε

  186. ϑϨʔϜϫʔΫ΍ϥΠϒϥϦͰ΋ w ྫ %#͔ΒϨίʔυΛ݅औಘ w ʮ%#ʹͲ͏͍͏42-Λൃߦ͢Δ͔ʯͱ͍͏)PXΛӅณ͠ɺ
 ʮ+PCΛ*%ͰϑΟϧλϦϯάͯ݅͠औಘ͢Δʯͱ͍͏8IBUΛදݱ

  187. ͦͷҰํͰ͜Μͳ͜ͱ΋ w ؆୯ͦ͏ʹʮݟ͑ΔʯϑϧελοΫ8FCϑϨʔϜϫʔΫ w ͪΐͬͱ΍΍͍͜͜͠ͱΛ΍Ζ͏ͱ͢Δͱɺ্͙͢ख͍͔͘ͳ͘ͳΔ w ʮ)551ϨεϙϯεϔομΛݟΖʯ w ʮ$POUFOU5ZQF͕PDUFUTUSFBN͔ͩΒʜʯ w

    ʮNVMUJQBSUGPSNEBUB͕ʜʯ w ʮ+PJOͨͭ͠΋Γ͕αϒΫΤϦʹͳͬͯΔͷͰ͸ʁʯ w ʮ42-ͷ࣮ߦܭը͕ʜʯ
  188. ʮΫϥʔΫͷୈࡾ๏ଇʯΞʔαʔɾ$ɾΫϥʔΫ ߴ౓ʹൃୡٕͨ͠ज़͸ɺ
 ຐ๏ͱݟ෼͚͕͔ͭͳ͍

  189. ͳͥʮϋϚΔʯͷ͔ʁ w υΩϡϝϯτͷαϯϓϧίʔυWTʮ࣮ઓʯͷίʔυ w ྆ऀͷဃ཭͸ந৅ԽͷϨΠϠʔΛॏͶΔ΄Ͳେ͖͘ͳΔ w ݁ہ͸ԼͷϨΠϠʔͷ஌ࣝΛ஌͍ͬͯΔඞཁ͕͋Δ

  190. ʮ࿙Εͷ͋Δந৅Խͷ๏ଇʯ w CZ+PFM4QPMTLZ w ந৅Խͱ͸ɺҰ౓ʹ஫໨͢΂͖֓೦ΛݮΒ͢͜ͱ΍ɺ
 ͦͷ࢓૊Έͷ͜ͱ w ந৅Խ͸͢΂ͯɺఔ౓ͷࠩͦ͋͜Εɺ࿙Ε͕͋Δ IUUQTDPNNPOTXJLJNFEJBPSHXJLJ 'JMF+PFM@TQPMTLZ@PO@@TFQU@KQH

  191. 8FCϑϨʔϜϫʔΫͷʮந৅Խͷ࿙Εʯ w ϑϧελοΫͳ8FCϑϨʔϜϫʔΫ͸࿙Ε͕ݦஶ w ໘౗ͳ࡞ۀΛந৅Խ͠ɺ࡞ۀΛޮ཰Խͯ͘͠ΕΔ w ͔͠͠໘౗ͳ෦෼Λ׬શʹӅณͯ͘͠ΕΔΘ͚Ͱ͸ͳ͍ w ͋͘·Ͱ΋ʮޮ཰ԽʯͷͨΊͷந৅ԽͰ͋Γɺ
 ʮԿ͕ى͖͍ͯΔ͔ʯΛҙࣝ͢Δඞཁ͕͋Δ

    w )551ɺ42-ɺ$16ɺϝϞϦɺ*0ɺωοτϫʔΫɺFUD
  192. ࿙Εͷ͋Δந৅ԽͰى͖Δ͜ͱ w ϓϩάϥϛϯάݴޠ΍8FCϑϨʔϜϫʔΫ͸ɺந৅ԽʹΑͬͯɺ
 )PXͰ͸ͳ͘8IBUʹूதͰ͖ΔΑ͏ʹਐԽ͍ͯ͘͠ w 8IBUʹूதͰ͖Δར఺͸େ͖͍͕ɺ
 ͦͷந৅Խ͸ඞͣ͠΋׬શͰ͸ͳ͘ɺ
 ݁ہ͸ԼͷϨΠϠʔͷ)PXΛ஌Βͳ͍ͱઌʹਐΊͳ͍͜ͱ͕͋Δ

  193. ʮ+PFMPO4PGUXBSFʯ+PFM4QPMTLZ ࿙Εͷ͋Δந৅Խͷ๏ଇʹ͏·͘ରॲ͢Δ
 །Ұͷํ๏͸ɺͦͷந৅Խ͕ͲͷΑ͏ʹػೳ͠ɺ
 ͦΕ͕ԿΛந৅Խ͍ͯ͠Δͷ͔ΛֶͿ͜ͱͩɻ

  194. ಘͨ΋ͷͪΐͬͱਂ͘જΔ༐ؾ w ʮ࿙Εͷ͋Δந৅Խʯͷ΋ͱͰ͸ɺ໰୊ղܾͷͨΊʹ
 ීஈ৮Δٕज़ͷԼͷϨΠϠʔʹજΔ͜ͱ͕ආ͚ΒΕͳ͍
 ͔ͭɺ๛෋ͳ৘ใ͕͋Δͱ΋ݶΒͳ͍ w 8FCαʔόʔΛ࡞Δ͜ͱͰɺ8FCϑϨʔϜϫʔΫ͕ͲΜͳ࢓ࣄΛ ͍ͯ͠Δ͔΋ͳΜͱͳ͘෼͔ΔΑ͏ʹ w ӳޠͷҰ࣍৘ใʹ౰ͨΔ͕͍ͤͭͨ͘͜ͱͰɺ


    ະ຋༁ͷ৽͍ٕ͠ज़ͷυΩϡϝϯτͳͲ΋ԲͤͣಡΊΔΑ͏ʹ w ʮ࢓ࣄͰ࢖͍ͬͯΔϑϨʔϜϫʔΫ΍ϛυϧ΢ΣΞͷίʔυ΋
 ಡΜͰΈΑ͏ɻ͋ΘΑ͘͹ίϯτϦϏϡʔτͯ͠ΈΑ͏ʯͱ
 ͪΐͬͱਂ͘જͬͯΈΔ༐ؾˍڵຯΛ͖͔͚࣋ͭͬʹ
  195. 8FCαʔόʔΛ࡞ͬͯΈΔ͜ͱ͕ɺ
 Έͳ͞Μͷʮਂ͍ʯΤϯδχΞͷΩϟϦΞΛ
 ܗ࡞Δ͖͔͚ͬʹͳΕ͹͏Ε͍͠Ͱ͢

  196. 🙏 ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ

  197. ʢ࣌ؒʹ༨༟͕͋Ε͹ʣ ίʔυϦʔσΟϯάλΠϜʂ

  198. None
  199. None
  200. None