Ruby in 2019

2cf373725ded741824c50fd571eda6e1?s=47 KONDO Uchio
August 29, 2019

Ruby in 2019

@Developers Summit 2019 Fukuoka

Sample codes: https://github.com/udzura/ruby-2.7.0-samples

2cf373725ded741824c50fd571eda6e1?s=128

KONDO Uchio

August 29, 2019
Tweet

Transcript

  1. All About Ruby in 2019 2019೥ɺվΊͯ஫໨͢ΔRuby―RubyKaigi͔ΒݟΔRuby 3.0ͷՄೳੑ Presentation by Uchio

    Kondo @Developers Summit 2019 Fukuoka
  2. Engineer @ GMO Pepabo, Inc. Uchio Kondo / @udzura https://blog.udzura.jp/

    * ɹɹɹɹɹɹɹɹ ϩʔΧϧΦʔΨφΠβʔ/ొஃऀ * CloudNative Days Fukuoka 2019 νΣΞΦʔΨφΠβʔ * ίϛϡχςΟ: Fukuoka.rb ɺ #;͘͹Ͷͯ͢ * Duolingo Ruby Leaguer
  3. Ruby Language

  4. ࣭໰Ͱ͢ • ͓࢓ࣄͰRuby࢖͍ͬͯ·͔͢ʁ • ͓࢓ࣄͰRails͡Όͳ͍RubyΛ࢖͍ͬͯ·͔͢ʁ • RubyKaigi 2019 in Fukuokaɺߦ͖·͔ͨ͠ʁ

  5. Ruby in 2019

  6. Ruby • ޿͘࢖ΘΕ͍ͯΔϓϩάϥϛϯάݴޠͰ།Ұɺ೔ຊਓ͕։ൃͨ͠΋ͷ • εΫϦϓτݴޠɺΦϒδΣΫτࢦ޲ɺಈతܕ෇͚ • ࠷৽൛: 2.6.4 @ 2019-08-28

    • ։ൃ൛: 2.7.0-preview1 @ 2019-05-31
  7. TryRuby! • https://ruby.github.io/TryRuby/

  8. Ruby on Dockerhub • Docker community͕४උͨ͠RubyҎ֎ʹɺRuby core teamͷϏϧυͯ͠ ͍ΔΠϝʔδ͕ଘࡏ͢Δɻ৔߹ʹΑͬͯ͸ͪ͜ΒΛ࢖ͬͨํ͕͍͍͔΋ •

    Docker community൛: ruby:2.6.3-* • Ruby core team൛: rubylang/ruby:2.6.3-* • trunk(एऀͷ͍͏master) ΋؆୯ʹར༻Ͱ͖Δ
  9. diff • ઃఆ͞Ε͍ͯΔ؀ڥม਺͕ҧ͏ɻDocker community ެࣜͷ΋ͷ͸บ͕͋ Δҹ৅... ٯʹ bionic Ҏ֎ͷbase image͸Docker൛ʹ͔͠ͳ͍

  10. RubyϦϙδτϦGitԽ • ௕Β͘ Subversion ͕ϝΠϯϦϙδτϦ͕ͩͬͨGitʹҠߦ • GitHub ͳͲͰϛϥʔ͍͕ͨ͠ git-svn ͸ͱͯ΋໘౗

    • ύονΛૹͬͯ͘Εͨਓͷ৘ใͳͲΛ͏·͘ࡌ͍ͤͨ • https://k0kubun.hatenablog.com/entry/ruby-core-2019 • https://www.hsbt.org/diary/20190423.html
  11. git.ruby-lang.org • ެࣜͷϦϙδτϦ͸cgitͰίϛϡχςΟ͕ϗετ͍ͯ͠Δ • ʮGitHubԽʯ͸͍ͯ͠ͳ͍ • ͱ͸͍͑clone͍ͨ͠ࡍ͸GitHubͷϛϥʔਪ঑ • GitHubʹPRΛग़ͤ͹൓өͯ͘͠ΕΔ͠ɺίϯτϦϏϡʔλʹ΋ܝࡌ͞Ε Δʢʂʂʣ

    • Git ͷ෼ࢄϦϙδτϦͰ͋Δͱ͜ΖͷϝϦοτ https://git.ruby-lang.org/ruby.git/
  12. ͪͳΈʹ • ඪ४ϥΠϒϥϦ͸ gem Խ͕΄΅ऴΘ͍ͬͯΔ • https://stdgems.org/ • GitHub ্Ͱɺ

    Ruby ίΞͱ͸ผͷϦϙδτϦʹͳ͍ͬͯΔ
 ʢRubyίΞࣗମ͸ɺgitwebʹ͋Δʣ • https://github.com/ruby/
  13. ͪͳΈʹ • ඪ४ϥΠϒϥϦͰ͋ͬͯ΋ɺʮ࠷৽൛ʯΛΠϯετʔϧͯ͠ར༻͕Մೳ $ gem install specific_install $ gem specific_install

    http://github.com/ruby/irb $ gem list -d irb *** LOCAL GEMS *** irb (1.1.0.pre.2, 1.0.0) Author: Keiju ISHITSUKA Homepage: https://github.com/ruby/irb License: BSD-2-Clause Installed at (1.1.0.pre.2): /Users/udzura/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0 (1.0.0, default): /Users/udzura/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0 Interactive Ruby command-line tool for REPL (Read Eval Print Loop).
  14. ruby-jp • ೔ຊޠΛ࿩ͤΔRubyistʹΑΔڊେSlack͕Ͱ͖ͨ • https://ruby-jp.github.io/ • > ruby-jp ͸ Ruby

    ϓϩάϥϚʔಉ࢜ͷަྲྀΛ໨తͱͨ͠ Slack ϫʔΫε ϖʔεͰ͢ɻ
 > ࢀՃऀͷٕज़ϨϕϧʹؔΘΒͣɺ࣭໰ɾ૬ஊɾ৘ใަ׵ΛؾܰʹͰ͖Δ ৔Λ໨ࢦ͍ͯ͠·͢ɻ
  15. Where Ruby is used • Web Application Framework: Ruby on

    Rails • 6.0 released @ 2019-08-15
  16. Where Ruby is used • Logging middleware: Fluentd • A

    member project of Cloud Native Computing Foundation
  17. Where Ruby is used • Infrastructure as Software: • Chef/Itamae

    • Vagrant • Serverspec
  18. Where Ruby will be used? • Frontend!!! • Opal •

    Data Science • Red Data Tools
  19. ͓·͚: mruby • ʮ૊ΈࠐΈʯ޲͚ mruby • ಛ௃: • CRuby ͱൺ΂όΠφϦ͕খ͔ͬͨ͞ΓলϝϞϦ


    ʮશ෦ೖΓʯmrubyόΠφϦ/static libΛ࡞Γ΍͍͢
 C API͕੔උ͞Ε͍ͯΔ • ͨͩ͠ɺࠓ೔͸CRubyͷ࿩Λத৺ʹ͠·͢...
  20. RubyKaigi in 2019 https://rubykaigi.org/2019

  21. Venue • ෱Ԭࠃࡍձٞ৔ @ 2019-04-18 ~ 20

  22. ԰୆ϥϯν

  23. ࠙਌ձ

  24. Talks

  25. Topics • Keynotes: • About Ruby 3 and its future

    by Matz • Branch Maintainer’s Life by nagachika • Extreme optimization tech for Ruby by Jeremy • Talks: • C-level Ruby optimization / specification details • Ecosystems such as bundler, RSpec, Typings, Homebrew... • JRuby / TruffleRuby / mruby... / serverless, containers, cloudnative...
  26. Ruby committers vs the world • Photo from: https://tech.drecom.co.jp/rubykaigi-2019-day3-report/

  27. Ruby updates in (2.3..2.6)

  28. Ruby 2.3.0 • Frozen String Literal ϓϥάϚ • did_you_mean gem

    ͷόϯυϧ • ʮ&.ʯΦϖϨʔλͷಋೖɻnilͰ΋ͳΔ΂҆͘શʹϝιουݺͼग़͠ • ύϑΥʔϚϯεͷվળʢProc#call ͷ࠷దԽͳͲʣ
  29. Ruby 2.4.0 • Fixnum/Bignumͷ౷߹ • binding.irb ͱॻ͚ΔΑ͏ʹͳΔ • ύϑΥʔϚϯεվળʢHashͷ಺෦σʔλߏ଄มߋͳͲʣ

  30. Ruby 2.5.0 • rescue/else/ensure Λ do/end ϒϩοΫʹ௚઀ॻ͚ΔΑ͏ʹ • ΧόϨοδͷڧԽʢ෼ذΧόϨοδͱϝιουΧόϨοδͷαϙʔτʣ •

    ύϑΥʔϚϯεͷվળʢVMͰͷtrace໋ྩͷ੔ཧɺϒϩοΫ౉͠ͷํࣜม ߋɺERBͷվળʣ
  31. Ruby 2.6.0 • JITͷಋೖ • RubyVM::AST ͷಋೖ • ऴ୺ͳ͠Rangeͷಋೖ •

    ύϑΥʔϚϯεͷվળ
 ʢϒϩοΫݺͼग़͠ͷվળɺίϧʔνϯͷωΠςΟϒԽʣ
  32. None
  33. Six Years of Ruby Performance • From RubyKaigi 2019 https://rubykaigi.org/2019/presentations/codefolio.html

  34. What’s new in Ruby 2.7.0 !!

  35. Caveats • ਖ਼ࣜϦϦʔεલͷόʔδϣϯͷ࢓༷ͳͷͰมߋ͢Δ͜ͱ͕͋Γ·͢ • ࣮ࡍൃදޙʹ2ՕॴมΘ͍ͬͯ·͢ʼʻ • ൃද࣌఺ʢ2019-08-29 17:00ʣͰͷ৘ใͱͳΓ·͢

  36. Pattern matching • case ... in ... ͱ͍͏จ๏Λಋೖ • ෳࡶͳߏ଄ͷϚονϯάͷधཁʹԠ࣮͑ͯ૷ɻ


    ΨʔυઅͳͲ΋͋Δ • Duck TypingΛར༻ͯ͠Ϛονϯά͢ΔΫϥεΛ֦ுͰ͖Δ http://blog.akanumahiroaki.com/entry/2019/05/02/200000
  37. Pattern matching: demo

  38. Numbered parameter in block https://autopp-tech.hatenablog.com/entry/2019/03/19/095500

  39. Changed! (edited after presentation) • @1, @2, @3 -> _1,

    _2, _3 • _1, _2, _3 ͱ͍͏ϩʔΧϧม਺͕͋ͬͨΒܯࠂ͕ग़ΔΑ͏ʹͳΓ·͢
  40. Beginless range https://blog.saeloun.com/2019/08/19/ruby-2-7-adds-beginless-range.html

  41. Pipeline operator https://dev.to/baweaver/ruby-2-7-the-pipeline-operator-1b2d ※ ͜Ε͸ preview-1 ʹ͸ؚ·Εͣɺdev൛ͷΈͰ͢

  42. reverted... (edited after presentation) > Maybe we would revisit the

    idea in the future (with different operator appearance)
  43. .: operator

  44. IRB improvement Syntax highlight ϝιουิ׬࣌ʹ υΩϡϝϯτ͕ग़Δ

  45. More next generation features in Ruby

  46. Typing • Current implementations: • Sorbet • ίʔυ಺ͷܕΞϊςʔγϣϯ • Steep

    • Gradual TypingɺܕఆٛϑΝΠϧ(.rbi) • ...
  47. Sorbet demo:

  48. Sorbet demo:

  49. Steep demo:

  50. Concurrency (Guild) • Many presentations by Koichi Sasada • "Guild

    Prototype" in RubyKaigi “2018” https://www.slideshare.net/KoichiSasada/guild-prototype
  51. Guild Idea • Thread/FiberΛ͞ΒʹแΉ΋ͷͱͯ͠GuildʢԾ໊ʣΛಋೖ • Guildʹॴଐ͍ͯ͠ΔΦϒδΣΫτ͸ɺଞͷGuild͔Β৮Εͳ͍ • Guildಉ࢜ͰΠϛϡʔλϒϧͳΦϒδΣΫτ͚ͩΛɺνϟϯωϧͰڞ༗

  52. Concurrency (AutoFiber) • Switch Fibers by I/O operations • ʮ໊લʯ໰୊...

    https://bugs.ruby-lang.org/issues/13618
  53. Is Ruby dead??

  54. What is being dead? • ୭΋࢖Θͳ͘ͳͬͨΒʁ • ։ൃ͕ఀࢭͨ͠Βʁ/׆ൃͰ͸ͳ͘ͳͬͨΒʁ • ࿩୊ʹͳΒͳ͘ͳͬͨΒʁ

  55. Hype Cycles https://www.gartner.com/jp/research/methodologies/gartner-hype-cycle

  56. Conclusion

  57. The future • Ruby ͸ࠓ΋ΞΫςΟϒʹ։ൃ͕͞Ε͍ͯΔ • Ϣʔβ͕ଟ͍ݴޠͰ͸͋Δʹ΋͔͔ΘΒͣɺະདྷͷͨΊʹେ͖ͳมߋ͕ ೖ͍ͬͯΔͱ͜Ζ • ܕ҆શੑɺฒߦੑɺύλʔϯϚονͳͲͷ࠷ۙͷݴޠͷ੒ՌΛऔΓೖΕ

    Α͏ͱ͍ͯ͠Δ • ͏·͍͚͘͹ɺΑΓݱ୅తͳݴޠͱͯ͠࠶౓஫໨͕ू·Δ͔΋
  58. มԽΛָ͠΋͏ Enjoy Programming, Enjoy Changes

  59. [PR]

  60. Fukuoka.rb #150 #149 @ 9/18(Wed) https://fukuokarb.connpass.com/event/144604/