Ruby Threads
Just wanted to echo something I sent via email, but Tim’s right Ruby threads are weak, in fact I’d call them a toy. Key problems:
- slow as hell, threads tend to die unexpectedly
- documentation and sample code limited to a handful of pages in the Pickaxe (lack of people using should have been clue #1)
- non-OO (in Ruby! an int in Ruby is an object!), all examples use code blocks, subclassing Thread can have unexpected (to me, with my Java threading biases) results
- many core libraries, and more painfully (in that I lost several weeks of my life, and some hair) ActiveRecord aren’t thread safe.
All from my experience of trying of writing a threaded RSS poller for Odeo that reused the model objects from the webapp. In short, fork() is your friend.
I’m hoping that Ruby 2.0 with Rite/YARV, the new threadsafe virtual machine will solve this. In the meantime there is, JRuby, I suppose. But I’ve got a lot less invested in Java then Tim does.