Ruby 3.1

  • Ruby now has “punning.”

    > Values in Hash literals and keyword arguments can be omitted. [Feature #14579]

    > {x:, y:} is a syntax sugar of {x: x, y: y}.

    > foo(x:, y:) is a syntax sugar of foo(x: x, y: y).

    This is going to be controversial and take some getting used to, but I think eventually everyone will love it. It’s not an easy syntax to learn - I remember when this came to JS it took a while to get my head around all the different ways this shorthand was used in the wild.

    It’s hard to come up with new syntax that can peacefully coexist with the established language. I think in hindsight it would have been helpful for Ruby if it had done something like square braces instead of brackets for hash literals, or not allowed brackets for blocks. The most ambiguous syntax all involves hash literals vs blocks… this adds to that cognitive load.

    But typing out a long hash literal just to capture a bunch of local variables or methods is so common, and the duplication is quite annoying, so on the whole I’m glad this was added and am sure I’ll use it a lot :)

  • "The following default gems are now bundled gems." Great to see slow removal (or carve out) of rarely used stdlib stuff.

    Ruby would benefit from a trimmed down stdlib, where effort could be spent keeping a smaller footprint stdlib more polished than it is today. Turning them into opt-in gems is a good first step.

    A few examples:

    - `rss` to parse RSS documents/streams

    - `win32ole` for Microsoft Windows OLE Automation

    - `dbm` for DBM databases

    - `abbrev` for finding the shortest unique abbreviation amongst many strings

    This page has more details: https://stdgems.org/

  • Love Ruby. Personal language of choice. People keep predicting its death, but it just keeps getting better and better!

  • Related: I believe there is ongoing work (not in 3.1) to modify the CRuby implementation to use shapes/hidden classes. This has significant potential to speed things up. More info: https://chrisseaton.com/truffleruby/rubykaigi21/

  • Thank you Matz and team! Lot of awesome stuff in this release.

  • No news about Ractors! The new concurrency facilities that Ruby 3.0 introduced. Anyone has an insight if there was any further development on that front?

  • I thought TypeProf is really interesting but doesn't seems to get much attention.

    I am also wondering if anyone is using RBS in production. Apart from big shops like Stripe / Shopify.

  • What a coincidence, I just started learning a bit of Ruby with an interpreter I'm writing a couple of nights ago.

    I will take the opportunity to ask; does anyone have a good introduction to creating Ruby (not Rails) projects? I'm a bit confused between rake, bundle, testing frameworks, how to debug a program or structure a project and I can't seem to find a good up to date resource on that.

  • I really can't wait to use the IRB Autocomplete feature. Aside from the obvious advantage of tabbing (convenience, fewer typos etc), it's a subtle way to improve discoverability of available methods. Very cool.

  • PSA: Ruby 3.1 isn’t compatible with Rails 7.0.0. There’s a patch in the world that’s coming soon.

  • How good is `debug.gem`? I'd be excited to try it if I was still using ruby ...

    I'm not using ruby anymore but the debugger experience I had from vscode via the rdebug-ide library a few years ago was _mostly pretty_ nice aside from very performance limitations ... a massive performance improvement on that front must feel great!

  • What is best way to master Ruby for generalist engineer? I know C++ and Python, JS, Typescript well enough.

    Python was easiest, since it took couple of days to master fundamentals and I was writing good code in no time.

    Also anyone working on Typescript equivalent for ruby?

  • Is yjit support available now for more cpu architectures? Super excited to try this out

  • did you guys know any updates about the static typing ruby? I wish it could be more like typescript

  • has this released on stable with the asdf tool? can't wait to try this out!

  • Sigh... why couldn't they drop the : like js?

      {x:, y:} is a syntax sugar of {x: x, y: y}.

  • undefined