Short Ruby News - Edition #91
Ruby 3.4 preview launched, Rails 8 development has started and a deep discussion about namespaces in Ruby. Plus a lot more inside.
You can jump directly to a section:
๐ย All about Code and Ruby: ๐ป Code, ๐Code Design,๐กAround, โค๏ธ Why Choose Ruby
๐งฐย Gems, Libraries, and Updates: ๐ New, ๐งฐ Updates and ๐ Keep an eye on
๐ค Related (but not Ruby-specific)
More content: ๐ ๐ ๐ง ๐ฅ โ๐พ (articles, podcasts, videos, newsletters)
๐ Launches
๐ย Greg Navisย launchedย whoishiring.jobs โ find you dream tech startup job
๐ Vitaly Slobodinย launchedย Ruby LSP - IntelliJ IDEs Plugin | Marketplace
๐ย Stores Techย launched a game for RubyKaigi participants that you can play too in the browser Ruby "enbugging" quiz
๐
Events
๐ Nairuby has extended their Call for Proposals to 31st of May.
๐ BalticRubyย shared they are looking for sponsors:
๐ All about Code and Ruby
๐ ย Yui Naruseย announced a new version ofย Ruby 3.4.0 preview1 Released
๐ย Xavier Noriaย sharedย about performance improvement in Ruby 3.4 by rewriting Array.each in Ruby:
Here is the current implementation of Ruby master that was initially proposed in Feature 20182 and updated in this PR:
Takashi Kokubun shared in the PR also some benchmarks for this implementation:
๐ Jose Fariasย sharedย a podcast where Jason Fried announced a new ONCE product that will be free, but we donโt know yet what product will be โ A Matter of Ambition: Part 2 โ REWORK podcast
๐ย David Heinemeier Hanssonย announced that the branch is created for Rails 7.2 andย Add Kamal by default to Rails 8
You should also check this commit by Rafael Franca called โDevelopment of Rails 8.0 starts nowโ and if you want to see the progress follow the Rails 8 Milestone
๐ป Code Samples
๐ย Yusuke Endohย sharedย a gist t.md
๐ย Ruby On Railsย sharedย a tip about allowing templates to set explicit locals:
Here is a good guide about strict locals in Rails partials written by Joe Masilotti and the official Rails documentation.
๐ Soutaro Matsumoto shares how you can define a method with keyword arguments using keyword names.
๐ Simon George has an open challenge for you. If you know a way, do let him know.
He also added:
๐ย Hiroya Fujinamiย sharedย how they implemented a new syntax for Ruby using Prism:
๐ย Josef Strzibnyย sharedย about referencing a specific foreign_key table in Rails migrations:
๐ย Chris Oliverย sharedย a tip about using min, max and clamp instead of conditionals:
๐ Mika Henriksson shares his solution on the issue where ActiveStorage allows you to load all assets from your production bucket in other environments, but not preventing you from actually deleting those files.
๐ Chris Oliver shares on how to convert Strings to Symbols to make dynamic symbols in Ruby.
๐ย Xavier Noriaย sharedย about Ruby classes:
๐ Michael Koper shares a tip he learned from DHHโs Campfire code
๐ Bhumi shared a rails tip for rails routes.
๐Bozhidar Batsovย asked on Mastodon and Twitter:
Here are some of the replies:
๐ย Lucian Ghindaย sharedย a thred about configuring code snippets in RubyMine and VScode for debug gem:
๐ Seth A. Roby shared a gist containing a class that will use your existing FactoryBot factories to rewrite the data already in the db, keeping the associations and structure but replacing the content.
๐ Thinking about Code Design
๐ Richard Schneeman published on Reddit a post about how Ruby GC works:
He shared a list of resources to read I will put here the entire recommendation because it is very very good with his own words about each resource:
Why does my App's Memory Use Grow Over Time? - Start here, a good high level overview of what causes a system's memory to grow that will help you develop an understanding of how Ruby allocates and uses memory at the application level.
Complete Guide to Rails Performance (Book) - This book is by Nate Berkopec and is excellent. I recommend it to someone at least once a week.
How Ruby uses memory - This is a lower level look at precisely what "retained" and "allocated" memory means. It uses small scripts to demonstrate Ruby memory behavior. It also explains why the "total max" memory of our system rarely goes down.
How Ruby uses memory (Video) - If you're new to the concepts of object allocation this might be an excellent place to start (you can skip the first story in the video, the rest are about memory). Memory stuff starts at 13 minutes
Jumping off the Ruby Memory Cliff - Sometimes you might see a 'cliff' in your memory metrics or a saw-tooth pattern. This article explores why that behavior exists and what it means.
Ruby Memory Use (Heroku Devcenter article I maintain) - This article focuses on alleviating the symptoms of high memory use.
Debugging a memory leak on Heroku - TLDR; It's probably not a leak. Still worth reading to see how you can come to the same conclusions yourself. Content is valid for other environments than Heroku. Lots of examples of using the tool `derailed_benchmarks` (that I wrote).
The Life-Changing Magic of Tidying Active Record Allocations (Blog + Video) - This post shows how I used tools to track down and eliminate memory allocations in real life. All of the examples are from patches I submitted to Rails, but the process works the same for finding allocations caused by your application logic.
N+1 Queries or Memory Problems: Why not Solve Both? - Goes through a tricky real world scenario from 2017 where an N+1 query was killing performance, but using "eager loading" used too much memory. I had to re-work the flow of the code to extract the data that was needed while avoiding extra memory allocations.
๐ย Chris Salzbergย sharedย a thread about the presentation from RubyKaigi about Namespace, What and Why
Some replies to this thread are interesting to read. Here are some replies/reactions about this, but before making your mind up, you should read the discussion on the Ruby issue tracker (it is long and discusses various aspects and edge cases).
You can play with the namespace in theย Ruby Playground
๐ย Matt Swansonย sharedย rails stats from their app:
๐ Jason Charnes is contemplating a significant change in their approach to building web applications with Rails.
๐ Nate Berkopec shares insight about the impact of parallel versus serial requests on user experience in web applications.
๐ย Kevin Vanzandbergheย sharedย performance gains by enabling YJIT
๐ย Andrei Bondarevย sharedย about how they helped a company switch from micro-services to Rails monolith:
Read the entire thread as it goes into detail about how this happened.
๐ Mohammad A. Aliย sharedย about how Litestack brings the efficiency of SQLite to Ruby applications:
๐ย Nate Berkopecย sharedย about how many requests per server does a Rails app server per vCPU:
Nate added later a bigger explanation about why that number seems low. Read the entire post, here is just a piece of it:
๐ก Around code (news, findings, books, and more - all about Ruby)
๐ก Emmanuel Hayford shares how strings will be considered frozen by default from Ruby 3.4
๐ก Prem Sichanugrist quotes on how Ruby has become more contributor friendly
๐ก Mohammad A. Ali shares about his comparison of two solutions for using SQLite as Rails cache store
Solution A:
Solution B:
Check out his blog on Comparing SQLite based Rails cache stores:
๐ก Josh Pigford wishes for Rails to have a quick auth generator
Stephen Margheim shared an example of minimal authentication requirements for Rails app as a reply
Josh Brown shared authentication-zero gem which could serve the same purpose.
Whatโs even better is that this might be coming along with Rails 8!
๐ก Keshav Biswa finds out that NASA uses Rails!
๐ก John Pollardย asked about the decision making process for Rails:
Here is an answer from Eileen M. Uchitelle about the decisions taken in the Rails Core:
๐กย Maxime Chevalierย sharedย about performance as a feature:
๐ย Lucian Ghindaย asked about a Ruby gem that will allow to select a snapshot of production DB:
Here are the recommended gems or scripts or but there were multiple ideas about how to do this in the Twitter replies or Mastodon replies:
evil-seed - A Gem for creating partial anonymized dumps of your database using your app model relations
forceps - Copy active record models from remote databases
scrubbing section from High performance PostgreSQL for Rails book
rails_anonymizer - Anonymize your DB with Rails
pgsync - Sync data from one Postgres database to another
postgresql_anonymizer - PostgreSQL extension
db_subsetter - Extract a subset of a relational database for use in development or testing
wipe_out - Library for removing and clearing data in Rails ActiveRecord models.
active_record_anonymizer - A ruby gem to anonymize your ActiveRecord attributes with ease
โค๏ธ Why Choose Ruby
โค๏ธ Josef Strzibny says why there is nothing like too much Ruby.
โค๏ธ John Pollard says how RoR developer experience is often overlooked upon.
โค๏ธ Felipe Vogel shared their experience from RailsConf 2024 - The Ruby community is for everyone
โค๏ธ Vzb is having fun building again on full-stack RubyOnRails
โค๏ธย Lucian Ghindaย asked why people love Ruby programming language:
There are a lot of answers on both Twitter and Mastodon that I cannot pick one to add here and adding all of them will make this huge newsletter almost infinite.
๐งฐ Gems, Libraries, Tools and Updates
๐ New Gems and Repos
๐ย Dr Nic Williamsย announced a new gem promptcraft: Try new system prompts on your AI conversations. Over and over until you're happy.
๐ย Harrison Broadbentย announced a new project Ruby-middleman-tailwind-starter-blog: A Middleman blog template configured with TailwindCSS, markdown parsing, code highlighting, a sitemap.xml and more
๐ย Svyatoslav Kryukovย announced a new gem turbo-mount: Use React, Vue, Svelte, and other components with Hotwire
๐ย Brooke Kuhlmann published a new gem called irb-kit
๐งฐ Updates
๐งฐย Ruby On Railsย announced a new version ofย Rails Versions 7.0.8.2, and 7.1.3.3 have been released!
๐งฐย Xavier Noriaย announced a new version ofย Zeitwerk:
๐งฐย Vinicius Stockย announced a new version ofย Support instance variables for definition, hover, completion and workspace symbols by vinistock ยท Pull Request #2042 ยท Shopify/ruby-lsp
๐งฐย Stimulus Reflexย announced a new version ofย StimulusReflex v3.5.0
๐งฐย Koichi Itoย announced a new version ofย Release RuboCop Rails 2.25.0 ยท rubocop/rubocop-rails
๐งฐย Kasper Timm Hansenย announced a new version ofย Release v0.6.0 ยท kaspth/oaken
๐งฐ Garrett Dimon shares his experience on using Kasperโs active_record-associated_object gem to organize model logic.
๐งฐย Mari Imaizumiย announced a new version ofย reline:
๐ Keep an eye on
๐ Fabian shares about intuitive rails behavior.
๐ค Related (but not Ruby-specific)
๐ค Mika Henriksson tips on how to tweak your post-deploy while using Kamal post-deploy hooks with AppSignal.
๐คย Jason Swettย sharedย about tests being product specifications:
๐คย David Heinemeier Hanssonย sharedย about automated testing:
๐ค Josh Brown shares a gist for Template Renderer
๐คย Cosminย sharedย about the inert HTML attribute:
๐คย Caleb Porzioย sharedย that web browsers have a native dropdown (check caniuse before using it in your product)
๐คย Aditya Agarwalย sharedย about weekly 1:1s:
More content: ๐ ๐ ๐ง ๐ฅ โ๐พ
Marco Rothย published their slides aboutย ย The Hotwire Landscape After Turbo 8 @ Helvetic Ruby 2024, Zurich
Soutaro Matsumoto shared their slides from RubyKaigi 2024 - Embedding it into Ruby code
Chris Oliverย published their slides aboutย Crafting Rails Plugins
Manu Jย publishedย their slides about Look Ma, No Background Jobs - A peek into the Async future
Mari Imaizumiย publishedย their slides aboutย Exploring Reline: Enhancing Command Line Usability
Ivo Anjoย publishedย their slides aboutย RubyKaigi 2024 - Optimizing Ruby: Building an Always-On Production Profiler
Jeremy Evansย publishedย their slides aboutย Reducing Implicit Allocations During Method Calling
Yuta Saitoย publishedย their slides aboutย RubyGems on ruby.wasm
Yusuke Endohย publishedย their slides aboutย Good first issues of TypeProf
Koichi Itoย publishedย their slides aboutย RuboCop: LSP and Prism
Hasumi Hitoshiย publishedย their slides aboutย Unlock The Universal Parsers: A New PicoRuby Compiler
Benoit Dalozeย publishedย their slides aboutย From Interpreting C Extensions to Compiling Them
Soutaro Matsumotoย publishedย their slides aboutย Embedding it into Ruby code
Takashi Kokubunย publishedย their slides aboutย YJIT Makes Rails 1.7x faster / RubyKaigi 2024
Hiroya Fujinamiย publishedย their slides aboutย RubyKaigi 2024 - Make Your Own Regex Engine!
Yuichiro Kanekoย publishedย their slides aboutย RubyKaigi 2024 - The grand strategy of Ruby Parser (Day1)
Vladimir Dementyevย publishedย their slides aboutย ย Ruby Mixology 101: adding shots of PHP, Elixir, and more by Evil Martians
๐ Newsletters
๐ Ruby On Rails published a new edition about Start of Rails 8 development, 7.0.8.2 & 7.1.3.3 released, Kamal by default, and lots more!
๐ Allison Pike published a new edition Once a Maintainer: Okura Masafumi
๐ Ruby Weekly published a new edition about A first glimpse of Ruby 3.4
๐ Awesome Ruby Newsletter issued a new edition Awesome Ruby Newsletter - Issue 417
๐ Hotwire Weeklyย published a new edition aboutย Week 20 - New Turbo Native videos, mounting components in Hotwire apps, and more!
๐ Sajjad Umar published a new edition about Ruby on Rails - May 2024
๐ง Podcasts
ย ๐งJoshua Wood shared FounderQuest | RailsConf recap with John Nunemaker
๐ง Andrew Atkinson published a new podcast 220 - Sin City Ruby 2024 Recap with Andrew Atkinson - The Code with Jason Podcast
๐ง The Bike Shed published a new podcast The Bike Shed: 426: Bringing "Our Selves" to Work
๐ง Indie Rails published a new podcast IndieRails | Tom Rossi - Building Products with a Buzz
๐ง Ruby on Rails Podcast published a new episode The Ruby on Rails Podcast Episode 515: Livestreaming Code On Twitch with Rachael Wright-Munn
๐ฝ๏ธ ๐ฅ Videos
Screencasts
๐ฅ Jason Swett published a new video about Adding Test Output Streaming - Live Coding on SaturnCI
๐ฅ Sebastian Wilgosz published a new video about Extracting logic from templates with Hanami Views
๐ฅ Chris Oliver published a new video about Rubygems Trusted Publishing
โ๐พ Articles
Whatโs new ๐
๐ Andy Crollย published an article aboutย Railsconf Detroit 2024: A Co-chairโs Perspective
๐ Mohammad A. Aliย published an article aboutย Turbo charge your Ruby Litestack apps using the Fiber Scheduler &YJIT
๐ John Nunemaker published an article featuring RailsConf 2024
๐ Prasanth Chaduvula published an article about Ruby 3.4, Range#size Now Raises TypeError If The Range Is Not Iterable and about Ruby 3.4, No More TypeError With **nil As It Is Treated As An Empty Hash.
๐ Noah Gibbs published an article about Software Engineer Portfolios explaining why software engineers should have a portfolio
๐ Roland Lopez published a new article about Ruby on Rails and the Art of Object-Oriented Design
๐ Krzysztof published an article about Hanami and HTMX - progress bar
๐ Thiago Araรบjo Silva published an article How We Used a Custom Enumerator to Fix a Production Problem
๐ Paul Keen published an article on New asserts for testing stopped streams after Ruby on Rails 7.1
๐ Deepak Mahakale published an article on how Rails 8 adds Kamal by default
๐ Jason Swett published a new article about Testing anti-pattern: merged setup data
๐ Justin Toniazzo published an article on Why you should nest modules in Ruby
๐ Lucian Ghinda published an article about Add Binding.break code snippet in RubyMine and VS Code
๐ Mykola Zozuliak published an article about Ruby class pattern to work with API requests with built-in async approach
๐ Gift Egwuenu published an article about April 2024 RubyGems Updates
๐ต๏ธ Deep-Dive
๐ต๏ธ Radan Skoric published an article on the Hidden feature of Turbo: stream actions inside regular HTML
๐ต๏ธ Mathieu Eustachyย published an article aboutย Concurrency and parallelism in Ruby
How-TOs ๐
๐ Miles published a new article about Track Deployments in Appsignal with Kamal
๐ Hexdevs published a new article about How to RSpec a Jbuilder response from a Rails JSON API
๐ Ganesh K. published a new article about How to build secure APIs with Ruby on Rails
๐ Roland Lopez published a new article about Creating your first Rails Engine
๐ Paul Sadauskasย published an article aboutย Referencing Stimulus Controllers as ViewComponent Sidecar Files with Propshaft Importmaps
๐ Akshay Khotย published an article aboutย How to Access Rails Models in a Rake Task
๐ Thomas Riboulet published an article about Creating Forms in Ruby on Rails with Simple Form
Krzysztof Kamil published an article aboutย Hanami Shrine - file handling in Hanami
Related
Daniel Lemire published an article about Learning from the object-oriented mania