Ruby.next

 Ruby.next

Slide-deck from my presentation at Grill.rb 2018 in Wroclaw, Poland.

1be785d1d788b82929e55fc83a9f0aaa?s=128

Bozhidar Batsov

August 12, 2018
Tweet

Transcript

  1. 1.
  2. 2.
  3. 11.
  4. 12.
  5. 13.
  6. 14.
  7. 15.
  8. 17.
  9. 18.
  10. 19.
  11. 20.
  12. 22.
  13. 23.
  14. 24.
  15. 25.
  16. 26.
  17. 27.
  18. 28.
  19. 36.
  20. 41.
  21. 45.
  22. 46.

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

    encoding •Refinements (experimental feature)
  23. 47.
  24. 49.
  25. 50.
  26. 51.
  27. 53.
  28. 55.
  29. 56.

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

    blocks •refinements take place in string interpolations

  30. 57.
  31. 60.
  32. 62.
  33. 63.

    •endless ranges (1..) •begin/else/end is now a syntax error (it

    used to be a warning) •some core lib methods now take optional keyword arguments (e.g. system(), Integer(), Float()) •a first stab at MJIT •built-in AST module
  34. 65.
  35. 69.
  36. 73.

    pry(main)> Ripper.sexp('alias :some :test') => [:program, [[:alias, [:symbol_literal, [:symbol, [:@ident,

    "some", [1, 7]]]], [:symbol_literal, [:symbol, [:@ident, "test", [1, 13]]]]]]]
  37. 74.

    each(:method_add_arg, sexp) do |s| next if s[1][0] != :call receiver

    = s[1][1][1] method_name = s[1][3][1] if receiver && receiver[1] == 'Array' && method_name == 'new' && s[2] == [:arg_paren, nil] offences.delete(Offence.new(:convention, receiver[2].lineno, ERROR_MESSAGE)) add_offence(:convention, receiver[2].lineno, ERROR_MESSAGE) end end
  38. 81.
  39. 95.

    –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…”
  40. 96.
  41. 97.
  42. 100.

    PHP

  43. 102.
  44. 103.

    The Future of Java and the JDK Who’s in charge?

    https://www.youtube.com/watch?v=HpbchS5kmio
  45. 122.

    class Foo # <b>DEPRECATED:</b> Please use <tt>useful</tt> instead. def useless

    warn "[DEPRECATION] `useless` is deprecated. Please use `useful` instead." useful end def useful # ... end end
  46. 123.

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

    :close, 2015, 5 def close # new logic here end end
  47. 125.
  48. 137.
  49. 139.

    class Struct def deconstruct; [self] + values; end end A

    = Struct.new(:a, :b) case A[0, 1] in (A, 1, 1) :not_match in A(x, 1) # Syntactic sugar of above p x #=> 0 end
  50. 140.

    class Struct def deconstruct; [self] + values; end end A

    = Struct.new(:a, :b) match A[0, 1] in (A, 1, 1) :not_match in A(x, 1) # Syntactic sugar of above p x #=> 0 end
  51. 142.
  52. 144.
  53. 151.
  54. 154.
  55. 160.

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

    it? =end def some_method end end
  56. 161.

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

    it? =end def some_method end end
  57. 164.
  58. 166.
  59. 175.
  60. 183.

    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
  61. 184.
  62. 186.

    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"
  63. 191.
  64. 192.

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

    => nil [3] pry(main)> defined? TrueClass => "constant"
  65. 193.
  66. 197.
  67. 199.

    $:

  68. 200.
  69. 201.

    $;

  70. 203.

    $*

  71. 204.
  72. 209.
  73. 211.
  74. 219.