Ruby 4: To Infinity and Beyond

1be785d1d788b82929e55fc83a9f0aaa?s=47 Bozhidar Batsov
September 30, 2017

Ruby 4: To Infinity and Beyond

Slide deck from my presentation at EuRuKo 2017 in Budapest.

1be785d1d788b82929e55fc83a9f0aaa?s=128

Bozhidar Batsov

September 30, 2017
Tweet

Transcript

  1. 1.
  2. 2.
  3. 5.
  4. 11.
  5. 12.
  6. 13.
  7. 15.
  8. 16.
  9. 17.
  10. 18.
  11. 19.
  12. 20.
  13. 21.
  14. 22.
  15. 29.
  16. 33.
  17. 37.
  18. 38.

    •keyword arguments •%i •UTF-8 is now the default source file

    encoding •Refinements (experimental feature)
  19. 39.
  20. 41.
  21. 42.
  22. 43.
  23. 45.
  24. 47.
  25. 48.

    •Top-level constant look-up is removed •rescue/else/ensure are allowed inside do/end

    blocks •refinements take place in string interpolations

  26. 50.

    Ruby 2.2 includes many new features and improvements for the

    increasingly diverse and expanding demands for Ruby. For example, Ruby’s Garbage Collector is now able to collect Symbol type objects. This reduces memory usage of Symbols; because GC was previously unable to collect them before 2.2. Since Rails 5.0 will require Symbol GC, it will support only Ruby 2.2 or later. (See Rails 4.2 release post for details.) Also, a reduced pause time thanks to the new Incremental Garbage Collector will be helpful for running Rails applications. Recent developments mentioned on the Rails blog suggest that Rails 5.0 will take advantage of Incremental GC as well as Symbol GC.
  27. 51.

    Ruby 2.2 includes many new features and improvements for the

    increasingly diverse and expanding demands for Ruby. For example, Ruby’s Garbage Collector is now able to collect Symbol type objects. This reduces memory usage of Symbols; because GC was previously unable to collect them before 2.2. Since Rails 5.0 will require Symbol GC, it will support only Ruby 2.2 or later. (See Rails 4.2 release post for details.) Also, a reduced pause time thanks to the new Incremental Garbage Collector will be helpful for running Rails applications. Recent developments mentioned on the Rails blog suggest that Rails 5.0 will take advantage of Incremental GC as well as Symbol GC.
  28. 52.

    Ruby 2.2 includes many new features and improvements for the

    increasingly diverse and expanding demands for Ruby. For example, Ruby’s Garbage Collector is now able to collect Symbol type objects. This reduces memory usage of Symbols; because GC was previously unable to collect them before 2.2. Since Rails 5.0 will require Symbol GC, it will support only Ruby 2.2 or later. (See Rails 4.2 release post for details.) Also, a reduced pause time thanks to the new Incremental Garbage Collector will be helpful for running Rails applications. Recent developments mentioned on the Rails blog suggest that Rails 5.0 will take advantage of Incremental GC as well as Symbol GC.
  29. 53.

    Ruby 2.2 includes many new features and improvements for the

    increasingly diverse and expanding demands for Ruby. For example, Ruby’s Garbage Collector is now able to collect Symbol type objects. This reduces memory usage of Symbols; because GC was previously unable to collect them before 2.2. Since Rails 5.0 will require Symbol GC, it will support only Ruby 2.2 or later. (See Rails 4.2 release post for details.) Also, a reduced pause time thanks to the new Incremental Garbage Collector will be helpful for running Rails applications. Recent developments mentioned on the Rails blog suggest that Rails 5.0 will take advantage of Incremental GC as well as Symbol GC.
  30. 54.

    Ruby 2.2 includes many new features and improvements for the

    increasingly diverse and expanding demands for Ruby. For example, Ruby’s Garbage Collector is now able to collect Symbol type objects. This reduces memory usage of Symbols; because GC was previously unable to collect them before 2.2. Since Rails 5.0 will require Symbol GC, it will support only Ruby 2.2 or later. (See Rails 4.2 release post for details.) Also, a reduced pause time thanks to the new Incremental Garbage Collector will be helpful for running Rails applications. Recent developments mentioned on the Rails blog suggest that Rails 5.0 will take advantage of Incremental GC as well as Symbol GC.
  31. 55.

    Ruby 2.2 includes many new features and improvements for the

    increasingly diverse and expanding demands for Ruby. For example, Ruby’s Garbage Collector is now able to collect Symbol type objects. This reduces memory usage of Symbols; because GC was previously unable to collect them before 2.2. Since Rails 5.0 will require Symbol GC, it will support only Ruby 2.2 or later. (See Rails 4.2 release post for details.) Also, a reduced pause time thanks to the new Incremental Garbage Collector will be helpful for running Rails applications. Recent developments mentioned on the Rails blog suggest that Rails 5.0 will take advantage of Incremental GC as well as Symbol GC.
  32. 56.
  33. 58.
  34. 65.
  35. 67.
  36. 73.
  37. 74.
  38. 75.

    –Zach Tellman There has been a consistent migratory pattern from

    Ruby to node.js to Go, Rust, and Elixir. At first, each community is defined by its potential. But as that potential is realized, the community begins to be defined by its compromises. That change is felt most keenly by the people who were there first, who remember what it was like when anything seemed possible. They feel fenced in and so they move on, in search of their golden city…”
  39. 77.
  40. 79.
  41. 81.
  42. 91.
  43. 101.

    pre { |x| x > 0 } post { |r,x|

    r > 0 } def sqrt(x) # return the square root of x end
  44. 102.

    type '(Float x {{ x>=0 }}) -> Float y {{

    y>=0 }}' def sqrt(x) # return the square root of x end
  45. 105.

    CSP

  46. 107.

    def sum(a, c) sum = a.reduce(0, &:+) c << sum

    # `<<` is an alias for `put` or `send` end a = [7, 2, 8, -9, 4, 0] l = a.length / 2 c = Concurrent::Channel.new Concurrent::Channel.go { sum(a[-l, l], c) } Concurrent::Channel.go { sum(a[0, l], c) } x, y = ~c, ~c # `~` is an alias for `take` or `receive` puts [x, y, x+y].join(' ')
  47. 115.

    class SomeClass extend Gem::Deprecate def no_more close end deprecate :no_more,

    :close, 2015, 5 def close # new logic here end end
  48. 117.

    class SomeClass deprecate scope: :class, version: 2.1 def ala #

    something truly deep end def bala # something extremely profound end end
  49. 119.
  50. 125.
  51. 128.
  52. 138.

    class SomeClass =begin This is a top comment. Or is

    it? =end def some_method end end
  53. 139.

    class SomeClass =begin This is a top comment. Or is

    it? =end def some_method end end
  54. 142.
  55. 144.
  56. 150.

    collect => map inject => reduce detect => find select

    => find_all sprintf => format length => size raise => fail
  57. 154.
  58. 159.
  59. 161.
  60. 164.
  61. 173.
  62. 174.
  63. 176.
  64. 186.

    pry(main)> A = 5 => 5 pry(main)> A = 6

    (pry):39: warning: already initialized constant A (pry):38: warning: previous definition of A was here => 6 pry(main)> Class = 3 (pry):40: warning: already initialized constant Class => 3 pry(main)> Class => 3
  65. 187.
  66. 189.

    class Parent @@class_var = 'parent' def self.print_class_var puts @@class_var end

    end class Child < Parent @@class_var = 'child' end Parent.print_class_var # => will print "child"
  67. 194.
  68. 195.

    [1] pry(main)> defined? 10 => "expression" [2] pry(main)> defined? Test

    => nil [3] pry(main)> defined? TrueClass => "constant"
  69. 196.
  70. 199.
  71. 206.

    $:

  72. 207.
  73. 208.

    $;

  74. 210.

    $*

  75. 211.
  76. 215.
  77. 222.

    The Kill List • Net::* • DRb • REXML •

    RSS • Rinda • WEBrick • XML
  78. 224.
  79. 225.
  80. 226.
  81. 227.
  82. 234.
  83. 237.
  84. 240.
  85. 241.
  86. 242.
  87. 243.
  88. 244.
  89. 245.
  90. 246.
  91. 248.
  92. 256.