---
title: "A first glimpse of Ruby 3.4"
publication: "Ruby Weekly"
issue: 703
published_at: "2024-05-16"
canonical_url: "https://rubyweekly.com/issues/703"
---

Plus we share three quick Ruby tips. |        

#​703 — May 16, 2024 

[Read on the Web](https://rubyweekly.com/issues/703)  

Together with [![pgAnalyze\](https://res.cloudinary.com/cpress/image/upload/c_fill,g_auto,e_trim,w_350,h_100/e_make_transparent/co_white,e_outline:7/lhwcvgc1asd4fzaahty4.png)](https://pganalyze.com/ebooks/advanced-database-programming-rails-postgres?utm_source=RubyWeeklyPrimary05162024)   

Ruby Weekly 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60,q_auto/dmc0ex2zonajgfkzihri.jpg)](https://www.ruby-lang.org/en/news/2024/05/16/ruby-3-4-0-preview1-released/)  

[Ruby 3.4 Preview 1 Released](https://www.ruby-lang.org/en/news/2024/05/16/ruby-3-4-0-preview1-released/) — I love it when the first preview of a new Ruby version drops. It makes it easier to get playing with the new features and reminds me of Christmas.. 😂 It’s a _preview_ so don’t throw it into prod (unless you’re Shopify) but it’s a good one to test against with a key change to how string literals now behave _(I anticipate this could break a few dependencies..)_ 

Yui Naruse   [![\](https://copm.s3.amazonaws.com/abbeddf0.png)](https://pganalyze.com/ebooks/advanced-database-programming-rails-postgres?utm_source=RubyWeeklyPrimary05162024) 

[Free eBook: Advanced Database Programming with Rails and Postgres](https://pganalyze.com/ebooks/advanced-database-programming-rails-postgres?utm_source=RubyWeeklyPrimary05162024) — Learn about subqueries, materialized views, and custom data types in Postgres and Rails. We walk through realistic real-life examples, translating first into SQL, and then into Rails code. Every example comes with source code so you can follow along. 

pganalyze sponsor   

- 🔒 A DoS vulnerability [has been found in REXML,](https://www.ruby-lang.org/en/news/2024/05/16/dos-rexml-cve-2024-35176/) so you're encouraged to upgrade it ASAP.
- ▶️ Rails core member [Eileen Uchitele's Tropical.rb keynote](https://www.youtube.com/watch?v=ow56D90FYpg) is now available to watch – she digs into some of the higher level ideas about what makes Rails tick (conventions, components, interfaces, etc.)
- 🇧🇷 For that matter, [17 other talks from Tropical.rb](https://www.youtube.com/playlist?list=PLvOWTr3oa1dVFAtodH31zjwdue2QH7wdd) are now available to watch too.
- 🇺🇸 Near NYC? Obie Fernandez _(The Rails Way)_ is [speaking at NYC.rb next month](https://www.meetup.com/nyc-rb/events/300339701/) about Ruby's role in the growing world of AI, something he has [recently written about, too.](https://obie.medium.com/the-future-of-ruby-and-rails-in-the-age-of-ai-8f1acea31bc2)
- ♻️ The Ruby core team is working on [the idea of having garbage collector routines be easier to replace or enhance.](https://bugs.ruby-lang.org/issues/20351)
- 🚂 [Rails 8 adds Kamal by default.](https://blog.saeloun.com/2024/05/15/rails-8-adds-kamal-by-default/)  

📄 Articles, Tutorials & Videos 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60,q_auto/okyrvjzfqngnwp0bctuc.jpg)](https://github.blog/changelog/2024-05-13-dependabot-core-is-now-open-source-with-an-mit-license/)  

[GitHub's dependabot-core is Now Open Source](https://github.blog/changelog/2024-05-13-dependabot-core-is-now-open-source-with-an-mit-license/) — [Dependabot](https://docs.github.com/en/code-security/dependabot) is a tool GitHub used to monitor the dependencies of projects hosted there (and create automated PRs to update them). It’s always interesting to see them open source a key part of their infrastructure – especially when it’s mostly written in Ruby! 

GitHub   

[Why You Should Nest Modules in Ruby](https://thoughtbot.com/blog/why-you-should-nest-modules-in-ruby) — Justin demonstrates a couple of gotchas you can avoid by nesting modules, if at the price of a little added verbosity. 

Justin Toniazzo   

[Developer’s Guide to Heroku Dynos](https://judoscale.com/guides/how-many-dynos?ref=RubyWeekly) — Which dynos should you use, and how many? (TLDR: Don’t use Perf-M!). 

Judoscale sponsor   

[A RailsConf 2024 Recap](https://kevinjmurphy.com/posts/railsconf-2024-recap/) — Kevin had a great time at RailsConf last week and he covers some of what he saw there. Separately, he’s put together [four things to take away from RailsConf 2024.](https://kevinjmurphy.com/posts/4-things-railsconf-2024/) 

Kevin Murphy   

📄 [A Class Pattern to Work with API Requests with an Async Approach](https://medium.com/@zozulyak.nick/ruby-class-pattern-to-work-with-api-requests-with-built-in-async-approach-bf0713a7dc96) Mykola Zozuliak 

📄 [How We Used a Custom Enumerator to Fix a Production Problem](https://thoughtbot.com/blog/how-we-used-a-custom-enumerator-to-fix-a-production-problem) Thiago Araújo Silva 

📄 [Hidden Feature of Turbo: Stream Actions Inside Regular HTML](https://radanskoric.com/articles/stream-actions-inside-regular-html) Radan Skorić 

📄 [A Less Painful Way to Work with Shopify's GraphQL API in Ruby](https://kirillplatonov.com/posts/shopify-graphql/) Kirill Platonov 

📄 [Creating a Progress Bar in a Hanami App with HTMX](https://2n.pl/blog/hanami-progress-bar-with-htmx) Krzysztof Kamil 

📄 [Creating Forms in Rails with Simple Form](https://blog.appsignal.com/2024/05/15/creating-forms-in-ruby-on-rails-with-simple-form.html) Thomas Riboulet  

🛠 Code & Tools 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60,q_auto/iveqy249jz6yfvizlqjs.jpg)](https://github.com/jhawthorn/vernier)  

[Vernier 1.0: A Next Gen CRuby 3.2+ Profiler (And How to Use It!)](https://github.com/jhawthorn/vernier) — A sampling profiler that can track multiple threads, GVL activity, GC pauses, idle time, etc. We linked to it not long ago, but it’s reached v1.0 and there’s now [▶️ a fantastic talk by its creator](https://www.youtube.com/watch?v=0LMjx3xkjlY) on what it does and how to use it. 

John Hawthorn   

[The Git Gem 2.0: A `git` Wrapper for Use from Ruby](https://github.com/ruby-git/ruby-git) — Takes the simple approach for wrapping calls to the usual `git` binary. 

Scott Chacon et al.   

[🌳 Need to Upgrade to Ruby 3.3 on a Budget? Try Bonsai by FastRuby.io](https://www.fastruby.io/monthly-ruby-maintenance?utm_source=cooperpress&utm_medium=paidplacement&utm_campaign=stuck-ruby-3-3-rw-apr-2024&utm_term=stop-postponing) — Stuck on Ruby 2.7? Stop postponing your upgrade, ship it with our fixed-cost monthly maintenance service. 🚀 

Bonsai By FastRuby.io sponsor   

[Strong Migrations: Catch Unsafe Migrations in Development](https://github.com/ankane/strong_migrations) — Detects potentially dangerous operations and prevents them running by default. Supports PostgreSQL, MySQL, and MariaDB. 

Andrew Kane   

[Promptcraft: Try New System Prompts on Your AI Conversations](https://github.com/drnic/promptcraft) — A Ruby-powered CLI tool for replaying a user/AI-agent conversation over and over but with a new system prompt each time so you can hone things until you get the end results you want. 

Dr Nic Williams   

- [Pygments.rb 3.0](https://github.com/pygments/pygments.rb) – Ruby wrapper for the Pygments syntax highlighter.
- [Humanize 3.1](https://github.com/radar/humanize) – Converts your numbers to text in 13 languages.
- [Business Class 1.7](https://nts.strzibny.name/businessclass-1.7/) – The commercial SaaS starter kit for Rails takes steps to get ready for Rails 8.
- [Cyperful 0.2](https://github.com/stepful/cyperful) – Interactive system testing UI for Capybara. Now with added RSpec support.
- [GraphqlDevise 1.5](https://github.com/graphql-devise/graphql_devise) – GraphQL interface on top of`devise_token_auth`.
- [Reline 0.5.7](https://github.com/ruby/reline/releases/tag/v0.5.7) – The better, but compatible, `readline`library.
- [Meilisearch Rails 0.13](https://github.com/meilisearch/meilisearch-rails) – Meilisearch integration for Rails.
- [rspec-sidekiq 5.0](https://github.com/wspurgin/rspec-sidekiq/releases/tag/v5.0.0) – Simple testing of Sidekiq jobs.  

💡 Quick tips..  

**Tip 1:** On Twitter, [Dr Nic Williams shared a tip](https://twitter.com/drnic/status/1790524779746992168) of how to make systems like ChatGPT return better code by being more specific in your system prompts. For example: 

> _When giving Ruby code snippets, use modern Ruby 3.3 syntax, especially for hashes and method signatures with named parameters._ 

I [followed up with a half joke](https://twitter.com/cooperx86/status/1790763657040736590) based on my own experiences where LLMs ignore other modern Ruby constructs and idioms, which leads us to... 

**Tip 2:** If you have an array, say, of items and you want to create a hash with the keys being the unique values and the values being the _number of times_ those values appear in the array, you might do something like this: 

```
array = [1,2,2,3,4,4,4]
array.each_with_object(Hash.new(0)) { |i, h|
  h[i] += 1
}
``` 

Or, perhaps: 

```
hash = Hash.new(0)
array.each { |i| hash[i] += 1 }
``` 

Since Ruby 2.7, however, you can use `array.tally`! It's made my _Advent of Code_ solutions far less verbose.. ;-) 

**Tip 3:** A simpler tip lies at the heart of tip two. **Skim Ruby's docs from time to time!** Whenever I check out [the docs for `Enumerable`](https://ruby-doc.org/core-3.0.2/Enumerable.html), I'm reminded of something I fail to remember in my day to day work. Have a browse and you might find your own useful shortcuts to share with your team.         

Curated by [Peter Cooper](https://twitter.com/cooperx86) and [Glenn Goodrich](https://twitter.com/ruprict).
Published by [Cooperpress](https://cooperpress.com/). 

[Change your email](https://rubyweekly.com/edit_subscription/*|UID|*) or [Stop getting this newsletter.](https://rubyweekly.com/leave/*|UID|*) 

© Cooper Press Ltd · Fairfield Enterprise Centre, Louth, LN11 0LS, United Kingdom 

Other weekly newsletters we publish include [Postgres Weekly](https://postgresweekly.com/), [React Status](https://react.statuscode.com/), [Frontend Focus](https://frontendfoc.us/), and [JavaScript Weekly](https://javascriptweekly.com/).
