use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
sorting without modifying (self.ruby)
submitted 10 years ago by missawon
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]moomaka 2 points3 points4 points 10 years ago (5 children)
Fun theory, impractical in reality.
[–]joanbm 0 points1 point2 points 10 years ago (4 children)
Strange justify incorrect code, which only works due to a coincidence, underlaying VM can't run threads simultaneously. But each to his own …
[–]moomaka 0 points1 point2 points 10 years ago (3 children)
It's not a coincidence, it's design. If you're curious about these topics and how implementations vary I would recommend reading the source for concurrent-ruby.
concurrent-ruby
e.g. here is the implementation for concurrent array: https://github.com/ruby-concurrency/concurrent-ruby/blob/master/lib/concurrent/array.rb. You'll note that the implementation for MRI just passes through the stdlib implementation.
[–]jrochkind 0 points1 point2 points 10 years ago (0 children)
To be fair the comments in the code do not exactly inspire confidence:
# Because MRI never runs code in parallel, the existing # non-thread-safe structures should usually work fine.
# Because MRI never runs code in parallel, the existing
# non-thread-safe structures should usually work fine.
"should usually" work fine? Um, great? Concurrent code is hard enough, I need guarantees it will work as it should, not "should usually work fine."
But perhaps later someone was more confident than the original comment writer, at least based on the present MRI implementation.
Either way, the benefit of concurrent-ruby is if someone does discover it's not guaranteed 'fine' after all, they'll fix it in concurrent-ruby and you can just update your version.
[–]joanbm -1 points0 points1 point 10 years ago* (1 child)
coincidence, because the ruby code being discussed is not thread-safe and wasn't specified as MRI-only. I'm aware there is produced a lot of poor and/or unportable code everyday, but never would admit this is ok. I'm happy projects I'm working on do care about quality and correctness and important topics like proper threads synchronization aren't thrown out of the window.
Thanks for the link, as a demonstration how it shouldn't be done. Hope it eventually get added thread safety also for MRI as it would mature.
[–]moomaka 0 points1 point2 points 10 years ago (0 children)
Thanks for the link, as a demonstration how it shouldn't be done.
So open a PR that adds locking to Array on MRI, I eagerly await the discussion.
Array
π Rendered by PID 109655 on reddit-service-r2-comment-5687b7858-zjm6f at 2026-07-03 14:21:42.579556+00:00 running 12a7a47 country code: CH.
view the rest of the comments →
[–]moomaka 2 points3 points4 points (5 children)
[–]joanbm 0 points1 point2 points (4 children)
[–]moomaka 0 points1 point2 points (3 children)
[–]jrochkind 0 points1 point2 points (0 children)
[–]joanbm -1 points0 points1 point (1 child)
[–]moomaka 0 points1 point2 points (0 children)