Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Ruby's Creed (RubyDay 2023, Verona)

Ruby's Creed (RubyDay 2023, Verona)

Slide deck from my RubyDay 2023 presentation.

Bozhidar Batsov

June 16, 2023
Tweet

More Decks by Bozhidar Batsov

Other Decks in Programming

Transcript

  1. –Matz “I think a programming language should have a philosophy

    of helping our thinking, and so Ruby’s focus is on productivity and the joy of programming. If you feel comfortable with Ruby’s philosophy, that means Ruby is your language.”
  2. 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
  3. noun 1. a short sentence or phrase chosen as encapsulating

    the beliefs or ideals of an individual, family, or institution.
  4. Beautiful is better than ugly. Explicit is better than implicit.

    Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. — The Zen of Python
  5. A dynamic, open source programming language with a focus on

    simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. — ruby-lang.org
  6. collect => map/filter inject => reduce detect => find select

    => find_all sprintf => format length => size raise => fail
  7. Plenty of “controversial” features • Flip- fl ops • For

    loops • Global variables • Magic arguments ($_) • Re fi nements • Optional static typing
  8. Things I value • Simple and consistent syntax • Functional

    style of programming • Useful standard library • Backwards compatibility • Development tooling • Ecosystem (3rd party libraries, frameworks, etc) • Community
  9. (Modern) Ruby Features I dislike • Ruby 1.9 hash literals

    • Re fi nements • %i literals • Rational/Complex literals (2/3r, 2+1i) • Endless ranges (1..) • Safe navigation operator (&.) • Static typing
  10. Scores • 5 - a change that makes me very

    happy • 4 - a change that makes me happy • 3 - I’m ambivalent towards the change • 2 - a change that makes me unhappy • 1 - a change that makes me very unhappy
  11. Ruby 2.7 • Pattern matching is added as an experimental

    feature (4/5) • Real keyword parameters (3/5) • Nice improvement, that creates a lot of maintenance overhead • Numbered block parameters - e.g. _1, _2 (2/5) • [10, 20, 30].map { _1**2 } • Beginless range - e.g. ..20 (2/5) • users.map(&:age).any?(...18)
  12. # traditional Ruby [1, 2, 3].each { |i| puts i

    } (1..10).map { |i| i * 3 } (1..9).each_slice(3).map { |x, y, z| x + y + z } # Ruby 2.7 [1, 2, 3].each { puts @1 } (1..10).map { @1 * 3 } (1..9).each_slice(3).map { @1 + @2 + @3 }
  13. h = Hash.new { |hash, key| hash[key] = "Go Fish:

    #{key}" } # vs h = Hash.new { @1[@2] = "Go Fish: #{@2}" }
  14. Ruby 3.0 • Full separation of keyword arguments (3/5) •

    Moar maintenance pain for the sake of long-term gain • Ractors (3/5) • Non-blocking IO with Fibers (3/5) • Pattern matching is no longer experimental (4/5) • Endless methods (2/5) • def foo = bar
  15. Ruby 3.1 • Hash literal value omission (2/5) • x,

    y = 1, 2; h = {x:, y:} • Anonymous block argument (2/5) • def filter(data, &)= data.select(&) • Pattern matching improvements (4/5)
  16. Ruby 3.2 • Anonymous method argument (**) forwarding (4/5) •

    Better inspectable re fi nements (3/5) • Data class (4/5) • Set is now a built-in class (5/5) • Per- fi ber storage (3/5) • More pattern matching improvements (3/5)