Slide 1

Slide 1 text

4ͭͷ؍఺͔Βൺֱ͢Δ RubyͷܕγεςϜ Fusic tech live 2021.06.15 ippachi 1

Slide 2

Slide 2 text

ࣗݾ঺հ ിத Ұീ ippachi • I D • Githubɿippach i • Twitterɿ@ippachi101 8 • Lik e • Ruby/Vim/TDD/Architecture 2 image

Slide 3

Slide 3 text

ࠓ೔࿩͢͜ͱ • ࣗݾ঺հ • ࠓ೔ͷൃදͰ࣋ͪؼͬͯ΋Β͏΋ͷ • ܕγεςϜͷ঺հ • ܕγεςϜͷൺֱ • ·ͱΊ 3

Slide 4

Slide 4 text

01 ࠓ೔࣋ͪؼͬͯ΋Β͏΋ͷ

Slide 5

Slide 5 text

Rubyͷಛ௃ • ಡΈ΍͍͢ • ॻ͖΍͍͢ • ϝλϓϩάϥϛϯά • ಈతܕ෇͚ݴޠ ← 5

Slide 6

Slide 6 text

Ruby͸ಈతܕ෇͚ݴޠ Ͱ΋੩తܕཉ͍͠ͱ͖΋͋ΔΑͶ

Slide 7

Slide 7 text

Ruby 3 with Type

Slide 8

Slide 8 text

Ruby 3 with type • ܕϥΠϒϥϦ͕ެ͔ࣜΒఏڙ͞Ε·ͨ͠ • RB S • Ruby 2Ͱ΋࢖͑ΔΑ • ͚Ͳ࣮͸ܕγεςϜΛ࣮ݱͰ͖Δgemͬͯଞʹ΋͋ΔΜͰ͢ 8

Slide 9

Slide 9 text

ͱ͍͏͜ͱͰ঺հ͠·͢

Slide 10

Slide 10 text

ຊεϥΠυʹ͓͚ΔܕγεςϜ • ੩తղੳͷͰ͖Δ΋ͷ ? • ಈతνΣοΫ΋ඞਢ ? • OOPʹ͓͚Δܕͷओཁͳશͯͷػೳ͕ඞཁ?(abstract, interface, fi nal ) • NO! 10

Slide 11

Slide 11 text

ຊεϥΠυʹ͓͚ΔܕγεςϜ • ੩తղੳͷͰ͖Δ΋ͷˠܕγεςϜ ! • ಈతνΣοΫͷͰ͖Δ΋ͷˠܕγεςϜ ! • ͍͍ײ͡ʹิ׬Λग़͚ͩ͢ͷ΋ͷˠܕγεςϜ ! • ΏΔ͍ײ͡ 11

Slide 12

Slide 12 text

ࠓ೔࣋ͪؼͬͯ΋Β͏΋ͷ • ֤ܕγεςϜͷ؆୯ͳಋೖํ๏ • ֤ܕγεςϜͷͬ͘͟Γͱͨ͠ҧ͍ • ܕγεςϜΛೖΕ͍ͨͱ͖ͷ൑அج४ 12

Slide 13

Slide 13 text

02 ֤ܕγεςϜͷ঺հ

Slide 14

Slide 14 text

ࠓ೔঺հ͢ΔܕγεςϜ • RBS (+ Steep ) • Sorbe t • Solargraph 14

Slide 15

Slide 15 text

RBS

Slide 16

Slide 16 text

RBS • Ruby 3ͱҰॹʹެ։͞Εͨެࣜͷ΋ͷ • Ruby 2Ͱ΋࢖͑Δ • ੩తղੳͷΈ • جຊతʹ͸steepͱҰॹʹ࢖༻͢Δ • ͳͷͰجຊతʹ͸͜ͷεϥΠυͰRBSΛݴٴ͍ͯ͠Δͱ͖͸ɺSteep΋ηοτͩͱࢥͬ ͍ͯͩ͘͞ 16

Slide 17

Slide 17 text

ಋೖํ๏ - RBS • rbsͱsteepΛGem fi leʹ௥Ճ • steep init • Steep fi leΛฤू • steep check 17

Slide 18

Slide 18 text

ಋೖํ๏ - RBS - Steepfileઃఆྫ 18

Slide 19

Slide 19 text

ܕͷॻ͖ํ - RBS 19

Slide 20

Slide 20 text

Language server - RBS • VS Cod e • steep-vscod e • Vi m • steep langserve r • ͍͍ײ͡ʹ X

Slide 21

Slide 21 text

Language server - RBS - coc.nvimͷྫ X

Slide 22

Slide 22 text

Sorbet

Slide 23

Slide 23 text

Sorbet • Stripe͕ࣾࣾ಺Ͱ࢖͍ͬͯͨ΋ͷΛެ։ͨ͠ • C++੡ • Shopifyͱ͔΋࢖͍ͬͯΔ • ੩తղੳ & ಈతνΣοΫ 21

Slide 24

Slide 24 text

ಋೖํ๏ - Sorbet • Gem fi leʹsorbetͱsorbet-runtimeΛ௥Ճ • srb ini t • srb tc 22

Slide 25

Slide 25 text

Language server - Sorbet • VS Cod e • sorbet-ls p • Vi m • srb tc --enable-all-experimental-lsp-features —lsp • ͍͍ײ͡ʹ X

Slide 26

Slide 26 text

Language server - Sorbet - coc.nvimͷྫ X

Slide 27

Slide 27 text

ܕͷॻ͖ํ - Sorbet 23

Slide 28

Slide 28 text

Solargraph

Slide 29

Slide 29 text

Solargraph • ܕγεςϜͱ͍͏ΑΓLanguage serve r • ੩తղੳ • YARDΛύʔεͯ͠ܕΛղੳ͢Δ 25

Slide 30

Slide 30 text

ಋೖํ๏ - Solargraph • Gem fi leʹsolargraphΛ௥Ճ • solargraph con fi g • solargraph typecheck 26

Slide 31

Slide 31 text

ಋೖํ๏ - Sorbet - .solargraph.ymlͷઃఆྫ 27

Slide 32

Slide 32 text

Language server - Solargraph • VS Cod e • Ruby solargraph • Vi m • ͍͍ײ͡ • coc.nvimͷ৔߹ :CocInstall coc-solargraph X

Slide 33

Slide 33 text

ܕͷॻ͖ํ - Solargraph 28

Slide 34

Slide 34 text

03 ֤ܕγεςϜͷൺֱ

Slide 35

Slide 35 text

4ͭͷ؍఺Ͱൺֱ͍͖ͯ͠·͢

Slide 36

Slide 36 text

ൺֱͷ؍఺ • طଘϓϩδΣΫτಋೖࢧԉ • ެࣜυΩϡϝϯτͷΘ͔Γ΍͢͞ • ܕͷදݱྗ • ΤσΟλࢧԉ 31

Slide 37

Slide 37 text

͋͘·Ͱݸਓͷײ૝Ͱ͢ ଞͷਓ͕΍Δͱશ͘ҧ͏݁Ռʹ ͳΔՄೳੑ΋͋Γ·͢

Slide 38

Slide 38 text

طଘϓϩδΣΫτ΁ͷಋೖࢧԉ

Slide 39

Slide 39 text

RBS >= Sorbet >= Solargraph

Slide 40

Slide 40 text

طଘϓϩδΣΫτ΁ͷಋೖࢧԉ - RBS • rbs prototype r b • ੩తղੳʹΑΓఆٛΛࣗಈੜ੒ • ୯७ͳ΋ͷҎ֎͸untype d • rbs prototype runtim e • ࣮ࡍʹrubyΛಈ͔ͯ͠ఆٛΛࣗಈੜ੒ • User.instance_method s • ΄΅શͯuntyped 35

Slide 41

Slide 41 text

طଘϓϩδΣΫτ΁ͷಋೖࢧԉ - RBS • typepro f • ੩తղੳʹΑΓఆٛΛࣗಈੜ੒ • ܕΛؤுͬͯਪ࿦͢Δ • prototype rbΑΓ΋ܕ͕ఆٛͰ͖Δ • ਫ਼౓͸·ͩߴ͘͸ͳ͍(Β͍͠ ) • ࢀߟ • https://pocke.hatenablog.com/entry/2020/12/18/230235 36

Slide 42

Slide 42 text

طଘϓϩδΣΫτ΁ͷಋೖࢧԉ - Sorbet • https://sorbet.org/docs/adoptin g • Αͼͩ͞Ε͍ͯΔϝιουΛఆٛ • ͓ͦΒ͘શͯuntype d • ࣗ෼Ͱ໌ࣔతॻ͘ͷ͕લఏͳͷͰࣗಈܕఆٛͷαϙʔτ͸ബ͍ • ϑΝΠϧຖͰܕͷϨϕϧΛઃఆͰ͖Δ 37

Slide 43

Slide 43 text

طଘϓϩδΣΫτ΁ͷಋೖࢧԉ - Solargraph • ͳʹ΋ͳ͠ • YARDΛॻ͍͍ͯΕ͹O K • ৔߹ʹΑͬͯ͸Ұ൪ָ͔΋ 38

Slide 44

Slide 44 text

RBS >= Sorbet >= Solargraph

Slide 45

Slide 45 text

ެࣜυΩϡϝϯτͷ෼͔Γ΍͢͞

Slide 46

Slide 46 text

Sorbet > Solargraph >= RBS

Slide 47

Slide 47 text

ެࣜυΩϡϝϯτͷ෼͔Γ΍͢͞ - RBS • https://github.com/ruby/rbs/blob/master/docs/syntax.m d • SteepϑΝΠϧͷॻ͖ํ͕Α͘෼͔Βͳ͍ • ͳΜͱͳ͘Ͱਪଌ͸Ͱ͖Δ • Ͳ͔ͬʹ͔͍ͯΔ͔΋͚ͩͲݟ෇͚Εͳ͔ͬͨ 42

Slide 48

Slide 48 text

ެࣜυΩϡϝϯτͷ෼͔Γ΍͢͞ - Sorbet • https://sorbet.org/docs/overvie w • Πϯετʔϧํ๏ • طଘͷϓϩδΣΫτ΁ͷಋೖํ๏ • τϥϒϧγϡʔςΟϯά • FA Q • ΤϥʔϦϑΝϨϯε • จ๏ 43

Slide 49

Slide 49 text

ެࣜυΩϡϝϯτͷ෼͔Γ΍͢͞ - Solargraph • ܕʹؔ͢ΔυΩϡϝϯτͷྔࣗମ͸গͳ͍ • YARDΛղऍ͍ͯ͠ΔͨΊYARDͷࢿ࢈Λͦͷ··࢖͑Δ 44

Slide 50

Slide 50 text

Sorbet > Solargraph >= RBS

Slide 51

Slide 51 text

ܕγεςϜͱͯ͠ͷදݱྗ(ػೳ਺)

Slide 52

Slide 52 text

Sorbet > RBS > Solargraph

Slide 53

Slide 53 text

ܕγεςϜͱͯ͠ͷදݱྗ(ػೳ਺) 48 RBS Sorbet Solargraph Interface o o Abstract o o Final o Override checking o Overload o o Sealed o Union type o o o Intersection type o o Optional type o o o Record type o o Tuple type o o Proc type o o o Enum o

Slide 54

Slide 54 text

ΤσΟλࢧԉ

Slide 55

Slide 55 text

ΤσΟλࢧԉ - ൺֱํ๏ • Language serverͷ௨৴Λ֬ೝ • initializeͷϨεϙϯεͱɺregister capabilityͷϦΫΤετ • ஫) ͋ͬͯΔ͔Θ͔Βͳ͍ͷͰࢀߟఔ౓ʹଊ͍͑ͯͩ͘͞ • ࢖ͬͯΈͨײ͡ͱͯ͠ൺֱͷॱ൪͸มΘΒͳ͍ҹ৅Ͱ͢ 50

Slide 56

Slide 56 text

Solargraph >= Sorbet > Steep

Slide 57

Slide 57 text

ΤσΟλࢧԉ 52 Steep Sorbet Solargraph hover o o o completion o o o signature help o o definition o o o type definition o o references o o document highlight o o document symbol o o workspace symbol o o o code action o rename o o implementation o formatting o folding range o

Slide 58

Slide 58 text

ͱ͍͏ײ͡Ͱ4ͭͷ؍఺͔Β ൺֱͯ͠Έ·ͨ͠

Slide 59

Slide 59 text

04 ·ͱΊ

Slide 60

Slide 60 text

݁ہͲΕ͕͍͍ͷ?

Slide 61

Slide 61 text

ਖ਼ղ͸ͳ͍

Slide 62

Slide 62 text

RBS(+ Steep)ΛબΜͩ΄͏͕͍͍͔΋͠Εͳ͍ਓ • RubyͷެࣜϥΠϒϥϦ • ࢥ૝ͱͯ͠͸΍͸ΓܕΛͰ͖Δ͚ͩҙࣝ͠ͳ͍Ͱ͍͍ੈքΛ໨ࢦ͍ͯ͠ΔΑ • ·ͩ·ͩൃల్্ͳͷͰػೳͱͯ͠͸ෆ׬શʹײ͡Δ͚Ͳɺকདྷੑ΋͋ΔΑ ! • Rubyͷॻ͖ຯ͸ͦͷ··ʹܕͷԸܙΛड͚͍ͨ!͍ͬͯ͏ਓʹ͓͢͢Ί 57

Slide 63

Slide 63 text

SorbetΛબΜͩ΄͏͕͍͍͔΋͠Εͳ͍ਓ • Stripe͕࡞ͬͨ΍ͭ • ։ൃ͞Ε͔ͯΒ݁ߏܦͬͯΔͷͰ҆ఆ͍ͯ͠Δ • ͔ͬ͠ΓܕΛҙࣝͯ͠ॻ͖͍ͨ ! • interfaceࢦ޲Ͱ fi nal͔abstract͚ͩͷੈքΛ࡞Γ͍ͨ ! • (ࣗ෼͸SorbetΛ࢖͍ͬͯ·͢) 58

Slide 64

Slide 64 text

SolargraphΛબΜͩ΄͏͕͍͍͔΋͠Εͳ͍ਓ • ͱΓ͋͑ͣิ׬͕΄͍͠ΜͩΑͳ • YARDॻ͍ͯΔΜ͚ͩͲ͜ΕͰܕνΣοΫͰ͖ͳ͍ ? • ผϑΝΠϧʹॻ͘ͷ΋໘౗ͩ͠ɺsig͸ͳΜ͔޷͖ʹͳΕͳ͍ • Language server͕Ϧονͳ΋ͷ͕͍͍! 59

Slide 65

Slide 65 text

͍͔͕Ͱͨ͠Ͱ͠ΐ͏͔?

Slide 66

Slide 66 text

Enjoy Ruby with Type