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

Ruby 3.0: Redux (Saint P RubyConf 2019)

Ruby 3.0: Redux (Saint P RubyConf 2019)

1be785d1d788b82929e55fc83a9f0aaa?s=128

Bozhidar Batsov

June 01, 2019
Tweet

Transcript

  1. None
  2. None
  3. Привет, ребята!

  4. Божидар

  5. Божо cool

  6. Bozhidar

  7. Bozhidar

  8. Bug cool

  9. Божи дар

  10. Божий дар

  11. None
  12. @bbatsov

  13. Бацов

  14. Батсов

  15. Sofia, Bulgaria Sofia, Bulgaria

  16. None
  17. None
  18. Bulgarian Cheese

  19. Болгарка

  20. Слънчев Бряг

  21. Златни пясъци

  22. Банско

  23. Луканка

  24. Rakia Connecting People

  25. Shopska Salad (use only with Rakia)

  26. None
  27. None
  28. None
  29. None
  30. None
  31. None
  32. bbatsov

  33. metaredux.com

  34. None
  35. None
  36. None
  37. None
  38. None
  39. None
  40. None
  41. None
  42. None
  43. None
  44. None
  45. None
  46. None
  47. None
  48. None
  49. None
  50. None
  51. Много городов у нас в России, Нету пальцев столько на

    ногах, С каждым годом всё они красивей, Утопают в солнце и в снегах.
  52. None
  53. None
  54. None
  55. None
  56. Not on Ruby’s Core Team

  57. Ruby & Rails style guides

  58. None
  59. None
  60. None
  61. None
  62. Matz on Ruby

  63. Language Maturity

  64. The Ruby Community

  65. Ruby is not dying

  66. None
  67. None
  68. We have to feed the community intellectually. — Matz

  69. We have to keep moving forward. — Matz

  70. Backwards Compatibility

  71. We’re not going to repeat the Python 3 mistakes! —

    Matz
  72. Victim of the Hype Cycle

  73. None
  74. Rails Mania (2008)

  75. Ruby Today

  76. Ruby Today

  77. 2025

  78. Matz’s Retirement

  79. None
  80. Ruby 4

  81. Ruby 4x4

  82. Ruby 4 is going to be 4 times faster than

    Ruby 3
  83. Ruby 4 is going to be 12 times faster than

    Ruby 2
  84. Ruby 4 is finally going to be fast enough!

  85. None
  86. What about Ruby 3?

  87. –Matz “We’ll aim to release Ruby 3 for the Olympic

    Games in Tokyo in 2020.”
  88. Ruby 3 Goals •Improved programming safety •Faster performance •Better concurrency/parallelism

    support •Better tools
  89. Optional static typing?

  90. Duck inference?

  91. Actors?

  92. Stream based model?

  93. Ownership based model?

  94. Guilds?

  95. 3 times faster performance?

  96. Smaller Goals •Sane keyword arguments (?!!?!) •Pattern Matching •Deprecation of

    quirky features •Frozen string literals
  97. None
  98. Ruby 3.0 Redux

  99. Dictionary Definitions

  100. Ruby

  101. noun 1. a precious stone consisting of corundum in colour

    varieties varying from deep crimson or purple to pale rose. 2. a programming language optimised for programmer happiness
  102. 3

  103. number 1. equivalent to the sum of one and two;

    one more than two; 3 2. A mystical version rarely achieved by most software projects.
  104. Redux

  105. adjective 1. brought back, revived Emacs era redux 2. (usually

    postpositive) (esp of an artistic work) presented in a new way Apocalypse Now Redux
  106. None
  107. Ruby 3.0 is not a single magic release

  108. Ruby 3.0 is an idea

  109. None
  110. Ruby follows SemVer

  111. Ruby 3 is going to be 3 times faster than

    Ruby 2.0
  112. Generational GC (Ruby 2.1)

  113. Incremental GC (Ruby 2.2)

  114. MJIT (Ruby 2.6)

  115. New AST library (Ruby 2.6)

  116. Deprecation of flip-flops (Ruby 2.6)

  117. Ruby 2.7

  118. Numbered block parameters

  119. numbers.map { Math.log2(@1) }

  120. foo.bar { @1 + @2 }

  121. h = Hash.new { @1[@2] = "Go Fish: #{@2}" }

  122. h = Hash.new { @1[@2] = "Go Fish: #{@2}" }

  123. None
  124. https://bugs.ruby-lang.org/issues/15723

  125. Method reference operator

  126. [2, 4, 8, 16, 32].map { |n| Math.log2(n) }

  127. [2, 4, 8, 16, 32].map(&method(Math.log2))

  128. [2, 4, 8, 16, 32].map(&Math.:log2)

  129. [2, 4, 8, 16, 32].map { Math.log2($1) }

  130. Beginless range

  131. Beginless range

  132. Beginningless range

  133. arr[..3]

  134. items.where(price: ..20)

  135. None
  136. Pattern Matching (https://bugs.ruby-lang.org/issues/14912)

  137. person = JSON.parse('{...}', symbolize_names: true) if person[:name] == ‘Alice’ children

    = person[:children] if children.length == 1 && children[0][:name] == ‘Bob’ p children[0][:age] end end
  138. case JSON.parse('{...}', symbolize_names: true) in {name: "Alice", children: [{name: "Bob",

    age: age}]} p age ... end
  139. None
  140. Resources • https://speakerdeck.com/k_tsj/pattern-matching-new- feature-in-ruby-2-dot-7 • https://medium.com/@baweaver/ruby-2-7-pattern-matching- first-impressions-cdb93c6246e6 • https://medium.com/@baweaver/ruby-2-7-pattern-matching- destructuring-on-point-90f56aaf7b4e

  141. All those features are experimental and subject to change

  142. Compaction GC

  143. MJIT Tuning/optimizations

  144. Ruby 2.7.0-preview1 is out!

  145. Ruby 3.0 (Current Status)

  146. Better Tools

  147. RubyGems 3

  148. The bundling of Bundler (Ruby 2.6)

  149. Gemifying the Standard Library (ongoing progress)

  150. Default vs Bundled Gems

  151. Default Gems • Bundler • RubyGems • date • irb

    • json • …
  152. Bundled Gems • minitest • did_you_mean • rake • …

  153. stdgems.org

  154. irb • New reline backend (portable replacement for readline) •

    Completion • Multi-line editing • Syntax-highlighting • Integration with RDoc
  155. None
  156. RDoc • Redesigned documentation system • Twice as fast

  157. Ruby 3x3

  158. Only applies to certain benchmarks

  159. Ruby 2.6 is 65% faster than Ruby 2.0

  160. None
  161. 10% average speedup per release

  162. None
  163. MJIT is the biggest hope for Ruby 3x3

  164. Guilds

  165. None
  166. None
  167. Developed outside the Ruby’s main repo

  168. https://github.com/ko1/ruby/tree/guild

  169. Work in progress ™

  170. Parallel Programming in Ruby 3 with Guilds (http://www.atdot.net/~ko1/activities/2018_rubyconf2018.pdf)

  171. Static Typing

  172. https://bugs.ruby-lang.org/issues/9999

  173. None
  174. Native Support for Тype Signatures in Ruby 3.0

  175. None
  176. With a twist…

  177. Dedicated Ruby interface files (.rbi)

  178. class Person @name: String @contacts: Array<Email | Phone> def initialize:

    (name: String) -> any def name: -> String def contacts: -> Array<Email | Phone> def guess_country: -> (String | nil) end
  179. https://github.com/soutaro/steep

  180. Type Signatures for Ruby Core (https://github.com/ruby/ruby-signature)

  181. Rakia Connecting People

  182. Open Questions • Is Steep becoming part of the Standard

    Library? • How is Sorbet going to make use of its type annotations? • Typing applications
  183. Built-in Type Inference Checker

  184. def foo(x) if x > 10 x.to_s else x.boo() x

    + 42 end end foo(42)
  185. $ exe/type-profiler test.rb test.rb:6: [error] undefined method: Integer#boo test.rb:7: [error]

    failed to resolve overload: Integer#+ Object#foo :: (Integer) -> String
  186. Resources • https://www.slideshare.net/mametter/a-typelevel-ruby- interpreter-for-testing-and-understanding • https://github.com/mame/ruby-type-profiler

  187. Sane Keyword Arguments

  188. https://bugs.ruby-lang.org/issues/14183

  189. # The following calls pass keyword arguments foo(..., key: val)

    foo(..., **hsh) foo(..., key: val, **hsh)
  190. # The following calls pass **normal** arguments foo(..., {key: val})

    foo(..., hsh) foo(..., {key: val, **hsh})
  191. Breaking change!!!

  192. Migration warning in Ruby 2.7

  193. What’s not in Ruby 3.0?

  194. Actors

  195. Stream processing

  196. Frozen string literals

  197. Deprecation of autoload

  198. https://github.com/fxn/zeitwerk

  199. Deprecation of backticks (`some-command`)

  200. Deprecation of character literals (?x)

  201. Summary

  202. • Ruby 2.7 will be the final release in the

    2.x series • Ruby 3.0 is scheduled to land in 2020 • Ruby 2.7 will serve as a preview for many of the key features in Ruby 3.0 • Static typing and Guilds are the biggest changes coming to Ruby 3.0 • Keyword argument overhaul is going to be a breaking change • The migration path from Ruby 2.x to 3.x should be very smooth
  203. Community Impact

  204. Community Contributed Features • UTF-8 • Enumerator • Generational GC

    • Keyword Arguments • JIT • Concurrency
  205. Community Contributions • Rake • Bundler • Documentation & Tutorials

    • A ton of amazing libraries • Rails • …
  206. None
  207. Real Namespaces (https://bugs.ruby-lang.org/issues/14982)

  208. None
  209. Felina

  210. Спасибо! twitter: @bbatsov github: @bbatsov https://metaredux.com https://emacsredux.com Saint P RubyConf

    2019 Saint Petersburg, Russia 01.06.2019