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

The Road to Ruby Mastery (RailsClub Moscow 2017)

The Road to Ruby Mastery (RailsClub Moscow 2017)

Slide-deck from my presentation at RailsClub Moscow 2017.

Bozhidar Batsov

September 23, 2017
Tweet

More Decks by Bozhidar Batsov

Other Decks in Programming

Transcript

  1. Божидар

    View full-size slide

  2. Большое спасибо!

    View full-size slide

  3. Большое
    спасибо!

    View full-size slide

  4. Sofia, Bulgaria

    View full-size slide

  5. Sofia, Bulgaria

    View full-size slide

  6. I’m an Emacs
    fanatic

    View full-size slide

  7. They call me Master…

    View full-size slide

  8. … and I’m a Rubyist

    View full-size slide

  9. I must be
    The Master Rubyist!

    View full-size slide

  10. This guy is so
    deep and profound!

    View full-size slide

  11. The Road to
    Ruby Mastery
    by Bozhidar Batsov

    View full-size slide

  12. having or showing very great
    skill or proficiency

    View full-size slide

  13. a person new to and
    inexperienced in a job or
    situation

    View full-size slide

  14. a worker, performer, or athlete
    who is experienced and good but
    not excellent

    View full-size slide

  15. Dreyfus Model of Skill
    Acquisition

    View full-size slide

  16. Novice
    Advanced
    Beginner
    Competent
    Proficient
    Expert

    View full-size slide

  17. The Road to Mastery

    View full-size slide

  18. http://norvig.com/21-
    days.html
    Teach Yourself
    Programming in Ten Years
    Peter Norvig

    View full-size slide

  19. Apprenticeship

    View full-size slide

  20. Novice
    Journeyman
    Master
    Apprenticeship
    Apprenticeship

    View full-size slide

  21. learning from others

    View full-size slide

  22. Computer Science Fundamentals

    View full-size slide

  23. Object-oriented programming

    View full-size slide

  24. Ruby is a purely object-
    oriented language

    View full-size slide

  25. Know Thy Language!

    View full-size slide

  26. Crazy People

    View full-size slide

  27. Ruby is a VERY COMPLEX
    language!

    View full-size slide

  28. class instance variable

    View full-size slide

  29. module_function
    vs
    extend self

    View full-size slide

  30. refinements

    View full-size slide

  31. super vs super()

    View full-size slide

  32. ==
    ===
    equal?
    eql?

    View full-size slide

  33. Grokking the language

    View full-size slide

  34. Understanding and appreciating
    its
    philosophy

    View full-size slide

  35. Coming to grips with reality

    View full-size slide

  36. (no language is perfect)

    View full-size slide

  37. (not even Clojure)

    View full-size slide

  38. (some languages really suck)

    View full-size slide

  39. Master the idioms

    View full-size slide

  40. for i in 1..3
    puts "Hello, Moscow!”
    end

    View full-size slide

  41. 3.times do
    puts "Hello, Moscow!”
    end

    View full-size slide

  42. if some_condition then
    # body omitted
    end

    View full-size slide

  43. def some_method
    # ...
    return result
    end

    View full-size slide

  44. Read some (good) code

    View full-size slide

  45. some == A LOT

    View full-size slide

  46. Obtain a notion of style

    View full-size slide

  47. Ruby Style Guide

    View full-size slide

  48. Tackle problems with style

    View full-size slide

  49. puts debugging sucks

    View full-size slide

  50. bla bla bla
    puts ‘********’
    puts x
    puts ‘********’

    View full-size slide

  51. pro “puts” debugging
    techniques

    View full-size slide

  52. object = Object.new
    puts
    object.method(:blank?).source_location
    # => ["/gems/activesupport-5.0.0.beta1/
    lib/active_support/core_ext/object/
    blank.rb", 14]

    View full-size slide

  53. class Bar
    def foo
    puts "====================="
    puts caller
    end
    end

    View full-size slide

  54. def foo
    puts method(:foo).super_method.source_location
    super
    end

    View full-size slide

  55. def parse(input, skip_code_comments: false, ignore_whitespace: true)
    # do stuff
    end
    method(:parse).parameters
    #=> [[:req, :input], [:key, :skip_code_comments], [:key, :ignore_whitespace]]

    View full-size slide

  56. config.thing = { "foo" => "bar" }
    config.thing.freeze = { "foo" => "bar" }
    config.thing.delete("foo")
    # active_support/concurrency/share_lock.rb:151:in
    `delete': can't modify frozen Hash (RuntimeError)
    # from active_support/concurrency/share_lock.rb:151:in
    `yield_shares'
    # from active_support/concurrency/share_lock.rb:79:in
    `block in stop_exclusive'

    View full-size slide

  57. Ruby Debugging Magic Cheat
    Sheet
    http://www.schneems.com/2016/01/25/ruby-debugging-magic-cheat-
    sheet.html

    View full-size slide

  58. I am a puts debugger
    https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer.html

    View full-size slide

  59. I am not a puts debugger!

    View full-size slide

  60. byebug
    https://github.com/deivid-rodriguez/byebug

    View full-size slide

  61. pry-byebug
    https://github.com/deivid-rodriguez/pry-byebug

    View full-size slide

  62. Profiling stuff

    View full-size slide

  63. ruby-prof
    https://github.com/ruby-prof/ruby-prof

    View full-size slide

  64. memory_profiler
    https://github.com/SamSaffron/memory_profiler

    View full-size slide

  65. Beyond Rails

    View full-size slide

  66. System administration

    View full-size slide

  67. Alternative web frameworks

    View full-size slide

  68. Keep in sync

    View full-size slide

  69. Always be exploring!

    View full-size slide

  70. Erlang/Elixir

    View full-size slide

  71. Ideas from other programming
    languages make us better
    programmers

    View full-size slide

  72. One more thing…

    View full-size slide

  73. Ruby is simply not a good fit
    for every possible problem

    View full-size slide

  74. ФЕЛИНА

    View full-size slide

  75. Епилог
    twitter: @bbatsov
    github: @bbatsov
    http//batsov.com
    http://emacsredux.com
    RailsClub
    Moscow,
    Russia
    23.09.2017

    View full-size slide