#367 Celluloid pro
Jul 18, 2012 | 11 minutes |
Tools
Celluloid puts an object-oriented spin on multi-threaded development. Here I cover the fundamental features of Celluloid in several examples.
- Download:
- source codeProject Files in Zip (1.17 KB)
- mp4Full Size H.264 Video (26 MB)
- m4vSmaller H.264 Video (12.7 MB)
- webmFull Size VP8 Video (14.2 MB)
- ogvFull Size Theora Video (25.4 MB)
Thank you for this awesome episode.
This has really impressed me and I want to see more of this.
My head is spinning a little... thinking of all the things that could be done with this. Thanks - excellent episode.
I had never seen the $* for creating av array. What is the difference form using []?
When you see any version of "$" it will refer to a global variable in Ruby. The global variable "$*" refers to the command line arguments passed into the program. (In this case the urls of the rss feeds.) It is not the same as simply declaring an array.
All the shell scripts are using "$" as a reference to some vars.
Thank so much Ryan for this and all other episodes!!!! I would like to see more about concurrency! Maybe differences between MRI and JRuby? Threads, forking and so on?
This was awesome celluloid reminds me alot of Erlang
The author wanted to give Ruby some of the features of Erlang. Check out the interview with him on The Changelog where he talks about Celluloid. The Changelog Episode .0.8.1. Great podcast!
Great episode, Ryan! It would be cool to see more on concurrency. :)
This reminds me of Eventmachine. Would Celluloid be something that could replace Eventmachine in the future?
Programming with it seams a lot easier than EM.
evented is not the same as threaded they have differente uses. Evented uses less resources too.
true, good point. Thanks!
Very enlightening stuff on concurrency lately.
Will you cover some of the things that can be done for Rails? Like Rack::FiberPool?
Celluloid is really impressive (configurable concurrency solution) based on what i have seen so far.. a good option for ruby projects.. reducing or zero the learning curve or adoption of the likes of Scala (AKKA) or Erlang etc.. awesome.. soon, gone will be the days when ruby would be mocked for concurrency..
It is awesome, Ryan, I am impressed by celluloid.
Not convinced about this project -- think it would be good for folks that have a lot experience with Threads and like this new nifty syntax. But i think it abstracts a lot of core concepts (Creating Threads, join(), Mutexs, blocking) that people new to concurrency should experience first hand before trying this.
Nice one! Thanks for doing this episode.
Wow - supervisors. There's Erlang in my Ruby! I'd like to learn more about Celluloid.
Indeed, I had flashbacks to my programming languages class. By flashbacks, I mean shots of adrenaline and joy.
Will this work on Heroku? Does this mean I don't need all those Dynos?
Something to keep in mind when trying Celluloid on Heroku is memory usage.
Heroku will restart your processes if they use too much memory, so you'll want to experiment to find the number of threads you can run, that depends on your work load.
I found this when working on heroku with girl_friday. It worked, but it crashed frequently due to memory limits.
"…an example that's a little more practical than launching rockets."
Some would argue there are few things more practical than launching rockets!
AWESOME !
Ryan, you may want to mention this bug since you're using IRB to demonstrate celluloid: https://github.com/celluloid/celluloid/issues/22
Were Rocket to have an ivar reference back to Launcher, calling #inspect causes an infinite loop. I thought I just wasn't getting it, but everything works fine when I override #inspect in my actor classes. That's several hours of my life I wish I could have back. =)
Great episode.
How do celluloid actors mix with rails, especially active record?
For concurrent processing check Parallel gem also: https://github.com/grosser/parallel
I just thought it's worth noting that the API has changed and rightly so, since the implementation of asynchronous calls by bang method clashed in projects that have used bang methods heavily .
https://github.com/celluloid/celluloid/commit/946eeb81
To Tobias point:
For whatever reason the launch! method didn't work for me. I used the syntax I found at https://github.com/celluloid/celluloid/wiki/Basic-usage: r.async.launch
When I tried to use r.launch! I got:
NoMethodError: undefined method `launch!' for #
Yes, this railscast is for Celluloid v0.11.1, the latest version is 0.15.2 where they have changed the way dispatching method calls. It either needs an update or a warning stating the version.