Yesterday I read this great article about Concurrency in JRuby from EngineYard and I realise I need to leverage my skills about concurrency in Ruby, by mentioning Ruby here I mean it could be all implementations of Ruby : JRuby, Ruby MRI, Rubinius, Ruby on Parrot / Cardinal except IronRuby, I don't code in Windows Environment.

What I learned from Haskell world, especially from Simon Peyton-Jones, he said on his video that OOP is all about state.

Note: I'm very very inexperienced when I mention Haskell, I only watched some good videos about Haskell, solved very few (less than 10) euler project in Haskell, read some good Haskell books and tutorials, I've never coded in Haskell professionally, I just read some source codes in Haskell, ex. pugs, Darcs, and some other Haskell codes I don't remember the source.

I might want to use Jaskell to trick concurrency as long as I use jruby, but that's for my long term learning plan, I want to maximise my concurrency skill in ruby first, do you have any suggestions for me to learn concurrency in ruby? I wish there were a kind of Head First book for me to learn Concurrency in Ruby. Things like strategies / how to tackle concurrency problem in ruby, inspired from EngineYard article and Haskell. Maybe some good downloadable videos that explain step by step to strengthen my fundamental about concurrency generally and then move to concurrency in ruby specifically.

Advice? Thank you.

  • OOP is all about state -- I'm not going to go through the whole video, but what Simon probably meant was that OOP is typically about mutable state, or state that changes over time. All programming languages have state, but Haskell (being a purely functional programming language) has immutable state (monads being the notable exception). Immutable state (basically meaning functions that do not cause side effects, but merely return a value) make concurrent programming much easier. It is possible to write OOP programs in an immutable way. Jul 24, 2011 at 0:43

1 Answer 1


To get you started, first read Ruby concurrency explained to get an overview. Do note that the Ruby community, in general, seems to find concurrency to be a new and controversial topic and that folks argue vehemently and incessantly over many details regarding how it should be implemented in or via Ruby. Seek fundamentals and do not get caught up in argumentative trivia!

One recommendation towards clarity is to mentally separate the idea of concurrency from multi-threading, which is only one implementation method. Threading is one way of implementing concurrency but there are others; in particular, look at process parallelism as mentioned in Concurrency is a Myth in Ruby.

the Actor Model approach to concurrency is implemented through many languages, now, and Ruby Concurrency with Actors gives a gentle introduction to how actors may be implemented via Ruby. Actors can simplify concurrency in many cases and can help you avoid some of the nastier pitfalls.

The Ruby community has implemented a Fiber class to provide "light weight cooperative concurrency" in Ruby. You will definitely want to follow some of the links in Ruby Fibers: 8 Useful Reads On Ruby’s New Concurrency Feature to understand this new addition to the language.

Be aware that, as Engine Yard explained, JRuby and Ruby operate on different virtual machines and that these differences may have huge implications for concurrency implementations, in terms of what both what may be possible as well as how it may be achieved.

Yours is a valuable question as Ruby is just now entering the concurrent domain and you can be an "early adopter!" Good luck on your worthy quest!

  • thanks for your answer, I appreciate it, I'll look into references you mentioned.
    – Arie
    Sep 26, 2011 at 22:42
  • 1
    Actors are a great way to with these sort of issues. I have used actors in multiple projects (not ruby though) to great success.
    – Travis
    Sep 27, 2011 at 2:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.