Ruby 3.0 Redux (Pivorak 4.0)

Ruby 3.0 Redux (Pivorak 4.0)

1be785d1d788b82929e55fc83a9f0aaa?s=128

Bozhidar Batsov

October 18, 2019
Tweet

Transcript

  1. None
  2. Привiт!

  3. Божидар

  4. Божо cool

  5. Bozhidar

  6. Bozhidar

  7. Божи дар

  8. Божий дар

  9. None
  10. Sofia, Bulgaria Sofia, Bulgaria

  11. None
  12. bbatsov

  13. Ruby & Rails style guides

  14. •rubystyle.guide •rails.rubystyle.guide •rspec.rubystyle.guide •minitest.rubystyle.guide •blog.rubystyle.guide

  15. None
  16. None
  17. None
  18. rubocop-minitest

  19. rubocop-rake

  20. None
  21. emacsredux.com

  22. metaredux.com

  23. #7 on the list of top white hackers in Bulgaria!

  24. None
  25. Божидар Батсов

  26. стацковарфлоу

  27. Expert in cyber security

  28. Expert in the following programming languages: Unix, Emacs, Perl and

    Ruby
  29. The Don Juan of IT in Bulgaria

  30. None
  31. slide intentionally left blank

  32. None
  33. None
  34. Bulgarian Cheese

  35. Болгарка

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

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

  38. Банско

  39. Луканка

  40. Rakia Connecting People

  41. Shopska Salad (use only with Rakia)

  42. None
  43. None
  44. Bulgarian politics are shit wrapped in cellophane.

  45. I’m never happy about a small pig and a new

    boss.
  46. To mess with my deputy is like sitting butt naked

    on a hedgehog.
  47. None
  48. None
  49. None
  50. None
  51. None
  52. None
  53. None
  54. None
  55. The most beautiful city in Ukraine

  56. None
  57. То є Львів, мій колєґа, про нього різне кажуть: Приезжим

    из востока Криївку тут покажуть. То є Львів, моє місто, не з простого тіста, Ліплений роками – друзями й ворогами. То є Львів старенький, мудрий, сивий дядько, Кожному залишить кавалочок на згадку. То є Львів "Бонжорно!", Неаполь і Ліворно, По-галицьки говорять, наші в них погоду роблять.
  58. То є Львів, шановні, вбирайте шлюбні сподні, Краватку, маринарку і

    "вйо!" по Стрийськім парку. То є Львів чудовий, вуйко ґонуровий, Я тішуся, шо з вами ходжу цими вулицями. То є Львів старенький, мудрий, сивий дядько, Кожному залишить кавалочок на згадку. То є Львів "Бонжорно!", Неаполь і Ліворно, По-галицьки говорять, наші в них погоду роблять. То є Львів, то Львів...
  59. None
  60. None
  61. None
  62. Not on Ruby’s Core Team

  63. Matz on Ruby

  64. Language Maturity

  65. The Ruby Community

  66. Ruby is not dying

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

  70. We have to keep moving forward. — Matz

  71. Backwards Compatibility

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

    Matz
  73. Victim of the Hype Cycle

  74. None
  75. Rails Mania (2008)

  76. Ruby Today

  77. Ruby Today

  78. 2025

  79. Matz’s Retirement

  80. None
  81. Ruby 4

  82. Ruby 4x4

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

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

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

  86. None
  87. What about Ruby 3?

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

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

    support •Better tools
  90. Optional static typing?

  91. Duck inference?

  92. Actors?

  93. Stream based model?

  94. Ownership based model?

  95. Guilds?

  96. 3 times faster performance?

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

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

  100. Dictionary Definitions

  101. Ruby

  102. 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
  103. 3

  104. 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.
  105. Redux

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

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

  109. Ruby 3.0 is an idea

  110. None
  111. Ruby follows SemVer

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

    Ruby 2.0
  113. Generational GC (Ruby 2.1)

  114. Incremental GC (Ruby 2.2)

  115. MJIT (Ruby 2.6)

  116. New AST library (Ruby 2.6)

  117. Deprecation of flip-flops (Ruby 2.6)

  118. Ruby 2.7

  119. Numbered block parameters

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

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

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

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

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

  126. numbers.map { Math.log2(_1) }

  127. None
  128. Method reference operator

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

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

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

  132. [2, 4, 8, 16, 32].map { Math.log2(_1) }

  133. Beginless range

  134. Beginless range

  135. Beginningless range

  136. arr[..3]

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

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

  140. 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
  141. case JSON.parse('{...}', symbolize_names: true) in {name: "Alice", children: [{name: "Bob",

    age: age}]} p age ... end
  142. None
  143. 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

  144. All those features are experimental and subject to change

  145. Deprecating $; and $,

  146. > $; = " " warning: non-nil $; will be

    deprecate => " " > "hello world!".split warning: $; is set to non-nil value => ["hello", "world!"] > $, = " " warning: non-nil $, will be deprecated => " " > ["hello", "world!"].join warning: non-nil $, will be deprecated => "hello world!"
  147. Compaction GC

  148. MJIT Tuning/optimizations

  149. flip-flops were finally deprecated!

  150. Then they were reinstated…

  151. None
  152. Pipeline operator

  153. foo() .bar(1, 2) .display

  154. foo() |> bar 1, 2 |> display

  155. None
  156. Added, contested and removed

  157. None
  158. Ruby 2.7 is coming for Christmas!

  159. Ruby 3.0 (Current Status)

  160. Better Tools

  161. RubyGems 3

  162. The bundling of Bundler (Ruby 2.6)

  163. Gemifying the Standard Library (ongoing progress)

  164. Default vs Bundled Gems

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

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

  167. stdgems.org

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

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

  171. Ruby 3x3

  172. Only applies to certain benchmarks

  173. Ruby 2.6 is 65% faster than Ruby 2.0

  174. None
  175. 10% average speedup per release

  176. None
  177. MJIT is the biggest hope for Ruby 3x3

  178. Guilds

  179. None
  180. None
  181. Developed outside the Ruby’s main repo

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

  183. Work in progress ™

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

  185. Static Typing

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

  187. None
  188. Native Support for Тype Signatures in Ruby 3.0

  189. None
  190. With a twist…

  191. Dedicated Ruby interface files (.rbi)

  192. Dedicated Ruby signature files (.rbs)

  193. 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
  194. https://github.com/soutaro/steep

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

  196. Rakia Connecting People

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

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

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

    + 42 end end foo(42)
  200. $ 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
  201. Resources • https://www.slideshare.net/mametter/a-typelevel-ruby- interpreter-for-testing-and-understanding • https://github.com/mame/ruby-type-profiler

  202. Sane Keyword Arguments

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

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

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

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

  207. Migration warning in Ruby 2.7

  208. def a_method(k: 1) puts "k: #{k}" end a_method({k: 1}) (irb):4:

    warning: The last argument is used as the keyword parameter (irb):1: warning: for `a_method' defined here => k: 1
  209. # To avoid the warning # and make it Ruby

    3 compatible, # use the double splat operator a_method(**{k: 1}) => k: 1
  210. What’s not in Ruby 3.0?

  211. Actors

  212. Stream processing

  213. Frozen string literals

  214. Deprecation of autoload

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

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

  217. Deprecation of character literals (?x)

  218. Summary

  219. • 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
  220. Community Impact

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

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

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

  225. None
  226. Felina

  227. Дякую! twitter: @bbatsov github: @bbatsov https://metaredux.com https://emacsredux.com Pivorak 4.0 Lviv,

    Ukraine 18.10.2019