Is ruby that slow? I always understood it was comparable to python?
Plus if it is performant enough for Shopify and Github it seems like it would be performant for 90%+ of use cases? The speed of development and the flexibility of development is much greater than most stacks once you add rails.
Your mileage may vary but in my experience writing a decent amount of complex Ruby and Python code, Ruby is often about 20-50% faster than similar Python. I don’t really know why that is.
That said, the difference isn’t enough to matter. Both languages are in the same performance magnitude and thus suited for the same kind of tasks.
On my 2013 Macbook Pro, using Ruby 2.6.5 and Python 3.7.4, I wrote two parsers for a 19Mb Apache log file - logs1.txt. Code for each language:
Ruby
IO.foreach('logs1.txt') {|x| puts x if /\b\w{15}\b/.match? x }
Python
with open('logs1.txt', 'r') as fh:
for line in fh:
if re.search(r'\b\w{15}\b', line): print(line, end='')
Ruby's best was 3.3 seconds whilst Python's was 3.9 seconds. If you factor-out Ruby taking 100ms longer than Python to startup Ruby is 18% faster than Python for string parsing. Results probably differ for Python's numeric performance but that depends whether you're including C-based third party libs such as numpy.
In fact, Ruby is not performant enough for Shopify, Github, and [<large_company>, ...].
It's very misleading for large companies to say "Ruby on Rails is performant enough", as they rely on other languages for their performance critical workflows.
I remember sometime ago on HN a GitLab developer repeating the same sentence. Actually, GitLab does use Golang for some microservices.
It's wonderful that a combination of Ruby and <performant_language> is easy to develop/maintain and fast at the same time, however, the distinction with a pure Ruby system is not a trivial semantic matter, as it perpetuates the wrong and misleading idea that pure Ruby is fast enough to develop a complex system.
I asked a couple of the Shopify engineers a a conference in late 2018: almost all of Shopify's web and background job processing is Ruby. They're quite open about it:
Hm, a lot of the article focuses on optimizing your interaction with a database (rdbms/sql), which has nothing to do with the performance of ruby (some of it arguably has to do with _Rails_).
Even more of the article has to do with Rails, and not ruby in general.
But the larger point, are you suggesting that in a language that is "performant enough", developers need no performance advice, they can write however they want and get adequate performance, for any performance needs?
Maybe, although I'm dubious. The existence of advice for programming does not mean a language/platform isn't "something enough" until we have AI writing code. At any rate, if such a language exists it is not ruby. But I disagree with that suggestion. The existence of optimization advice does not mean that a language "is not performant enough". If Shoppify is still happily using ruby/rails, I would say it indeed demonstrates they are performant enough for them.
Nope I'm not. But Shopify is large enough to have a first-class engineering team that would (presumably) be writing efficient code, which is nothing special. So if this first-class engineering team is still writing about _fast code in Ruby_, doesn't that imply Ruby isn't fast?
Shopify's engineering team is obviously writing code congruent with the advice they give here, that's why they give the advice! I'm not following you at all.
I don’t know, I think most of the high level points made in the article (caching, know your SQL/ORM, memory management and algorithm complexity) apply to almost any web application and framework once you hit some level of scale.
This is an article about the Ruby on Rails framework not the ruby language. Most of the discussion is about SQL and query optimisation.
Also describing common performance pitfalls does not imply that something is or isn’t “performant enough”. Only that you can make mistakes that will affect performance.
That, I’m afraid, is true for every language or framework.
Plus if it is performant enough for Shopify and Github it seems like it would be performant for 90%+ of use cases? The speed of development and the flexibility of development is much greater than most stacks once you add rails.