John Hawthorn, a brilliant Rubyist and contributor of quite a lot of important
open source in the Ruby ecosystem references a benchmark for a gem that lets you
invoke the Crystal programming language from
Ruby.
I'll spoil the post here by giving you the before and after.
Before:
The "crystalized" version runs about 4x faster than the pure Ruby version.
After:
Now it's Ruby that's 5 times faster than Crystal!!! And 20x faster than our original version.
Writing a program that behaves the way you want is hard, but that's not the end
of the journey. Without an understanding of how the computer will execute your
instructions, you're left at the mercy of a bunch of arbitrary performance
implications that can lead to misguided beliefs emerging within teams and
organizations.
A common refrain in recent years is, "we're rewriting all our critical
sections of Ruby into Rust." Closer inspection by an expert almost always finds
flaws in the assumptions (or, if there are any, analyses) that lead to these whole-cloth "optimizations", however.
I've seen organizations try to pull off pretty much every approach you can think
of to escape performance problems and technical debt. The more dramatic the
maneuver—like, say, bifurcating one's codebase into two languages and then
bridging them—the more likely it is to fail to accomplish the stated goal or to
fail outright.
Trust me when I say it's almost always better to dance with the one who brought
you. Embracing the problem usually leads to better solutions than running from
it.