2023 and Ruby is still ridiculously slow for some things
I am doing some machine learning stuff for recommendations, and needed to preprocess some train data before feeding it into the recommender. The processing of a dataset done in Ruby was taking up to 20 seconds to process half a million items despite a ton of optimizations; I ported the same processing to a Postgres function (it's not just queries, I need to build a temporary dataset and then another derived from it with some processing that requires looping; I could in theory do it with CTEs but it would be ridiculously complex in comparison). This way it happens in the database directly, and it now takes just 50 milliseconds for the exact same processing. 400_000 times faster than the exact same thing done in Ruby. I still cannot believe the difference. I was planning to port the Ruby code to Crystal due to the difference in speed but I am gonna leave it in Postgres. It's 2023 and for some things Ruby is still ridiculously slow compared to alternatives 😦
Comments
Would be interesting to know the difference between Ruby and Crystal
I noticed Crystal is way faster but struggles with certain use-cases as well.
What do you mean it struggles? I have done some stuff with Crystal and it's just awesome. Looks like Ruby but plenty fast
Thanks for this data point. Now when I participate in language flamewars I'd have some anecdote against Ruby
But really, I think Ruby folks were touting ergonomics over performance. Its flagship product was Ruby in Rails. When Twitter decided to ditch it, it didn't bode well for the ecosystem.
I also think RoR and Ruby "community" moved on to Rust.
What? As a Ruby/Rails dev this doesn't make any sense
Rust doesn't have anything that is remotely comparable to Rails
No, I mean the community active in Ruby (like the people writing blogs etc) moved on to Rust. Or so I've heard.
I am pretty sure you've heard wrong. Rust is growing fast, but for Rubyists like myself Cyrstal is a more natural choice when performance matters
Here some examples from a few years ago:
https://news.ycombinator.com/item?id=19560566
https://news.ycombinator.com/item?id=19166020
Especially this comment and its replies
But these are isolated cases, it's different from asserting that the community is moving en masse or something like that
Yeah that's why I quoted the "community". I think I've read somewhere that few Mozilla people who blogged a lot about RoR moved on to Rust.