<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>The Napkin ~ A Blog By Highgroove Studios comments on Writing Ruby Extensions in C the Highgroove Way</title>
    <link>http://napkin.highgroove.com/</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>The Napkin ~ A Blog By Highgroove Studios comments</description>
    <item>
      <title>"Writing Ruby Extensions in C the Highgroove Way" by mtodd</title>
      <description>&lt;p&gt;Trying to handle image manipulation, creating PDFs, or in-memory caching in pure Ruby is like trying to win the Tour de France on your hipster single-speed bike. The single-speed works 90% of the time, but when you have demanding performance requirements, it&amp;#8217;s not good enough. Many popular Ruby libraries, such as MySQL/PostgreSQL, RMagick, and most of the webservers Ruby applications are deployed on (like Passenger, Mongrel, and Thin), harness the blazing speed of the C language and libraries to handle the heavy lifting and performance-intensive business that Ruby can&amp;#8217;t keep up with on its own.&lt;/p&gt;


	&lt;p&gt;In some of my recent work, I had the opportunity to delve into and expand on a Ruby extension written in C for looking up geographic information based on IPs. This library was vital to one of our client&amp;#8217;s projects that has immense performance requirements without the possibility of full request caching. By utilizing the existing GeoIP C library for accessing their special in-memory binary database, we were able to keep up with the demand the application would be seeing.&lt;/p&gt;


	&lt;p&gt;As is common at Highgroove Studios, along with making sure our contributions to the library were open sourced, I took the lessons and experience gained from this unusual endeavor and presented them to our local Ruby User Group here in Atlanta. I focused more on exposing the bridge between the Ruby and the C environments and understanding the internals of the Ruby language from a C standpoint. However, armed with this knowledge, any Rubyist is able to open up most any Ruby extension or even the Ruby language implementation itself and understand what&amp;#8217;s going on. My goal was to get the developers over the initial hurdle of being able to read the code and understand it enough to investigate further.&lt;/p&gt;


	&lt;p&gt;Personally, I gained from this experience a better appreciation for the real beauty of the Ruby language and the effort required to make it as fluid and dynamic as it is as well as having a more thorough understanding of the internal workings of the language. Working this close to the language core has also made a difference on my Ruby style, both in trying to fight the language less but to also use it more efficiently and effectively.&lt;/p&gt;


	&lt;p&gt;For more information, check out the presentation slides&lt;sup&gt;&lt;a href="#fn1"&gt;1&lt;/a&gt;&lt;/sup&gt; and some of the C examples I wrote for the presentation&lt;sup&gt;&lt;a href="#fn2"&gt;2&lt;/a&gt;&lt;/sup&gt;. Also check out the GeoIP I contributed to which inspired this whole adventure&lt;sup&gt;&lt;a href="#fn3"&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;


	&lt;p id="fn1"&gt;&lt;sup&gt;1&lt;/sup&gt; &lt;a href="http://www.slideshare.net/maraby/writing-ruby-extensions"&gt;http://www.slideshare.net/maraby/writing-ruby-extensions&lt;/a&gt;&lt;/p&gt;


	&lt;p id="fn2"&gt;&lt;sup&gt;2&lt;/sup&gt; &lt;a href="http://github.com/mtodd/ruby-c"&gt;http://github.com/mtodd/ruby-c&lt;/a&gt;&lt;/p&gt;


	&lt;p id="fn3"&gt;&lt;sup&gt;3&lt;/sup&gt; &lt;a href="http://github.com/mtodd/geoip"&gt;http://github.com/mtodd/geoip&lt;/a&gt;&lt;/p&gt;

</description>
      <pubDate>Fri, 10 Jul 2009 13:56:00 EST</pubDate>
      <guid>&lt;a href="/articles/2009/07/10/writing-ruby-extensions-in-c-the-highgroove-way"&gt;Writing Ruby Extensions in C the Highgroove Way&lt;/a&gt;</guid>
      <link>&lt;a href="/articles/2009/07/10/writing-ruby-extensions-in-c-the-highgroove-way"&gt;Writing Ruby Extensions in C the Highgroove Way&lt;/a&gt;</link>
    </item>
  </channel>
</rss>
