About.com http://ruby.about.com/
Get the latest headlines from the About.com About.comhttp://clk.about.com/?zi=1/1hhhttp://www.about.com/
11820en-us2014-05-31T22:03:47ZSat, 31 May 2014 22:03:47 +0000hourly12000-01-01T12:00+00:00Threading in Rubyhttp://ruby.about.com/b/2014/05/31/threading-in-ruby.htm
<p>Threading in Ruby gets a bit of a bad rap. &#160;While MRI doesn't support full threads, only one Ruby thread can be actively running at the same time, other Ruby implementations (such as JRuby) can run threads fully concurrently, and even MRI supports concurrency in IO-bound tasks. &#160;The following are three articles that may help you understand threading in Ruby.</p>...<p><a href="http://clk.about.com/?zi=1/1hc&#038;zu=http://ruby.about.com/b/2014/05/31/threading-in-ruby.htm">Read Full Post</a></p>http://ruby.about.com/b/2014/05/31/threading-in-ruby.htmSat, 31 May 2014 22:11:48 +00002014-05-31T22:11:48ZMutexes in Rubyhttp://ruby.about.com/b/2014/05/31/mutexes-in-ruby.htm
<p>Since we're talking about threads, we <em>have</em> to talk about mutexes. &#160;A Mutex is the only practical way to prevent race conditions (where more than one thread tries to access a resource at the same time). &#160;A mutex is not a complicated (though it is nuanced) thing, and <a href="http://clk.about.com/?zi=1/1hc&#038;zu=http://ruby.about.com/od/advancedruby/fl/Mutexes.htm">Ruby implements Mutexes in a rather simple way</a>.</p>http://ruby.about.com/b/2014/05/31/mutexes-in-ruby.htmSat, 31 May 2014 22:03:47 +00002014-05-31T22:03:47ZThread Pools in Rubyhttp://ruby.about.com/b/2014/05/31/thread-pools-in-ruby.htm
<p>A common pattern in programs that must complete a large number of jobs is to use a thread pool, a type of producer/consumer model. &#160;Say, for example, you have to download 500 files. &#160;One way to do this is to take the URL for each file in turn, download the file, and move onto the next, but that's very slow. &#160;Another way is to fire up 500 threads, one of each file and just let the OS sort it out but that's both inefficient and rude (you shouldn't "thrash" we servers like that). &#160;So, instead, make a thread pool. &#160;You have 500 files to download, but you only want 3 to download concurrently. &#160;<a href="http://clk.about.com/?zi=1/1hc&#038;zu=http://ruby.about.com/od/advancedruby/fl/Thread-Pools.htm">What you really want is a thread pool</a>.</p>http://ruby.about.com/b/2014/05/31/thread-pools-in-ruby.htmSat, 31 May 2014 22:01:22 +00002014-05-31T22:01:22ZThreads in Rubyhttp://ruby.about.com/b/2014/05/31/threads-in-ruby.htm
<p>Ruby does have threads, however the threading support in MRI (the most widely used Ruby interpreter) is not complete. &#160;It supports concurrency for IO-bound tasks, but since only one Ruby thread may execute at a time, CPU-bound tasks cannot be run concurrently on Ruby's MRI interpreter. &#160;Nonetheless, <a href="http://clk.about.com/?zi=1/1hc&#038;zu=http://ruby.about.com/od/advancedruby/fl/Threads.htm">Ruby does have threads, and this is how you use them</a>.</p>http://ruby.about.com/b/2014/05/31/threads-in-ruby.htmSat, 31 May 2014 21:58:57 +00002014-05-31T21:58:57ZConditional Assignmentshttp://ruby.about.com/b/2014/04/30/conditional-assignments.htm
<p>Ruby has its roots in Perl (or at least one of its roots) and <a href="http://clk.about.com/?zi=1/1hc&#038;zu=/od/beginningruby/fl/Conditional-Assignments.htm">conditional assignments</a> are one Perlism that Ruby brought along with it. &#160;A conditional assignment allows you to assign (or not assign) a value to a variable depending on the truthiness of the value currently held in the variable. &#160;Though these constructs can be replaced with simple conditional statements, they're still in wide use today.</p>http://ruby.about.com/b/2014/04/30/conditional-assignments.htmWed, 30 Apr 2014 21:42:38 +00002014-04-30T21:42:38ZSignalshttp://ruby.about.com/b/2014/04/30/signals.htm
<p>Signals are an interprocess communication primitive used in UNIX-like operating systems (mostly Linux and OS X in the Ruby world). &#160;They're used primarily to inform a program it's being shut down. &#160;There are things you can do to prevent the shut down, however, and other uses for signals than shutting preventing a shut down.</p>...<p><a href="http://clk.about.com/?zi=1/1hc&#038;zu=http://ruby.about.com/b/2014/04/30/signals.htm">Read Full Post</a></p>http://ruby.about.com/b/2014/04/30/signals.htmWed, 30 Apr 2014 21:40:39 +00002014-04-30T21:40:39ZFibershttp://ruby.about.com/b/2014/04/30/fibers.htm
<p>Threading in Ruby has always been a bit of a nonstarter. &#160;Early on, there was the global interpreter lock, and even now concurrency is not really a thing in MRI (though it's truly concurrent on jRuby). &#160;However, there is another concurrency model: cooperating multitasking. &#160;It's not used much, but it can be an interesting way to segment you code. &#160;Cooperating multitasking is implemented in Ruby using <a href="http://clk.about.com/?zi=1/1hc&#038;zu=/od/advancedruby/fl/Fibers.htm">Fibers</a>.</p>http://ruby.about.com/b/2014/04/30/fibers.htmWed, 30 Apr 2014 21:38:54 +00002014-04-30T21:38:54ZCloning 2048 in Rubyhttp://ruby.about.com/b/2014/03/31/cloning-2048-in-ruby.htm
<p>2048 is the newest game to really go viral. No one even remembers Flappy Bird anymore, now it's all 2048 all day long. So what is 2048? It's a sliding puzzle game you can&#160;<a href="http://gabrielecirulli.github.io/2048/" target="_blank">play here</a>...<p><a href="http://clk.about.com/?zi=1/1hc&#038;zu=http://ruby.about.com/b/2014/03/31/cloning-2048-in-ruby.htm">Read Full Post</a></p>http://ruby.about.com/b/2014/03/31/cloning-2048-in-ruby.htmMon, 31 Mar 2014 21:22:32 +00002014-03-31T21:22:32ZCloning 2048 in Ruby: The Final Few Methodshttp://ruby.about.com/b/2014/03/31/cloning-2048-in-ruby-the-final-few-methods.htm
<p>All the important methods were already talked about in the previous articles. We really need to talk about spawning new cells and seeing if we've met the game over condition though.</p>...<p><a href="http://clk.about.com/?zi=1/1hc&#038;zu=http://ruby.about.com/b/2014/03/31/cloning-2048-in-ruby-the-final-few-methods.htm">Read Full Post</a></p>http://ruby.about.com/b/2014/03/31/cloning-2048-in-ruby-the-final-few-methods.htmMon, 31 Mar 2014 21:21:44 +00002014-03-31T21:21:44ZCloning 2048 in Ruby: The Core Algorithmhttp://ruby.about.com/b/2014/03/31/cloning-2048-in-ruby-the-core-algorithm.htm
<p>The slide method is the core of the whole 2048 game. It slides all the rows to the left, collapsing any empty tiles and combining any adjacent tiles with the same value. Remember that this method&#160;<em>only</em>slides the puzzles to the left. In order to slide the puzzle to the right, you need to rotate the puzzle twice (so it's essentially upside down, and left is right), slide the tiles and rotate the puzzle twice again. Similarly, to move up and down you rotate, slide and rotate again (always completing four rotations total).</p>...<p><a href="http://clk.about.com/?zi=1/1hc&#038;zu=http://ruby.about.com/b/2014/03/31/cloning-2048-in-ruby-the-core-algorithm.htm">Read Full Post</a></p>http://ruby.about.com/b/2014/03/31/cloning-2048-in-ruby-the-core-algorithm.htmMon, 31 Mar 2014 21:21:00 +00002014-03-31T21:21:00Z