💡 One of the most popular recurring features we've added to our sister Postgres Weekly newsletter has been a 'tip of the week.' We've been looking to begin this in Ruby Weekly too, and thanks to the hard work of Jemma Issroff we've got out first one this week. Don't miss it at the end of this issue :-) __ Peter Cooper, editor | |
How Fast is Ruby 3 on Rails?— The king of running Ruby and Rails benchmarks is back with a look at how Ruby 3 handles Rails from a performance point of view. Spoilers: The final release of Ruby 3.0 is more stable under load than preview1 and the overall performance is not dissimilar to that under 2.7. Noah Gibbs |
▶ DHH Talks Hotwire, Rails Next and the 'DHH Stack'— Whatever David Heinemeier Hansson (DHH) does is of natural interest to Rails developers and many Ruby developers too, so it’s nice to hear him chat at length on his current attitudes to things including Hotwire, ‘Rails 7’, and how he starts new projects. Remote Ruby Podcast podcast |
IRB’s New Built-In Time Measuring Command— Ruby 3.0 added measure , which you might know allows you to measure time, but did you know there’s a stackprof option? And, did you know you can add your own custom measures as well? (Jemma also contributed our first Tip of the Week which you can find at the end of this issue.) Jemma Issroff |
▶ Chatting with a Rails Core Team 'Heavy Hitter'— Rafael França is a Principal Engineer at Shopify, Rails core team member, and has the most commits to the Rails codebase to his name (with even more than DHH). On this podcast he discussed how the Rails 6.1 release went and drops some hints about Rails 7. Ruby on Rails Podcast podcast |
A Better React/Rails Architecture— Spoiler: It’s about modularizing to allow each framework to fill its intended purpose in its intended manner. Stitch Fix Technology |
The Rails Upgrade Series— The guides go all the way back to 2.3 (I’d love to see usage statistics on the older guides) and up to 6.0, so if you need to upgrade for any version, check it out. FastRuby.io |
Senior Software Engineer at Loomly (Remote)— Loomly is the Brand Success Platform that helps marketing teams streamline online collaboration. We’re looking for a Senior Software Engineer to contribute to building our core product and help with ongoing maintenance. Loomly |
Find a Job Through Hired— Create a profile on Hired to connect with hiring managers at growing startups and Fortune 500 companies. It's free for job-seekers. Hired |
ℹ️ Interested in running a job listing in Ruby Weekly? There's more info here. |
💡 Tip of the Week Open an IRB console within code using binding.irb There are many popular debugging gems or IRB alternatives. These are typically packed with features and can be extremely useful tools. The main caveat to using them, besides learning their unique syntax, is having to install (and sometimes configure) them. If we're working in repos that don't have our favorite debugging gems installed, we have to adopt certain workarounds. Perhaps less well known than gems like pry and byebug is the binding.irb feature of irb (as available in Ruby 2.4 onward). It allows us to open an IRB console from within the current scope. In this IRB console, we can call any methods or variables defined within the current scope as well as mutate state. Since IRB is installed with Ruby, there's no need to install any separate gems and it will work wherever we're running Ruby. Here's an example of adding a binding.irb call to some simple code: |
def func(input) a = 1 binding.irb a + input
end
puts func(0)
|
$ ruby example.rb
From: example.rb @ line 3 :
1: def func(input) 2: a = 1 => 3: binding.irb 4: a + input 5: end 6: 7: puts func(0)
irb(main):001:0> a
=> 1
irb(main):002:0> input
=> 0
irb(main):003:0> a = 2
=> 2
irb(main):004:0> input = 3
=> 3
irb(main):005:0> exit
5
|
Voila! We get an IRB console from within our code. Not only can we see the values of our local variables, we can also change their values (which leads this program to print 5 instead of 1 as it otherwise would have). Any methods or variables available within the current scope can be accessed from this IRB console. As we see above, binding.irb will pause execution of our code, and exit ing the IRB console will resume execution. Next time you're debugging, give binding.irb a try! This week’s tip was written by Jemma Issroff. |
|
|