Or You Can Cheat

Posted by Jacob Harris Wed, 27 Sep 2006 20:08:00 GMT

Wow, long time no blog. Work and home life have just sucked all the mental energy out of me lately. For those of you who still have kept me in your feedrolls or click here from time to time, I have a new set of slides presented for your personal enjoyment.

Last week—transfixed by the horror of an empty slate of speakers—I decided it was time to give another talk to the NYC.rb and so I spent a few days throwing together a presentation I titled Or You Can Cheat. It’s all about how you can write C extensions for Ruby and also how this something you shouldn’t undertake lightly. I have a very interesting approach to presentations: when I want to learn more about a subject, I throw together a presentation on it. I think the combination of casual interest and the abject fear of humiliation in front of my peers is a great personal motivational tool. This talk continues that trend, and while I can not claim to be a definitive expert on C extensions for Ruby, I certainly know a lot more about the subject now and I think you will too.

If you are interested, you can download the talk here

Or You Can Cheat (600K PDF)

This is a bit more silly and off-the-cuff than Rubyisms in Rails, and I really enjoyed it. There are a few references I should clarify though. First, there is the matter of arepas. The arepa is the official food of NYC.rb and it is a rite of passage here to take visiting Ruby eminences to our official supplier, the Caracas Arepa Bar. Asides from being addictively tasty, arepas serve as a perfect metaphor for Ruby extensions, in that they wrap the tasty ingredients inside a pragmatic corn flour shell. They really are that tasty. Yes, I also suppose I was a bit harsh calling Joel Spolsky a troll, but I had no other term to describe his wild extrapolation that current Ruby interpreter performance augurs that Ruby will always be slow, that Rails is a horrible web development framework, and how you should shackle your entire development environment around the slowest part. But he is right that Ruby currently is slow for some uses, and C exensions are a potent way to resolve those edge cases without throwing in the towel.

And yet, I hope you’re not dropping everything to write them.

Why the lukewarm recommendation? Well, I think Ruby performance has become an all-purpose scapegoat these days. In some cases, this is deserved (we need YARV. Now.), but it’s all too easy to blame Ruby when the real problem is your web server, your database, or some stupid algorithm you wrote that’s wildly inefficient. Rule all that out first before you dive into C extensions for Ruby. Because C is dangerous, C is tricky, and C is just plain no fun. C extensions can be like eating an arepa filled with broken glass if you aren’t careful. But they also are a useful tool for performance and especially for wrapping existing libraries and legacy code.

Which gets me wondering if there are any cool killer apps for C extensions and Ruby. Are there some cool open-source libraries that would be nice with Ruby bindings? How cool would could a combination of Starfish and RubyInline really be? Would we need to use C extensions to create rbsh, a Ruby shell? What other fun things could you do if you had nice Ruby tongs to keep that nasty C code at bay? Let me know if you have any awesome ideas and if you enjoyed these slides. And in return, I’ll try to see if I can actually blog again one of these days. Thanks.

Posted in  | Tags , ,  | no comments

Comments

(leave url/email »)

   Preview comment