<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>The Vose Way: Concurrent code in Ruby 1.8.6 through inlining</title>
    <link>http://www.chuckvose.com/articles/2008/01/07/concurrent-code-in-ruby-1-8-6-through-inlining</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>A Blog about Butter, Cheese, and Ruby on Rails</description>
    <item>
      <title>Concurrent code in Ruby 1.8.6 through inlining</title>
      <description>&lt;p&gt;&lt;strong&gt;Slight typo in the code fixed: 2008-01-08&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;Toshiyuki and I have released a new gem called rbridge which allows us to execute functional, side-effect free, concurrent code directly in Ruby regardless of the version by using Erlang as a processor. This includes using the Mnesia distributed database and &lt;span class="caps"&gt;ETS&lt;/span&gt;/DETS.&lt;/p&gt;


	&lt;p&gt;To try it out please follow these steps:&lt;/p&gt;


	&lt;p&gt;1. Download Erlang for your os. Windows has binaries and &lt;span class="caps"&gt;OS X&lt;/span&gt; can be configured with `./configure&amp;#8212;prefix=/opt/local` to make MacParts happy. I haven&amp;#8217;t yet tried it with Linux but the default configure options should be okay.&lt;/p&gt;


	&lt;p&gt;2. Download the rbridge gem. `sudo gem install rbridge`&lt;/p&gt;


	&lt;p&gt;3. Start the rulang server in Erlang on port 9900. Change dir to the gem directory which is usually /usr/local/lib/ruby/gems/1.8/gems/rbridge-0.1/lib and run &lt;strong&gt;sudo erlc rulang.erl&lt;/strong&gt;. Enter the Erlang shell by typing &lt;strong&gt;erl&lt;/strong&gt;. Finally, start the server with &lt;strong&gt;rulang:start_server(9900).&lt;/strong&gt; (There&amp;#8217;s a dot at the end of the command).&lt;/p&gt;


	&lt;p&gt;4. Require rubygems and rbridge in your code and create a new connection to the rulang server. This is the simplest bit of inline code I can think of but there is a lot more we can do: asynchronous access and ruby-style syntax specifically.&lt;/p&gt;


&lt;pre&gt;
require 'rubygems'
require 'rbridge'

@r = RBridge.new(nil, 'localhost', 9900)

puts @r.erl('10*10.')
&lt;/pre&gt;

	&lt;p&gt;To read more check out the documentation on &lt;a href="http://ruby-mnesia.rubyforge.org"&gt;ruby-mnesia.rubyforge.org&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Aside:&lt;/strong&gt; Toshiyuki Hirooka found me. Thank you to everyone that helped search and offered to translate for us. I&amp;#8217;m constantly impressed by the support from the Ruby community.&lt;/p&gt;</description>
      <pubDate>Mon, 07 Jan 2008 13:11:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:dd7dc46a-8bfa-4828-bcc9-2136ee24bd1b</guid>
      <author>vosechu@create-on.com (Chuck Vose)</author>
      <link>http://www.chuckvose.com/articles/2008/01/07/concurrent-code-in-ruby-1-8-6-through-inlining</link>
      <category>Ruby</category>
      <category>Erlang</category>
      <category>Ruby</category>
      <category>Erlang</category>
      <category>rbridge</category>
      <category>rulang</category>
      <category>gems</category>
    </item>
  </channel>
</rss>
