YJIT is an amazing technology, and together with other innovations like object shapes and various GC optimizations, Ruby is becoming seriously fast! Big Ruby shops such as Shopify [1] have been running 3.3 pre-release with YJIT and reporting double digit percentage performance improvements.
Personally I'm really excited about Ruby and its future. I can't wait to start working with Ruby 3.3 and using it on my client's production sites...
[1] https://railsatscale.com/2023-09-18-ruby-3-3-s-yjit-runs-sho...
Edit: add percentage to performance improvements.
The recent irony of the web is anyone that implemented a web app with "slow" ruby and backend rendering now has the fastest page loads compared to bloated front-end web apps backed by actually slow eventually consistent databases that take seconds to load even the tiniest bits of information. I see the spinner GIF far too often while doing menial things on the "modern" web.
For reference:
$ units -1v '1|2 billion reqs/month / 14 servers' 'req/sec/server'
1|2 billion reqs/month / 14 servers = 13.580899 req/sec/server
I always do this when I see large-sounding query counts; a month has a lot of seconds in it, and it’s easier to visualize only one at a time: I can imagine hooking a speaker up to the server and getting a 14Hz buzz, or do a quick mental arithmetic and conclude that we have ~70ms to serve each request. (Though peak RPS is usually more relevant when calculating perf numbers; traffic tends to be lumpy so we need overhead to spare at all other times which makes the average much less impressive-sounding.)I think that shim still uses ruby 2.6, I may try to upgrade it to 3.3 with yjit and see what the latency drop is, which is probably a more interesting number anyways, but again only really matters for a single caching request that only happens once in a while.
The real reason I continue to use ruby is because it's a quick way to get things done on business logic heavy web apps, but I continue to be impressed how much I can get away with using it for things it's really not known for being good at. I run into people often that refuse to use it for absolutely anything because there's a perception that it's "too slow", but when pressed I learn that they're not really working on anything that requires high performance provided by more esoteric languages with stricter memory management that is very likely nerfing their productivity unnecessarily. My goal here was to push back on that perception a bit, not to make the dns shim sound impressive.
But something to keep in mind. I’ve seen servers before that could serve in the 100,000 QPS range on a single instance! They weren’t written in Ruby.
What database is on the backend, and is that db serving cached content? What happens if you cache it with e.g. redis to avoid the heavyweight rails ORM stuff?
Do you have granular benchmarks for the db query, requests to other services, and the web processing itself (using artificially pre-cached responses from db and those other services)?
If you rewrite it anyway, might as well use something else than ruby.
The db (mysql) is not the problem in the scenario I described.
You’re likely in one of two situations as a businesss:
* You’re a struggling startup. Development velocity trumps literally everything. Your server costs are trivial, just turn them up.
* You’re a successful business (maybe in part because you moved fast with Ruby), you can pay down the debt on that absurdly large response. Chunk it, paginate it, remove unnecessary attributes.
This is paginated (page size of 1000) and the caller chooses only the attribute they need already, thanks.
Even successful companies care whether they need to run 1000 servers or one for something.
My entire point was that Rails is not designed for this.
“Why would I pointlessly accept this clear case of massive technical debt for literally no reason what-so-ever?”
Rails does not present any sort of promise that go does not also present, so just saying “yeah, I’ll handcuff my app like this cause I feel like using Ruby” is, frankly, absurd.
When you ask the right questions, you never land on Ruby, and that’s why Ruby continues to decline.
You mean like 10% faster, or 10x faster?
Edit: clicked the link; it's 10%. I don't think that's going to make any difference to the perception of Ruby's slowness given that it's on the order of 50-200x slower than "fast" languages like Rust, Java, Go and C++.
Hardly relevant, I'd think at least 80% of all Ruby usage everywhere is in Ruby on Rails applications.
The 100x to 200x mainly comes from Rails.
All these micro-benchmarks shootouts means nothing either. Is anyone running a mandelbrot or pi-digits SaaS company? I'd think not.
Similarly saying Rails is slow out of context, means nothing, Rails is "slower" than Ruby micro-frameworks X because it does useful things the other doesn't like CSRF protection etc. If you don't need these features, turn them off and Rails will be about as fast as these frameworks.
If anything annoys me more than clueless people shitting on Ruby for bad reasons it's Rubyists spreading FUD about Rails.
One is scripting language, the other compiled, the difference is huge already there.
It is worth comparing any two languages and ecosystems if they are used for the same things, in this case -- web backends.
Anything and everything that has a web backend is a fair game for comparison.
We do allow the occasional use of “send” but try to avoid it. Dynamic method definitions are strictly banned.
a nice ide integrated experience:
https://code.visualstudio.com/docs/languages/ruby#_debugging...
https://github.com/ruby/vscode-rdbg
https://code.visualstudio.com/docs/editor/debugging
heavy metaprogramming in any language is going to be a pain to debug so i'm not sure what you're expecting but there are tools to help. you can also call source_location on some method to figure out where things exist.
The link shows 13-15%.
If I’m going to give it even a second glance, I can’t be seeing “ruby 10,000% slower than Java” for measured use cases.
But one thing that is not mentioned or discussed enough, is Ractor, M:N thread scheduler, Fibre and Async. Especially in the context of Rails. I am wondering if any one are using these features in productions and if you could share any thoughts on the subject.
This is entirely predictable - Ruby does not have a big scientific computing community which happened to depend on every implementation detail of the hosting interpreter.
It is quite common to see "Python" libraries that are just thin bindings layers, they could just as well be "Tcl" libraries for that matter.
Python workloads, with deep pocketed backers, do spend more time inside GPU or C runtime.
Really? What’s so significant with this release?
> But one thing that is not mentioned or discussed enough, is Ractor, M:N thread scheduler, Fibre and Async.
Yes! Ractors deserve more highlighting! It’s a huge feature.
I think the Prism parser update is a standout highlight for me. This is the start of many new static analysis tools for ruby.
It's also significant that RBS type information is starting to be used in IRB autocompletion. Previously RBS has been an interesting experiment but hasn't had much practical use compared to Sorbet.
Ruby seems to now have good answers to non-blocking IO (async fibers) and tooling questions (ruby-lsp). We're starting to see YJIT performance improvements starting to compound with more to come too.
That all seems significant to me. Thanks to everyone involved.
I just looked at the source, I guess Mike has been mostly working on both projects on his own for the last 4 years, so Faktory has a lot of features that require the enterprise license.
I wonder if he could change the situation it he markets a bit more to the python and more specifically Django community.
By the way, celery was born as a protocol spec to support multiple languages but never moved past Python. I can't google a quote for that, I remember I saw it years ago in the documentation somewhere.
I still think Rails has the best ORM design I've ever seen, iterated with practical applications. Django's ORM and migrations are, for lack of a better word, odd.
I'm a bit surprised that people here argue that no one using Rails would ever want to interface with other languages. Most big companies do. How can you not interface with python these days.
Looks to me like celery might just be the only job queue left like that. Might be worth writing a current ruby en-queuing library for it. Retracting my previous statement about ActiveJob since it would probably be too much effort to execute anything bidirectionally.
External systems come with a cost, especially if it's more than a library.
Not sure I can recommend it, but Gearman does fit the bill. There’s client and worker libraries for a dozen languages, including Python3 and Ruby.
A Ruby implementation would probably not be hard.
I don't how much people use this in serious or high performance work but it might be an option.
[1] https://mac.install.guide/ruby/update.html
Just curious, which version manager would you recommend? Previously I recommended asdf, frum, or chruby.
Do other language runtimes do similar things? Creating a thread sounds too heavy, though it might not matter in practice. As per their own benchmark, the overhead is minimal but still not zero.
10000.times {
Addrinfo.getaddrinfo("www.ruby-
lang.org", 80) }
# Before patch: 2.3 sec.
# After ptach: 3.0 sec.
100.times {
URI.open("https://www.ruby-lang.org").read }
# Before patch: 3.36 sec.
# After ptach: 3.40 sec.My impression is that everything was migrated to be asynchronous by default, unlike in Python where all of these operations were reimplemented in the async "color". Is that true?
I find Ruby fascinating yet difficult.
If you’re fluent in Node and Python it should be quite easy to learn. The downside is it’s not going to do anything fundamentally new for you coming from those languages. The upside is mostly aesthetic, Ruby offers and encourages really beautiful ways of expressing code, and it’s neat to experience that.
Ruby has iterators/generators. It doesn't have first-class functions because it doesn't have functions at all, but blocks/procs serve the same purposes.
It seems to me that Python still has these holdovers from when it was not fully object-oriented, where a lot of string and data structure manipulation is done with language-level functions rather than methods on the objects, which can be quite confusing.
Another issue I had was that Python's test frameworks like PyTest were just so weak compared to the likes of MiniTest and RSpec.
can you elaborate on what you miss here? ruby has a robust enumerable suite of methods so i'm curious what you found lacking
I'd love to hear what makes you say this - none of it is meaningfully true (ruby doesn't have functions, but it has blocks and callables).
It has:
Add to this also Shopify, Github, Gitlab, Basecamp and some others and you will see that Ruby can be use for more than shell scripting and data munging. Yes they are Rails but Rails is written in Ruby so they are Ruby.
Ruby is also very fun, probably the most fun language I’ve used regularly. That makes it its own reward.
Then add in something like Pry or Irb, where you are able to build castles in your sandbox.
Most of my data exploration happens in Pry.
A final book I’ll toss out is Data Science at the Command Line, in particular the first 40 or so pages. They highlight the amount of tooling that exists that’s just python shell scripts posing as bins. (Ruby of course has every bit of the same potential.) I had always been aware of this, but I found the way it was presented to be very inspirational, and largely transformed how I work with data.
A good practical example I use regularly is: I have a project set up that keeps connection strings for ten or so SQL Server DBs that I regularly interact with. I have constants defined to expedite connections. The [Sequel library](https://sequel.jeremyevans.net/) is absolutely delightful to use. I have a `bin/console` file that sets up a pry session hooking up the default environment and tools I like to work with. Now it’s very easy to find tables with certain names, schemas, containing certain data, certain sprocs, mass update definitions across our entire system.
``` # Something failed, and not everything loaded as you expected # explore explore explore…
db::CompetitorPricing.tables
db::CompetitorPricing.tables.grep(/^pricing_/)
latest = DB::CompetitorPricing.tables.grep(/^pricing_/).map {|table| [table, table.max(:create_ts)}
latest = latest.sort_by(&:last)
# serialize to csv, or json, or perhaps copy the data into excel:
Clipboard.copy latest.map{ _1.join("\t")}.join("\n") ```
Just like with work in the shell, you have a really easy time iteratively exploring the problem and building up your answer. The ability to serialize your data you’ve found, and keep your favorite tools in your pocket feels extremely productive. And of course, all of this can be written in ruby 1-liner shell scripts, or more complex shell scripts to pipe in and out of other tools if desired.
The most interesting part IMO is how it's so similar to Python along many categories, but also so different.
Biggest example is how Ruby just loves Blocks. They're all over the place in the std lib, tons of syntax sugar for them, and countless DSLs built around them. All the standard functional stuff is there in the std lib and has been from very early on, so doing functional-style stuff is really smooth and reads well. In Python, you can technically do most of the same stuff, but it all seems a lot more awkward to write and to read (though maybe just my opinion from doing Ruby first). Python has lambdas, but it doesn't seem to like them much for more than trivial things. But instead functions are first-class everywhere.
This introduction about a framework built with ruby and not ruby itself was necessary because even today, I would guess that 95% of all development with ruby is RoR applications. It's my understanding that ruby rose to prominence mostly because of ruby on rails, now that RoR is in a downward trend I think ruby will follow the same trend until it's reduced to a small community of enthusiasts in the same way that happened to perl.
As for the language itself I can't think of a single reason to opt for ruby over python or typescript. Ruby doesn't do anything better both in terms of language or platform than its already better established competitors.
I'll bite.
Even at the most basic level of built in functions/methods (String, Array, Hash) - I found Ruby's to blow Python's out of the water.
https://ruby-doc.org/core-2.5.1/String.html
https://www.w3schools.com/python/python_ref_string.asp
Even Python's choice of naming and syntax to use these basic functions just hasn't been thought through as much as Ruby's implementation. There's a reason it's called the language of Developer happiness.
Ruby's community I've found is more focused on best engineering practices (like testing) than others, which is perhaps why RSpec and MiniTest are fantastic frameworks. The likes of PyTest doesn't even compare to what those two offer.
Plenty of reason above to use Ruby, and we haven't even got to Rails yet.
With the recent additions of the prefix/suffix methods I have no desire for any more.
https://docs.python.org/3/library/stdtypes.html#string-metho...
Meh. Been in the industry longer enough to not care about Developer happiness but more about solving problems quickly.
Your developer happiness ain't necessary mine just like some people prefer the cuteness of Ruby and other prefers the strictness/patterns of Java.
And there is a lot more: new conferences, new books and new gems.
(Shameless plug: I curate a newsletter called Short Ruby that covers news from Ruby world every week).
Maybe Ruby is not at the level where is was in 2007-2009 but it is also NOT in a downward trend.
It's not only that ruby and ruby on rails are trending down, this has been the case for at least 10 years.
https://berk.es/2022/03/08/the-waning-of-ruby-and-rails/
This is only an article, but you will find the same point of view in many other places. The decline of ruby and RoR is obvious for anyone doing web development. Python is only getting stronger, Typescript the same, not to mention the statically typed competitors like Java with Spring Boot.
I wouldn't doubt that even languages like Go and Rust might surpass ruby soon in web development because as general purpose languages they are already more relevant.
I'm a former RoR developer and I took off the keywords ruby and ruby on rails from my curriculum because for me professionally it makes no sense to invest time in them.
https://trends.google.com/trends/explore?date=all&q=Ruby%20o...
Ruby got nothing else bigger than Rails unfortunately no matter how people in that community is hyping Ruby out.
It's okay if Ruby and Rails on a downward trend it might pick up again in the future.
C'mon now, we all know that our industry is like a Fashion industry.
The only reason why Rails is making a comeback is because we're in tough time: no more VC money to hire tons of Engineers to build a web-app.
When money was flowing, folks tend to build over-engineered solution (microservice, mesos, container, k8s, cloud-y orchestration), when money is tight, folks tend to build simple stuff because of lack of resources.
It's really sad if that's the case. What's replacing it (mostly JS/TS everywhere, relying on PaaS) really isn't as fun.
For me, coming from more of a Ruby background, I found Python and Node to not be too hard to understand, and my only nitpick would be on how eggs/packages were managed and dealing with dependancies.
In particular, Python dependancies compared to Ruby dependancies were more challenging initially for me. I’ve grown to appreciate Python indents and find it nice to read, but that was also annoying at first.
Ruby itself is not the issue. The way people and frameworks (looking at you Rails) abuse its mechanics in pursuit of “clean code” drives me crazy. An incredible number of things are downright challenging to debug because of the insane flexibility of Ruby.
I wouldn't use NodeJS to build web-app that fits Rails. NodeJS ecosystem feels like building on a house of cards though.
Python feels alot cleaner, but I wouldn't pick it over Node for web UI automation or Rest API testing.
NodeJS does not attract the kind of people who build ElasticSearch, Kafka, Hadoop, Spring Framework, etc so the quality of the libraries reflected of that the Web Developers crowd: the short-term Do-ers (need it today, let's build it, and let's move on to the next interesting stuff).
Shouldn't the default be the number of logical cores? Like Rust's Tokio and countless other M:N runtimes
On paper it’s awkward, but in reality convention and social norms make it rarely an issue.
The global namespace only supporting exactly one version of each gem encourages a health culture of stable ABIs and deprecation periods too. An absolute dream compared to some language ecosystems
Or I'm speaking out of my ear and completely wrong (and I don't know which :D)
If anything Rails autoloading (Zeitwerk really) make it much easier to find where constants come from as it enforce a constant name -> file name convention, so all you need is fuzzy file search.
Ruby imports have always used a single global namespace. I'm not convinced that this is an issue in practice - it's worked just fine for several other languages.
I used to be a huge Ruby fan but having exposure to Python where this isn't an issue, life is just easier.
It looks like a big leap, but when you compare the actual speed to _any_ other language you realize Ruby still has many, many percent to go to even be in the same game.
If you look at CPU bound micro-benchmarks like most similar announcements uses, you easily get into the 3x territory: https://railsatscale.com/2023-12-04-ruby-3-3-s-yjit-faster-w...
Where are you seeing 3x improvement?
Because even this graph from your article doesn’t show that, unless you’re comparing JIT vs non-JIT. But JIT has existed for awhile now (not new in 3.3).
https://railsatscale.com/2023-12-04-ruby-3-3-s-yjit-faster-w...
But my point is that the YJIT team never really communicate numbers from synthetic benchmarks, it's very focused on real world workloads.
Synthetic benchmarks are used internally, but mostly to optimize a specific pattern that was identified as a common hotspot.
All this to say this figure you quote is not to be directly compared to many similar announcements from other projects or benchmark suites.
Now if you still think it's not good enough, I encourage you to try your hand at it to see how much of an accomplishment that really is.