3

💎 Ruby 3.2.0 Is From Another Dimension

 1 year ago
source link: https://tomaszs2.medium.com/ruby-3-2-0-is-from-another-dimension-5249e3186ec9
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

💎 Ruby 3.2.0 Is From Another Dimension

I don’t know what you were doing on 25th of December 2022. I was eating pierogis, while Ruby team did some epic sh***!

1*u8MemDH2-NeAMBsmmJedqg.png

On that very day Yui Naruse announced the release of a ground breaking Ruby version. You know I am reporting what’s new in programming languages for a while now. I didn’t see that coming especially on the festive season. I almost chocked on my bigos!

You Can Now Run Ruby In Your Browser

Let’s start slow. WebAssembly and WASI are with us for a while now. There are some attempts to run various programming languages in the browser and on serverless environments supporting WASI.

But Ruby made it early to the party and is in an exquisite company of C#, Rust, Go and Swift. It is impressive, Ruby team proves to be able to provide all the stuff kids love these days.

41% Faster Code Execution

Finally, the YJIT is production ready. The new JIT compiler based on ground breaking Basic Block Versioning already gives some exciting results. The benchmark speed is 41% faster.

Shopify, that is also heavily relying on Ruby also reports up to 39% speed improvement!

No More Regex Lags

If you are using Regex heavily, you know it is sometimes possible to throw out your computer just by writing wrong Regex. I personally am responsible for hanging online regex testers tens of times in 2022.

In Ruby 3.2 there were implemented two solutions to tackle the problem. First is a global regex timeout. Whatever you will write, the regex will terminate the execution after given period of time. But that would not be enough for Ruby team. Oh no. They have also crushed the execution time!

Please look carefully at this chart:

1*URz4BLb3jbH3FeQZrFzOVg.png

Do you see anything suspicious here? I will give you a hint: where is the red line? It’s not there anymore.

The Ruby team used some memoization techniques and excellent craftmenship to basically flatten the curve. For some regex rules execution time is linear and flat like a sidewalk covered with ice.

Another chart shows regex went on a serious diet after the changes:

1*6fFlZ4Lt7Uxnq1P13C8FiA.png

The chart could as well represent my weight gain during the Christmas. Unfortunately for me, it is the blue line 😄

Read to the end for a bonus

No More Flow Control Mismatch Hell

Don’t know about you, but I really hate it when I have to remove some ifs, and some fors, and end up figuring out where I should close them.

With Ruby 3.2.0 the war is over, because it indicates very precisely where the end is likely to be missing. Here’s an example:

1*kJoLj8s0nNLHk5X7i8lISQ.jpeg

Passing Anonymous Rest And Keyword Rest Arguments Is Now Possible

Ruby 3.2.0 comes with other notable improvements as well. But the last one that caught my attention is described in the header, and looks like this:

1*FPBd3XDgK_Wk1-NmC3w8KQ.jpeg

Ruby on 100%. Making programming as comfortable as possible.

The Ruby 3.2.0 release is amazing. I love the WASI initial support, faster execution, faster regex and syntax and error reporting improvements. The release is definately ground breaking and worth updating to.

Bonus

Check out what’s new in Rails 7.0.4.

If you like the article, clap, subscribe, like and share. Cheers!

Source


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK