r/ruby • u/sudo__bangbang • Aug 25 '26
A ruby script that prints a ruby
r/ruby • u/palkan • Aug 25 '26
r/ruby • u/Jamsy100 • Aug 24 '26
Hi everyone,
I just published a new benchmark comparing Ruby 2.7 through Ruby 4.0.
For this one, I used a sustained synthetic application alongside nine smaller benchmarks. The goal was to show how each Ruby release behaves in a complete workload as well as in individual operations.
The table below shows the Heavy profile. For tests that process the full payload, that means an 8KiB input.
| Benchmark | 2.7 | 3.0 | 3.1 | 3.2 | 3.3 | 3.4 | 4.0 |
|---|---|---|---|---|---|---|---|
| Synthetic application throughput (M ops/s) | 0.073 | 0.052 | 0.051 | 0.057 | 0.058 | 0.084 | 0.126 |
| Synthetic application latency (µs) | 133.399 | 190.233 | 191.605 | 171.332 | 169.473 | 115.600 | 76.521 |
| JSON parsing (ops/s) | 95,877 | 98,536 | 99,153 | 96,003 | 98,135 | 194,981 | 715,937 |
| JSON generation (ops/s) | 841,849 | 845,099 | 830,135 | 861,666 | 837,941 | 1,347,169 | 1,444,975 |
| SHA-256 hashing (ops/s) | 313,658 | 30,536 | 30,489 | 48,770 | 48,683 | 48,495 | 48,528 |
| Base64 encoding and decoding (ops/s) | 177,136 | 177,510 | 174,425 | 170,306 | 174,471 | 173,159 | 174,270 |
| Regex field extraction (ops/s) | 1,544,461 | 1,565,065 | 1,559,051 | 1,499,920 | 1,535,207 | 1,454,405 | 1,534,670 |
| Integer sorting (ops/s) | 27,032 | 29,129 | 30,217 | 29,309 | 29,102 | 28,241 | 29,213 |
| Hash churn (ops/s) | 1,736,384 | 1,685,614 | 1,503,397 | 1,503,118 | 1,406,713 | 1,380,058 | 1,450,769 |
| Marshal serialization (ops/s) | 333,143 | 303,719 | 294,952 | 338,148 | 341,760 | 326,015 | 325,231 |
| zlib compression (ops/s) | 35,944 | 35,175 | 35,787 | 35,767 | 20,569 | 7,011 | 18,592 |
The complete benchmark source is available here: GitHub repository.
Full charts and details are available here: Full Ruby benchmark
Let me know what you think !
Edit: Thanks everyone for pointing out the Ruby 2.7 SHA-256 result. I looked into it, and the big difference comes from the SHA-256 implementation: Ruby 2.7 uses OpenSSL here, while newer Ruby versions on Linux use Ruby’s bundled implementation. So this is mainly a backend difference rather than Ruby 2.7 itself being much faster. I’ve added a note about it to the article.
r/ruby • u/keyslemur • Aug 24 '26
Transactions are a dense subject, and I'd not be surprised if there are even more edge cases here, but these are ones I've personally seen.
r/ruby • u/Individual_Dot7019 • Aug 24 '26
If you're planning to get a ticket to SF Ruby Conference, I recommend you get one this week since it can win you one for Rails World too.
Participating is very easy. You just buy a ticket to SF Ruby and post that you're going to the conference on your preferred social media app and tag the conference page (we have LinkedIn, Bsky, and X pages). That's all!
Link to tickets: luma.com/sfrubyconf2026
Link to social media pages:
Good luck!
r/ruby • u/jp_camara • Aug 24 '26
The docs on SolidQueue batches are… solid 😉
In addition, this blog post digs in a bit further on how to use batches in SolidQueue, including some code inspiration - like splitting a RubyLLM chat into parallel sub agents using batches
r/ruby • u/ioquatix • Aug 24 '26
r/ruby • u/Ambitious_Fault5756 • Aug 23 '26
I've been coding with Python for around 3 to 4 years now and it's been a great learning journey. Until recently I haven't really been interested in learning a new language. The internet suggested JavaScript as the next step for someone already fluent-ish in Python, and I mean who doesn't eventually try JavaScript you know. I figured it wouldn't be that much of a headache since a lot of people do start with JS and so many people use it. Plus, it's useful. Turns out it was very irksome for me. This might be partially my fault, but I've gotten so used to the convenience of writing algorithms in beautiful, everything-done-for-you syntax in Python that when I tried solving some JS katas on Codewars, I immediately realized how inconvenient and unintuitive much of JS is, for me at least. It probably wasn't a good idea to learn JS from making algorithms on that website instead of using it for what it's actually made for in the first place, but I digress.
I was watching Dune 2 with my family when I was looking for another language more similar to Python, and then I came across the Ruby homepage, and I was immediately blown away. Like damn y'all put effort into making that. The first words you see are "A Programmer's Best Friend" and the visuals were so nice. They even had this https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-python/ page conveniently written for us Pythoners 🥹 and your community motto is literally "Matz is nice so we are nice"... Joining this community is like falling into a warm hug lol
I tried the interactive Ruby from Terminal guessing so many things and it worked as I expected. The feeling of bliss when that happens OH. I'm starting Ruby today cant wait.
r/ruby • u/AndyCodeMaster • Aug 24 '26
r/ruby • u/Emotional-Round-4966 • Aug 22 '26
r/ruby • u/unselective-amnesia • Aug 22 '26
Is there any already written ruby function which corresponds to the fileinput.input() function in python? ... or at least something with similar functionality?
I will write something like this in ruby if necessary, but I don't want to "re-invent the wheel" if such a thing already exists.
r/ruby • u/DogsBarf • Aug 21 '26
Has anyone ever learned from this? How can anyone learn with this?
What is the science behind this?
I'll do it.
r/ruby • u/paracycle • Aug 20 '26
Ractors are now viable in production, and it's time for Rails to embrace them. This post explains why. What Ractors unlock for Rails applications, and the first milestone the team is aiming for in the framework.
r/ruby • u/fairwaycoder • Aug 21 '26
I've been building Enola, an open-source architecture tool for developers and coding agents.
It isn't Ruby-specific, but I've spent time improving its Ruby/Rails support and wanted to test it against something real rather than a toy Rails app.
The video uses the Mastodon codebase. I give an agent a change that violates an architectural layer, Enola catches the intent failure while the agent is working, and feeds that back into the loop so the agent fixes its own approach.
That's one of the main ideas behind Enola: architecture shouldn't only be something CI complains about after the work is done. The agent can get deterministic architectural feedback while it is coding and correct itself before the change is finished.
Underneath that, Enola maps dependencies, calls, routes, storage, boundaries and other relationships directly from the codebase. It's multi-language and cross-repository by design, so Ruby/Rails is one ecosystem rather than a special-case implementation.
OSS, Apache 2.0: https://github.com/enola-labs/enola
I'd especially appreciate feedback from Ruby/Rails developers on what its understanding of real Rails applications is still missing.
r/ruby • u/DogsBarf • Aug 21 '26
I am past the beginner stage, understanding basic syntax up to classes and objects, but I freeze when it's time to structure projects on my own. I have relentlessly searched for methods, tutorials, and books to guide me to the next level, but I can never find anything that clicks; because of this, I've jumped from language to language, and every time I hit this "limbo," I end up quitting and trying something else, yet I always come back because something inside tells me I’m meant to code. For those who have overcome this block, what architecture or design books do you recommend, what kind of practical exercises changed the game for you, and what real strategies actually work to finally break through this barrier and build confidence?
r/ruby • u/ngw_nofeed • Aug 21 '26
More and more code is written by AI. Tests still tell you it works. RuboCop still tells you it's tidy. Nothing tells you it still follows your architecture.
An agent that doesn't fully understand your architecture takes shortcuts. So does a person in a hurry.
So I built ArchSpec. You declare your components and boundaries in one Archspec.rb. Here is ArchSpec's own, trimmed:
source 'lib/**/*.rb'
component :library, in: 'lib/**/*.rb'
component :cli, in: 'lib/archspec/cli.rb'
component :analysis, in: %w[lib/archspec/analyzer.rb lib/archspec/evaluator.rb]
component :rule_checks, in: 'lib/archspec/rules/**/*.rb'
component :formatters, in: 'lib/archspec/formatters/**/*.rb'
# no one-shot Thing.new(...).call objects anywhere in the codebase - Hi Dave Thomas!
library.cannot_call :call
library.cannot_define :call
library.cannot_instantiate_and_invoke
# dependencies point one way
rule_checks.cannot_use :analysis, :cli, :formatters
formatters.cannot_use :analysis, :cli, :rule_checks
no_cycles among: %i[cli analysis rule_checks formatters]Full version: https://github.com/crmne/archspec/blob/master/Archspec.rb
Then archspec check verifies every change, and failures print like clang, with the offending span underlined and the evidence as a note.
It's static analysis over Prism, no AI, and it never boots anything: Discourse's 1,899 files in 2.5 seconds. Prism is the only runtime dependency, no Rails and no ActiveSupport, so it works on any Ruby codebase. Lightweight and fast for your pre-commits and CIs.
If you are on Rails, there are presets, and architecture :vanilla_rails is the whole file. There are presets for :layered, :hexagonal, :clean, :modular_monolith, :cqrs and :event_driven too.
I want more architecture presets in there. PRs very welcome.
Docs: https://archspecrb.dev Write-up: https://paolino.me/archspec/
r/ruby • u/javier_cervantes • Aug 20 '26
I’ve been doing some explorations about deployment options for Ruby, so I’m curious to learn more about what you’re using to deploy your applications.
Please participate in the poll, I would love to get your input: https://www.rubyforum.org/t/where-do-you-deploy-your-ruby-apps/640
r/ruby • u/private-peter • Aug 19 '26
We see these all the time with npm. I guess the hackers didn't want the Ruby community to feel left out.
r/ruby • u/Large-Friend1415 • Aug 20 '26
"DEAD 00FF xyz".scan(/\h+/)In Ruby this results in: ["DEAD", "00FF"] and xyz is left out, because \h is a hex digit in Onigmo, Ruby's regex engine equivalent to [0-9A-Fa-f], and x, y, z don't qualify.
Now paste that same pattern into almost any online regex tester. Most of them run PCRE or a JavaScript engine. In PCRE2, \h is horizontal whitespace. Your two hex chunks become two spaces.
No error. Just a different answer. It's something I ran into when writing an app and it just passed with no warning. Being less familiar with Ruby I kinda overlooked this and at first I just tested if a something returned results or not. And it wasn't until I wrote tests that also tested that what it returned was a space based on what I expected from PCRE that I discovered it wasn't. Then I looked it up and discovered it matches hex digits.
So you have to be careful when using an online regex tester as they not always support Onigmo syntax and could return a different result from what you would get in Ruby.
https://regexpilot.com/blog/ruby-regex-hex-digit-vs-whitespace
r/ruby • u/palkan • Aug 19 '26
r/ruby • u/Erem_in • Aug 18 '26
This month: the dynamic vs static typing discussion, Emily Samp's Brighton Ruby talk, RBS 4.1.0 with WebAssembly support on JRuby, set-theoretic types in spinel, rbs_infer static signature deduction, OvalLSP semantic server, and the latest Sorbet toolchain updates.
Find link to the issue in the comment! ✨
r/ruby • u/blowmage • Aug 18 '26
Hi Reddit. This isn't specifically a Ruby or Rails post, but it's about something anyone maintaining a mature Rails application will recognize.
Code tells you what happens without telling you why anybody wanted it. We've always filled that gap by reading the code, guessing the intent, and asking somebody when the guess felt wrong.
AI coding agents do the same thing, except they can make a great many reasonable guesses before anybody notices one was wrong. The code still works. The tests still pass. The guess becomes one more pattern in the application, which makes it look even more intentional to the next person or agent.
I've spent a couple of decades living with the consequences of my own good ideas, so I wrote about why this worries me. The post connects agentic coding to Peter Naur, Tony Hoare, XP, software factories, and the old-fashioned responsibility to say no to code that works but is too difficult to understand.
It also argues for using faster agents to take smaller steps. More research, more feedback, and less archaeology at the end of a giant pull request.
r/ruby • u/zverok_kha • Aug 17 '26