Short Ruby News - edition #20

Briefly about everything in Ruby world

This edition was created with the help of @adrianthedev/@[email protected] from Avo for Ruby on Rails (a friendly full-featured Rails admin panel) and @jcsrb.

You can jump directly to one of the following sections if you like:

πŸ‘ Our Community

More content: πŸŽ₯ 🎧 πŸ—ž (articles, podcasts, videos and newsletters)

πŸ‘ Our Community

πŸ‘ Hanami 2.0 was released. Read the release notes here.

πŸ‘ Ruby versions 3.1.3, 3.0.5 and 2.7.7 are released:

Related to this, Postmodern announced that ruby-versions now support all these three versions.

πŸ‘ Jean Boussier about Ruby/Rails:

🀝 Cezar Halmagean is offering all Short Ruby subscribers/readers a 40% discount for his course Learn Hotwire . Use coupon code SHORTRUBY (valid until Tuesday) at the checkout :

πŸ‘‰ All about Code and Ruby

πŸ‘‰ Greg Navis shared a thread about constant autoloading. Read the whole thread about how constant autoloading works:

πŸ‘‰ Chris Oliver asked about deals for Ruby & Rails. Some of them were available for Friday, but I think you should check them out as most of them are still available:

Here is a list of links (that today - Sunday seems still to be valid) from the replies:

πŸ‘‰ Mehdi Farsi shared a short code explaining the difference between ! and not:

If you want to understand more unary operators (the method ending with @) here is an example:

πŸ‘‰ James shared a new project he is working on rubymyths.dev and here is the reason why:

If you want to know who was the one that inspired this and what they shared, read here

πŸ‘‰ Joel Drapper asked about why senior/principal engineers are asked basic Rails take-home coding challenges:

The thread also has some ideas about how a conversation about hiring senior developers could be.

πŸ‘‰ Kelly Sommers shared a joke that Mastodon seems slow, and it implied this is because of Ruby:

Nate Berkopec pointed out that maybe Ruby is not the issue here:

And also added that the X-runtime header is showing 92 milliseconds runtime:

I am adding something here: Kelly said they shared this as a joke, but this is a joke that is not so obvious and implies that Ruby is slow. Thus please take time to read the thread, as this kind of critique, sometimes thrown in a lightweight way, will influence decisions. It will help you be prepared to have this conversation.

πŸ‘‰ Jason Swett shared they are starting Code With Jason Salon. Register here if you want to participate:

πŸ‘‰ Joel Drapper shared a code preview showing conditional tokens support in the next version of Phlex:

πŸ‘‰ Greg Navis shared a thread about using then to sequence operations:

πŸ‘‰ Kirill Shevchenko shared a code sample about using the ActiveSupport built-in module for configuration:

πŸ‘‰ Greg Navis shared a thread about currying in Ruby. There are a lot of code samples there so here are two

πŸ‘‰ Peter Solnica shared a code sample showing how providers work in Hanami:

πŸ‘‰ Greg Molnar asked about Rspec or Minitest:

Here is a summary of reasons for choosing Minitest:

  • It is simple

  • It is fully supported by Rails.

  • It is easier to reason with

  • It is easy to onboard new developers as there is no new DSL to learn

And here is a summary of reasons for choosing RSpec:

  • Because a lot of people are using it

  • needs less code to achieve the same test case as with Minitest

  • Rspec seems less boring than Minitest

Worth considering listening to this YAGNI episode: RSpec w/ Justin Searls

πŸ‘‰ Joel Drapper started a discussion about method overload in Ruby (please be advised this does not work):

And this got a lot of gems proposing various ways to achieve this:

πŸ‘‰ Lucian Ghinda asked about examples of using the endless method:

Here are some responses:

  • "Using it when the method is exactly one line with no logic (not even ||=)β€œ (@[email protected])

  • β€œsaw someone used it to replace the rails β€œscope” class method” (@[email protected])

  • β€œI often use them for methods that are a single statement (not line, statement)” (@[email protected])

  • β€œI use it mostly as a signal that the method is basically a computed attribute -- it's a single statement, and usually takes no arguments.” (@[email protected])

  • β€œI use it with one-liners, mostly like I'm using one-liners in Elixir. Just return data, no mutations or memorization” (@[email protected])

  • β€œOnly use Ruby 3.0’s endless method definitions with a single line body. Ideally, such method definitions should be both simple (a single expression) and free of side effects.” (rubystyle.guide)

There are some code samples shared so you should read the replies.

If you have read so far and you like the content, maybe you take into consideration sharing this and subscribing:

🧰 Gems, Libraries, and Updates

🧰 Avo shared a new release packed with a lot of goodies:

🧰 Joel Drapper shared a RC release for Phlex 1.0. Read the release notes here

🧰 Stan Lo shared that IRB v.1.5.0 has been released. He also shared short videos explaining the highlights:

Explaining edit commands and explaining debug commands:

🧰 Jean Boussier shared a PR for fixing format_command Fix `format_command`'s terrible performance

🧰 Dima Fatko shared their two PRs that are merged and will be part of Rails 7.1 that will save many queries when updating records:

🧰 Takashi Kokubun announced the release of ERB v.4.0.0:

RB::Util.html_escape became 1.77x faster in no-escape cases. From Ruby 3.2 or if you use ERB 4+, it's faster than CGI.escapeHTML

He also shared a PR that is merged to Rails main which will improve ERB speed

🀝 Related (but not Ruby-specific)

🀝 Mario Fusco shared an opinion about the Design Patterns book:

He then followed up with a thread explaining more about why they think the book is outdated and also shared.

🀝 Jason Swett shared about one of the benefits of writing tests first:

🀝 Ryan Bates shared about writing clever code:

More content: πŸŽ₯ 🎧 πŸ—ž

Newsletter

πŸ—ž Ruby Radar published a new edition: Ruby Radar #78 - RubyConf 2022

πŸ—žοΈ Ruby Weekly published a new edition: OK, this is a big week for Ruby

πŸ—žοΈ Ruby LibHunt published a new edition of the Awesome Ruby Newsletter

Podcasts

Videos

πŸŽ₯ Avo shared a video showing the last release's changes and how to use the code for the new features: Avo 2.20 - Arguments on filters and actions, keep action modal open, and select field fixes.

πŸŽ₯ The London Ruby User Group shared the videos from the November 2022 meeting:

πŸŽ₯ John Hawthorn shared a live stream on Twitch about improving Mastodon and looking at Ruby performance: Watch it here

πŸŽ₯ Collin Donnell did a live streaming on Youtube about the first look at Hanami: Hanami First Look

πŸŽ₯ Dave Kimura published a new episode about Active Storage Variants

Articles

Maciej Mensfeld shared an excellent article they wrote about contributing to Ruby on Rails and improving concurrency: Ruby concurrency is hard: how I became a Ruby on Rails contributor

AppSignal blog published a new article by Julian Rubisch about System Notifications with Noticed and CableReady in Rails

Reply

or to participate.