<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>gnuu.org</title>
	<atom:link href="http://gnuu.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://gnuu.org</link>
	<description>my word against yours, fight.</description>
	<lastBuildDate>Wed, 17 Jun 2009 06:10:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>YARD at Montreal.rb</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/MaosWn-lcWs/</link>
		<comments>http://gnuu.org/2009/06/17/yard-at-montreal-rb/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 06:05:30 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[Montreal.rb]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[yard]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/06/17/yard-at-montreal-rb/</guid>
		<description><![CDATA[I gave a talk today at Montreal.rb. It was great to see people interested in improving Ruby documentation. You can read the slides below (direct link).
]]></description>
			<content:encoded><![CDATA[<p>I gave a talk today at <a href="http://montrealonrails.com">Montreal.rb</a>. It was great to see people interested in improving Ruby documentation. You can read the slides below (<a href="http://gnuu.org/wp-content/uploads/2009/06/yard.pdf">direct link</a>).</p>
<p></p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/MaosWn-lcWs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/06/17/yard-at-montreal-rb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/06/17/yard-at-montreal-rb/</feedburner:origLink></item>
		<item>
		<title>Installing Ruby 1.8 and 1.9 Side by Side</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/JOESgd-rI3U/</link>
		<comments>http://gnuu.org/2009/06/14/installing-ruby-1-8-1-9-side-by-side/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 22:38:23 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[1.8]]></category>
		<category><![CDATA[1.9]]></category>
		<category><![CDATA[rubygems]]></category>
		<category><![CDATA[setup]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/06/14/installing-ruby-1-8-and-ruby-1-9-on-the-side-by-side/</guid>
		<description><![CDATA[It&#8217;s unfortunate that people are still having trouble getting Ruby 1.8 and 1.9 to co-exist on a single system. It&#8217;s unfortunate because it hurts the migration and adoption rate of Ruby 1.9. That&#8217;s specifically unfortunate because Ruby 1.9 is insanely better than 1.8, so much so that I honestly think that people not wanting to [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s unfortunate that people are still having trouble getting Ruby 1.8 and 1.9 to co-exist on a single system. It&#8217;s unfortunate because it hurts the migration and adoption rate of Ruby 1.9. That&#8217;s specifically unfortunate because Ruby 1.9 is insanely better than 1.8, so much so that I honestly think that people not wanting to switch might actually be insane themselves. </p>
<p>If you&#8217;re thinking about trying Ruby 1.9 but think it will be a hassle to install and will break all your (non-rails) apps, read on. I use Ruby 1.9 almost exclusively and have very few issues.</p>
<p></p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/JOESgd-rI3U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/06/14/installing-ruby-1-8-1-9-side-by-side/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/06/14/installing-ruby-1-8-1-9-side-by-side/</feedburner:origLink></item>
		<item>
		<title>RubyGems Integration with YARD 0.2.3.1</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/ca594chH4SM/</link>
		<comments>http://gnuu.org/2009/06/13/rubygems-integration-with-yard-0-2-3-1/#comments</comments>
		<pubDate>Sat, 13 Jun 2009 22:26:43 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/06/13/yard-rubygems-integration-with-yard-0-2-3-1/</guid>
		<description><![CDATA[Just yesterday, thanks to Nick Quaranto and his GemCutter project, I discovered that RubyGems 1.3.2 introduced a new plugin architecture that developers can use to add functionality to gem. I&#8217;ve wanted to add YARD integration into RubyGems for the longest time, but I never really had any clue how to do it until now. It [...]]]></description>
			<content:encoded><![CDATA[<p>Just yesterday, thanks to <a href="http://litanyagainstfear.com">Nick Quaranto</a> and his <a href="http://gemcutter.org">GemCutter</a> project, I discovered that RubyGems 1.3.2 introduced a new plugin architecture that developers can use to add functionality to <tt>gem</tt>. I&#8217;ve wanted to add YARD integration into RubyGems for the longest time, but I never really had any clue how to do it until now. It was actually quite simple.</p>
<p></p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/ca594chH4SM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/06/13/rubygems-integration-with-yard-0-2-3-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/06/13/rubygems-integration-with-yard-0-2-3-1/</feedburner:origLink></item>
		<item>
		<title>YARD Milkshakes (0.2.3) Released</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/8DIcQ71OrJM/</link>
		<comments>http://gnuu.org/2009/06/07/yard-milkshakes-0-2-3-released/#comments</comments>
		<pubDate>Sun, 07 Jun 2009 23:44:22 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/06/07/yard-milkshakes-0-2-3-released/</guid>
		<description><![CDATA[Today marks the first release of YARD in almost a year. Although technically speaking the new release isn’t that much more featureful than 0.2.2, this release marks a pretty huge milestone in YARD’s development. It turned out to be extremely difficult (for me) to keep up development with a full school schedule. YARD sets out [...]]]></description>
			<content:encoded><![CDATA[<p>Today marks the first release of <a href="http://yard.soen.ca">YARD</a> in almost a year. Although technically speaking the new release isn’t that much more featureful than 0.2.2, this release marks a pretty huge milestone in YARD’s development. It turned out to be extremely difficult (for me) to keep up development with a full school schedule. YARD sets out to accomplish a heck of a lot more than one person can handle on a part-time basis, but the fact that it’s starting to come together is really what is worth celebrating here. </p>
<h2></h2>
<h2></h2>
<h2>New Parser, Stronger Code</h2>
<p>That said, there are still some <a href="http://yard.soen.ca/whats_new.html">significant improvements</a> in the 0.2.3 release. Plenty of stability and performance fixes were added, and a completely new parser for Ruby 1.9 was implemented based on the new Ripper parser that comes with the 1.9 standard library. Those who have been using YARD know that it has its own homegrown parser built from the ground up. While I’m impressed that I was even able to write a Ruby parser that works 80% of the time, it was quite lacking in both speed and robustness. Although <a href="http://nex-3.com">Nathan Weizenbaum</a> (of <a href="haml.hamptoncatlin.com">Haml</a> fame) contributed some great refactoring and quality improvement patches to the parser, it still has some pretty obvious limitations. </p>
<p>The new 1.9-only parser will be the face of YARD looking forward, especially as people will start migrating to Ruby 1.9 themselves. The 1.8.x parser is still supported and maintained as far as bug fixes go, though new functionality probably should not be expected. </p>
<p>If you’re not yet convinced that Ruby 1.9 is worth the trouble for your project, consider these benchmark results of the new ripper parser parsing the YARD codebase twice:</p>
<pre>yard (master)$ ruby -v
ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-darwin9.6.0]
yard (master)$ ruby benchmarks/ripper_parser.rb
Rehearsal -------------------------------------------------
<strong>rip-parser      1.930000   0.020000   1.950000 (  2.004864)</strong>
yard-parser     4.700000   0.020000   4.720000 (  4.712828)
---------------------------------------- total: 6.670000sec

                    user     system      total        real
<strong>rip-parser      1.760000   0.000000   1.760000 (  1.763015)</strong>
yard-parser     4.720000   0.020000   4.740000 (  4.755574)</pre>
<p>The comparison here is between the new parser used when you run YARD in Ruby 1.9 versus my old pure-ruby implementation. The difference is significant; a speed improvement of nearly 2.7x. Realize again that these are both running in 1.9, so we’re not even comparing the speed benefit you get from using YARV over MRI. That result is actually:</p>
<pre>yard (master)$ ruby -v
ruby 1.8.7 (2009-01-28 patchlevel 99) [i686-darwin9.6.0]
yard (master)$ ruby benchmarks/ripper_parser.rb
Rehearsal -------------------------------------------------
yard-parser     7.820000   0.030000   7.850000 (  7.859455)
---------------------------------------- total: 7.850000sec

                    user     system      total        real
yard-parser     8.070000   0.020000   8.090000 (  8.114952)</pre>
<p><em>Note that I had to modify the benchmark script to ignore the ripper parser here.</em></p>
<p>So, in Ruby 1.8.x, the fastest YARD can parse its own codebase twice is roughly 8 seconds. Compare this to running YARD in Ruby 1.9.1 (previous results), which can parse nearly over 4 times faster. This becomes significant on large projects like Rails, which takes 11 seconds to parse all of code in 1.9, but roughly 65 seconds under Ruby 1.8.7. 65 seconds is a <em>long</em> time to wait to parse code; and that doesn’t even count HTML generation, which takes an even more significant amount of time.</p>
<h2>Plenty of New Documentation</h2>
<p>I’ll be the first to admit, for a documentation tool, YARD is surely lacking in documentation. I take this seriously, but at the same time, I’m only one person and there’s a lot to write about. I made it a point this time around to spend this entire last week brushing up documentation to make YARD easier to jump into. YARD now has a great <a href="http://yard.soen.ca/getting_started.html">Getting Started</a> guide which should cover the really basic aspects of how to get around. More importantly, as a developer tool, there is also a hefty <a href="http://yard.soen.ca/tech_overview.html">Technical Overview</a> guide covering all of the major components of the project and how a developer could take advantage of them. In this release alone I’ve written roughly 7,948 new words of documentation, and I’ve barely scratched the surface. YARD has tremendous potential and tons of use cases, so writing about it all will take time, but it <em>will</em> happen.</p>
<h2>Looking Forward</h2>
<p>So in the end, this release was very important. The parser was something that was on the table for a long time, dating back to my first <a href="http://gnuu.org/2008/02/22/the-yard-roadmap-to-10/">roadmap to 1.0</a> post last year. Now that it’s complete, we can start looking ahead. As more of the groundwork is properly laid out, it becomes easier to move forward. The next release will be focusing on drastically improving the quality of the HTML templates, so expect bigger changes in the coming months.</p>
<p>By the way, if you didn’t notice, YARD got a new site face-lift, so check out the <a href="http://yard.soen.ca">site</a>.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/8DIcQ71OrJM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/06/07/yard-milkshakes-0-2-3-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/06/07/yard-milkshakes-0-2-3-released/</feedburner:origLink></item>
		<item>
		<title>Introducing a New Blog (Design)</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/ix3jWMqlcGQ/</link>
		<comments>http://gnuu.org/2009/06/01/introducing-a-new-blog-design/#comments</comments>
		<pubDate>Mon, 01 Jun 2009 06:32:53 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[new blog]]></category>
		<category><![CDATA[yard]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/06/01/introducing-a-new-blog-design/</guid>
		<description><![CDATA[Since YARD development has been slowing down in preparation for the 0.2.3 release coming this week, I had some time to step back from writing code and start putting together docs. I was planning on writing a bunch of design &#38; architecture overviews for yard so more people can have a sufficient set of resources [...]]]></description>
			<content:encoded><![CDATA[<p>Since <a href="http://github.com/lsegal/yard">YARD</a> development has been slowing down in preparation for the 0.2.3 release coming this week, I had some time to step back from writing code and start putting together docs. I was planning on writing a bunch of design &amp; architecture overviews for yard so more people can have a sufficient set of resources to figure out how to write plugins and such. There are actually plenty of developers that have expressed interest so far, and I’m going to be spending this entire week putting out as much information as I can. As I started doing this, though, I realized I really haven’t done any web design or written any significant web related content in a <em>really</em> long time, so this weekend I decided I would take a little break from YARD to focus on some other much needed improvements.</p>
<p>I’m referring specifically to my blog, which was becoming a complete mess of ugliness and broken HTML. I decided to completely gut it, remove a bunch of useless crap and focus on making the content clean and easy to read. This is pretty much a warm-up exercise for the coming week of writing docs and putting out the new YARD site, but it’s something I should have done long ago. Hopefully this will give me some new incentive to write more (about YARD?) </p>
<h2>It’s not a “blog” anymore</h2>
<p>You may have noticed that comments are gone. Good. Comments are often useful, but to be honest, like many other “bloggers”, I’ve discovered they often don’t add much to the conversation (I rarely get comments on my blog anyway, so styling all that HTML is a waste of my time). A lot of people will say a site is “not a blog” if it does not allow a two-way conversation between the author and the reader. Fine, then I guess this is no longer a blog. My intention for writing articles is <em>not</em> to inherently start a conversation or get feedback. I write because I want to share, not because I need validation or care that you think I’m a dumbass. Don’t get me wrong, I still like when people point out errors and omissions or insert points of view, so if you notice anything send me an email or twitter me instead, we can have the discussion there. Better yet, reply with your own article. This keeps the conversation sane, civil and keeps the signal-to-noise ratio down. I’ve noticed this trend from other blogs I visit, and I’m starting to think the future of blogging will look a lot more like magazine articles than threaded conversations. Dialog is good, but it should be controlled so that it remains on topic and relevant.</p>
<p>I mentioned <a href="http://twitter.com/lsegal">Twitter</a> is a good way to reach me. I’ve actually been using it a lot for the past 6 months; a lot more than this blog. It’s no surprise that microblogging is way easier than writing long articles, so for the past few months my Twitter account has probably been a better source of blog content than my blog (I guess this is probably why people like Tumblr). Let’s be honest, I’m probably not going to start blogging much more than I already do, but I can keep up with Twitter pretty well. Because of this, I’ve incorporated my Twitter feed into my blog and it’s prominently displayed on the front page and in the sidebar on others. I didn’t just add it as a widget to fill whitespace. Instead, expect that feed to be a major source of content for this site. Though you should probably just <a href="http://twitter.com/lsegal">follow me</a>.</p>
<p>Anyway, enough about me. Hope you like the new design.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/ix3jWMqlcGQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/06/01/introducing-a-new-blog-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/06/01/introducing-a-new-blog-design/</feedburner:origLink></item>
		<item>
		<title>Getting Git.tmbundle working with Ruby1.9</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/U96BlE7hd2k/</link>
		<comments>http://gnuu.org/2009/05/25/getting-gittmbundle-working-with-ruby19/#comments</comments>
		<pubDate>Tue, 26 May 2009 03:03:10 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[bundles]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[ruby 1.9]]></category>
		<category><![CDATA[textmate]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/05/25/getting-gittmbundle-working-with-ruby19/</guid>
		<description><![CDATA[Tim Harper has a great Git TextMate bundle that I use extensively, but since I’ve converted to Ruby 1.9, I’ve had some problems that others might have run into. Here’s what I did to get everything working nicely in Ruby 1.9:
First off, if you haven’t already, you’ll probably want to pull an updated version of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tim.theenchanter.com">Tim Harper</a> has a great Git TextMate bundle that I use extensively, but since I’ve converted to Ruby 1.9, I’ve had some problems that others might have run into. Here’s what I did to get everything working nicely in Ruby 1.9:</p>
<p>First off, if you haven’t already, you’ll probably want to pull an updated version of TextMate’s support files from the svn repository to get some necessary 1.9 compatibility fixes.</p>
<pre>$ cd ~/Library/Application\ Support/TextMate/
$ svn co <a href="http://macromates.com/svn/Bundles/trunk/Support">http://macromates.com/svn/Bundles/trunk/Support</a></pre>
<p>You’ll need to clone <a href="http://github.com/lsegal/git-tmbundle/tree/master">my Git.tmbundle repository</a> into the Bundles directory to get most of the changes I made to his bundle to deal with the basic Ruby 1.9 issues. </p>
<p>After that, you should get most of the basic functionality of the bundle, but you’ll probably notice that if you try to compare branches, revisions, or any of the more fun stuff, you’ll get the following error:</p>
<pre>ArgumentError: An object in the argument tree could not be converted
&#160;&#160;&#160; from (irb):17:in `to_plist'
&#160;&#160;&#160; from (irb):17
&#160;&#160;&#160; from /usr/local/bin/irb:12:in `&lt;main&gt;'</pre>
<p>This is because TextMate ships with a native plist library in its support directory (the one we checked out above) that isn’t quite Ruby 1.9 compatible. We’re lucky though, because an updated version of the library, <a href="http://github.com/kballard/osx-plist">osx-plist</a> (written by Kevin Ballard) is on GitHub, so let’s pull and build it.</p>
<pre>$ cd ~/Library/Application\ Support/TextMate/Support/lib/osx
$ git clone git://github.com/kballard/osx-plist.git
$ cd osx-plist/ext/plist
$ ruby extconf.rb &amp;&amp; make
$ cp plist.bundle ../../../</pre>
<p>Assuming you have TextMate using Ruby 1.9, you should now be able to compare revisions and branches, and do pretty much anything with the awesome Git.tmbundle!</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/U96BlE7hd2k" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/05/25/getting-gittmbundle-working-with-ruby19/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/05/25/getting-gittmbundle-working-with-ruby19/</feedburner:origLink></item>
		<item>
		<title>Taking your Job Seriously; the Answer to “Software Engineering”</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/QueqKJp-gZs/</link>
		<comments>http://gnuu.org/2009/03/24/taking-your-job-seriously/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 04:37:00 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[ethics]]></category>
		<category><![CDATA[iron ring]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/03/24/taking-your-job-seriously-the-answer-to-software-engineering/</guid>
		<description><![CDATA[Today was supposedly one of the biggest days of my professional life. I took an oath today. An oath to uphold the professional values of the Engineering industry of Canada. Although the Iron Ring ceremony is mostly symbolic and has no affect on my legal status as a professional Engineer (read: I’m not one), it’s generally seen as an essential part of your career. So you would expect that this would be a time of great celebration, a memorable stepping stone to a bright future. The only problem is, I have no short-term intentions of ever becoming an Engineer.]]></description>
			<content:encoded><![CDATA[<p><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="My Ring (tm)" border="0" alt="My Ring (tm)" align="right" src="http://gnuu.org/wp-content/uploads/2009/03/photo345.jpg" width="188" height="162" /> Today was supposedly one of the biggest days of my professional life. I took an oath today. An oath to uphold the professional values of the Engineering industry of Canada. Although the <a href="http://en.wikipedia.org/wiki/Iron_Ring">Iron Ring</a> <a href="http://en.wikipedia.org/wiki/The_Ritual_of_the_Calling_of_an_Engineer">ceremony</a> is mostly symbolic and has no affect on my legal status as a professional Engineer (read: I’m not one), it’s generally seen as an essential part of your career. So you would expect that this would be a time of great celebration, a memorable stepping stone to a bright future. The only problem is, <em>I have no short-term intentions of ever becoming an Engineer</em>. </p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/QueqKJp-gZs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/03/24/taking-your-job-seriously/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/03/24/taking-your-job-seriously/</feedburner:origLink></item>
		<item>
		<title>Demystifying Continuations in Ruby (because they shouldn’t be feared)</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/Xt3g0udsGUU/</link>
		<comments>http://gnuu.org/2009/03/21/demystifying-continuations-in-ruby/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 18:35:03 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[continuations]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby 1.9]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/03/21/demystifying-continuations-in-ruby/</guid>
		<description><![CDATA[So most people won’t touch continuations with a 10 foot pole, that’s probably why in Ruby 1.9 they’ve been pseudo-deprecated (YARV performance was also an issue here, to be fair) by being pushed out to an explicit “require ‘continuation’” call. Perhaps it’s been misunderstood, but there’s a secret that nobody knows about continuations: they’re dead simple. BRAINDEAD simple.]]></description>
			<content:encoded><![CDATA[<p>So most people won’t touch continuations with a 10 foot pole, that’s probably why in Ruby 1.9 they’ve been <a href="http://wiki.jruby.org/wiki/Differences_between_mri_and_jruby">left out of JRuby</a> and <a href="http://www.atdot.net/~ko1/pub/ContinuationFest-ruby.pdf">pseudo-deprecated</a> in Ruby 1.9 (YARV performance was also an issue here, to be fair) by being pushed out to an explicit “<em>require ‘continuation’</em>” call. Perhaps it’s been misunderstood, but there’s a secret that nobody knows about continuations: <strong>they’re dead simple</strong>. <em>BRAINDEAD</em> simple.</p>
<p>Most blogs and articles I’ve seen that try to explain continuations get it wrong. They bore you with low level details that confuse you in the first place, or scare you by starting with the premise that “it’s complicated, but I&#8217;ll try to make you understand”. I’m not going to do either, I’m actually going to explain continuations in two words, and I want you not to laugh, cry, or vomit on yourself when you read them:</p>
<h2>GLORIFIED GOTOs</h2>
<p>Oh no, I just said a dirty word, didn&#8217;t I. You may have your own irrational fears of the goto statement, but you probably know what they are and how they work:</p>
<pre class="sh_c">#include &lt;stdio.h&gt;
int main() {
  int i = 0;
  printf("%d\n", i);
  goto some_label;
  i = 1;
  some_label:
  printf("%d\n", i);
  return 0;
}</pre>
<p>The above snippet of working C shows how we can jump to different points in a function. It prints 0 twice instead of 0 followed by 1, as you would expect. Language evolution has mostly deprecated this form of programming through method calls and, more intricately, exception handling. These new practices are really just syntactic sugar on the old goto concept. Hopefully all those who scoff at any mention of goto will one day sit down and realize that they&#8217;re a central part of how computers work, but I&#8217;m getting off topic. The point is, whether you use gotos or not, they&#8217;re extremely simple to understand. In fact, they’re exactly as simple as continuations; let’s re-write the above using those &#8220;scary&#8221; guys:</p>
<pre class="sh_ruby">def main
  i = 0
  callcc do |label| # callcc gives us ‘label’, a continuation object
    puts i
    label.call # this is our "goto" statement
    i = 1      # we skip this completely
  end          # this is where our "label" would otherwise sit
  puts i
end</pre>
<p>To those in the know, this doesn&#8217;t really show off the full-extent of callcc&#8217;s powers (that comes later), but you can look at &quot;label.call&quot; as the equivalent of &quot;goto label&quot;, and the end of the callcc block is where the label would be. That&#8217;s basically how continuations work.</p>
<p><em>If you’re having trouble parsing the above: the little trick to understanding the code is simply realizing that the block that callcc yields is <strong>executed immediately, once, and only once</strong>. It’s simply there so you can do any one-time initialization with the continuation you’re creating. The end of the block is where any subsequent calls to the yielded continuation object will go, not the block itself.</em></p>
<h3>NOW YOU KNOW.</h3>
<p>So what, is it really that simple? Continuations are another way to write gotos? The answer is: pretty much. There are actually only two functional difference that makes them even more powerful than the above C-style gotos, but one that makes them a little less-so.</p>
<h4>More Powerful, How?</h4>
<p><span style="font-size: 140%">1.</span> <strong>They’re not local to your method</strong>. Simply put, we can’t do the following in C:</p>
<pre class="sh_c">// a() is called by main()
void a() {
  printf("hello world\n");
  label1:
  printf("then you say...\n");
  b();
}
void b() {
  printf("then I say...\n");
  goto label1;
}</pre>
<p>This should print &quot;hello world&quot; followed by &quot;then you say&quot;, &quot;then I say&quot;, in a never-ending loop. Problem is, it won&#8217;t compile. Without getting into the nitty-gritty of why C can’t do this, I’ll just simply show how we can actually get away with it using continuations:</p>
<pre class="sh_ruby">def a
  puts "hello world"
  callcc {|cc| $label1 = cc } # pretend this says "label1:"
  puts "then you say..."
  b
end

def b
  puts "then I say"
  $label1.call # pretend this says "goto label1"
end</pre>
<p>As the comments indicate, this is almost a one-to-one translation of the C code above. Our continuation object is set to a global variable, essentially making it a “<em>global label</em>” that can be goto’d by running the method #call (picture it as “label.goto” instead of #call).</p>
<p><span style="font-size: 140%">2.</span> <strong>They maintain stack-frame state</strong>. That’s the reason why labels in C are local to a function, because you can’t just jump between functions without switching stack frames. Actually, there are tricks in C to do just that (namely <tt>longjmp</tt> and <tt>setjmp</tt> to jump to arbitrary addresses and continue execution which is actually how continuations are done in C), but we’re focusing on Ruby here, right? Basically, the continuation object yielded from callcc (the {|cc| thing}) contains a snapshot of our stack frame at the point it was yielded at (remember, the block is only yielded that first time). This allows us to jump between methods in a class, between classes, and jump back from a nested call when we are arbitrarily deep in a stack frame. </p>
<h4>Anyone Up For A Quick Real World Example?</h4>
<p>The last situation is the one with some real world usage. Imagine we’re writing a web framework with a Rails-style before_filter and we want the ability to halt the execution during a filter and jump all the way back up to the router code to find the next matching route. <a href="http://www.sinatrarb.com">Sinatra</a> (sort-of) does this with the `pass` method, and though it probably doesn’t use continuations to achieve the result, the concept here is a perfect example of wanting to jump back through our stack frames arbitrarily. We could be 3 method calls deep, or we could be 20 method calls deep, but we need to “go to” a specific point in our program execution. Usually, people implement this with try/catch style exception handling (RouteAbortError maybe), but continuations may be a little cleaner depending on the scenario (we might have a method handling the exception 3 method calls up, but we want to jump 7 method calls up to the initial point in code).</p>
<h4>Less Powerful, How?</h4>
<p>There’s one thing you may have noticed from the initial example, it’s that jumping forward looks different from the example where we jumped backwards. The limitation is that continuations can’t actually jump <em>forwards</em>, at least not between method calls. The reason is that in C, labels are compiled into the program statically, but in Ruby, the continuation objects are created at runtime. This means that we’d need to execute that callcc call in our future method to generate the continuation, but we can’t run code that hasn’t yet been run. In short, continuations are great for jumping back in time, not quite so for jumping forwards.</p>
<h3>Final Correction</h3>
<p>So I initially called continuations “glorified gotos”. Hopefully this got you to understand the simple concept behind their use; but now I should fess up and modify the definition just a little bit to be slightly more accurate. Instead of glorified gotos, think of continuations as:</p>
<h2>GLORIFIED, <u>STATEFUL, BACKWARDS JUMPING,</u> GOTOs</h2>
<p>Now that you know what the fuss is about, you can decide to hate continuations all you want.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/Xt3g0udsGUU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/03/21/demystifying-continuations-in-ruby/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/03/21/demystifying-continuations-in-ruby/</feedburner:origLink></item>
		<item>
		<title>Ruby 1.9 Common Problems Pt. 1: Encoding</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/mlfvwAPbaWw/</link>
		<comments>http://gnuu.org/2009/02/02/ruby-19-common-problems-pt-1-encoding/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 06:05:41 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[BlueCloth]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[problems]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[programming languages]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby 1.9]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/02/02/ruby-19-common-problems-pt-1-encoding/</guid>
		<description><![CDATA[If you’re migrating from Ruby 1.8.x to 1.9 you probably have run into one of the following error messages:
invalid multibyte char (US-ASCII)
- OR -
CompatibilityError: incompatible encoding regexp match (Windows-31J regexp with UTF-8 string)
The errors themselves are relatively self-explanatory. Ruby 1.9 is far more Unicode aware than 1.8, and this error happens when have some Unicode [...]]]></description>
			<content:encoded><![CDATA[<p>If you’re migrating from Ruby 1.8.x to 1.9 you probably have run into one of the following error messages:</p>
<p><code class="dark">invalid multibyte char (US-ASCII)</code></p>
<p>- OR -</p>
<p><code class="dark">CompatibilityError: incompatible encoding regexp match (Windows-31J regexp with UTF-8 string)</code></p>
<p>The errors themselves are relatively self-explanatory. Ruby 1.9 is far more Unicode aware than 1.8, and this error happens when have some Unicode (usually UTF-8) in one of your files. What you have to do to fix these, however, is not always as straightforward.</p>
<p>Well, after some time pulling my hair out, I&#8217;ve figure out that the solutions to these issues are actually quite simple. </p>
<h3>Invalid multibyte char (encoding here)</h3>
<p>If you get this issue, add the following to the top of each exploding file (below the <a href="http://en.wikipedia.org/wiki/Shebang_(Unix)">shebang</a> if there is one):</p>
<pre class="dark"># encoding: utf-8</pre>
<p style="border-right: #ccc 1px solid; padding-right: 7px; border-top: #ccc 1px solid; padding-left: 7px; font-size: 0.8em; background: #eee; padding-bottom: 7px; margin: 7px; border-left: #ccc 1px solid; padding-top: 7px; border-bottom: #ccc 1px solid"><strong>Note:</strong> You can also use &quot;coding:&quot; or even the Emacs style <tt>-*- encoding: utf-8 -*-</tt> but I like the simple term, &#8216;encoding&#8217;. Also note that you might need to replace &#8216;utf-8&#8242; wth your specific encoding if it&#8217;s something else.</p>
<p>This should resolve the issue.</p>
<p>Basically, Ruby by default assumes that every file is encoded as US-ASCII, and so when it reads UTF-8 (or any Unicode) it freaks out because it is beyond the 7-bit encoding. You have to tell it that the file is encoded as utf-8 by listing it as we did at the top of the file. Yes, it&#8217;s a little anal, but I&#8217;m sure we&#8217;ll get used to it.</p>
<h3>Incompatible encoding regexp match</h3>
<p>This issue is a little bit hairier. I had this problem with the <a href="http://www.deveiate.org/projects/BlueCloth/">BlueCloth</a> 1.0.0 gem (on line 972 of bluecloth.rb). It turns out that there are a <a href="http://www.zenspider.com/Languages/Ruby/QuickRef.html#11">few switches</a> that turn on specific encodings, and for some reason BlueCloth turns on the <tt>//s</tt> switch which enables the SJIS encoding (maybe <a href="http://daringfireball.net/">John Gruber</a> wanted <tt>//m</tt> for multiline?). Ruby 1.8 didn&#8217;t mind having this on, but 1.9 freaks out. Moral of the story, when you see this error, check your Regexp switches.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/mlfvwAPbaWw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/02/02/ruby-19-common-problems-pt-1-encoding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/02/02/ruby-19-common-problems-pt-1-encoding/</feedburner:origLink></item>
		<item>
		<title>Ruby 1.9.1 Favorite New Features</title>
		<link>http://feedproxy.google.com/~r/connectnothing/~3/lrNjiehy2uI/</link>
		<comments>http://gnuu.org/2009/01/31/ruby-191-favorite-new-features/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 21:35:43 +0000</pubDate>
		<dc:creator>Loren Segal</dc:creator>
				<category><![CDATA[post]]></category>
		<category><![CDATA[enumerations]]></category>
		<category><![CDATA[new features]]></category>
		<category><![CDATA[ordered hash]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby 1.9]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://gnuu.org/2009/01/31/ruby-191-favorite-new-features/</guid>
		<description><![CDATA[I just grabbed Ruby 1.9.1 today (it was released January 30th 2009, so I’m 24 hours late) and decided to play with it. I’m interested in the changes they’ve been making to the parser, something I’m particularly interested in given my Ruby documentation tool, YARD, is highly dependent on syntax (and I’m messing with the [...]]]></description>
			<content:encoded><![CDATA[<p>I just grabbed <a href="http://ruby-lang.org">Ruby 1.9.1</a> today (it was released January 30th 2009, so I’m 24 hours late) and decided to play with it. I’m interested in the changes they’ve been making to the parser, something I’m particularly interested in given my Ruby documentation tool, <a href="http://github.com/lsegal/yard">YARD</a>, is highly dependent on syntax (and I’m messing with the parser), but some of the other changes are quite nice too. I came across this nice <a href="http://www.scribd.com/doc/2589469/Migrating-to-Ruby-19">migration guide</a> that covers some of the basic changes, but here is a more distilled list of my favorites:</p>
<h3>1. Hash entries are <em>Ordered!</em></h3>
<pre class="sh_ruby">h = { cat: 1, zebra: 2, dog: 3 }
h.delete(:zebra)
h[:monkey] = 4
h.each {|key, val| puts "#{key}: #{val}" }

# Guaranteed to print:
# cat: 1
# dog: 3
# monkey: 4</pre>
<p>I’ve been praying for this for who knows how long. Everyone knows hashes don’t maintain order internally, but much of Ruby development makes use of Hashes as dictionaries because of the simplistic syntax. The problem is that dictionaries, unlike straight hash objects, usually require order to be maintained. There are tons of places in YARD where I had to resort to nested Arrays (eg. <tt>[[key, val], ...]</tt>) to maintain order of a set of associated objects… I’ve even written countless <em>OrderedHash</em> classes to solve this problem. This is definitely the biggest feature in 1.9 to me.</p>
<p><strike>PS. You might have noticed the Pythonish <tt>{a: 1}</tt> syntax— yep, that&#8217;s new too, but it&#8217;s not quite cool enough to make it&#8217;s own item in our list but it’s really convenient to type.</strike></p>
<h3>2. Symbols are now Intuitively Comparable</h3>
<p>YARD calls #to_s on about a million things. Last I checked, Rails does too. This is because internally we try to keep everything stored as a Symbol for obvious efficiency. The problem is that when writing API&#8217;s we&#8217;re usually allowing developers to pass in a String <em>or</em> a Symbol, which means comparison is <em>always</em> annoying. It looks like the Ruby devs looked at a lot of this code, puked all over their keyboards, and cleaned up both their keyboards and the code to deal with this. We can now do things like:</p>
<pre class="sh_ruby">:hello =~ /e/      # => 1
:hello === "hello" # => true
:hello[1] == "e"   # => true</pre>
<h3>3. Enumerations on a Hash return a Hash</h3>
<p>For the same reasons as above, this is awesome. Performing a #select on a hash was always a pain in Ruby 1.8 because you would end up with an Array… totally not a Hash. This inconsistency has been dealt with and we can now do:</p>
<pre class="sh_ruby">{a:1,b:2,c:3}.reject {|k,v| k == :b }
=> {:a=>1, :c=>3}</pre>
<h3>4. Proper Unicode Support</h3>
<p>Let&#8217;s not get too far into this list without giving credit for the awesome work Ruby 1.9 has done in fixing the Unicode support. In short, it is now possible to do things like:</p>
<pre class="sh_ruby">"Hi!".encode("utf-16be") # => "\x00H\x00i\x00!"
File.read('test.txt', encoding: 'utf-8').encoding</pre>
<p>We also get Enumerations like <tt>#each_char</tt> that iterate properly over such strings. There’s plenty more goodies regarding Unicode, but I still don’t know all of the details. Interestingly enough, I ran into a Ruby Unicode problem the other day, so I think I’ll be revisiting the problem with these new tools soon and write about what happened.</p>
<h3>5. Regexps get Look-ahead/Look-behind</h3>
<p>Probably the most powerful feature of regular expressions have been missing from Ruby for the longest time. I can’t remember any specific times when I hit this limitation, but I imagine it will simplify a lot of hacky code attempting to work around the feature omission in 1.8. </p>
<h3>6. Object #tap</h3>
<p>This is an easy one because anyone could have implemented it, but it&#8217;s a nice way to silently hook into a method call chain. The <a href="http://www.ruby-doc.org/core-1.9/classes/Object.html#M000309">Ruby 1.9 docs</a> give a cool example of this, but I think a better example is when dealing with method calls that aren&#8217;t chainable like <tt>Hash#delete</tt>: </p>
<pre class="sh_ruby"># In 1.8 we need to do this because #delete returns nil:
h = {:a => 1, :b => 2, :c => 3}
h.delete(:b)
h.each {|k,v| puts k }

# In 1.9 we can do this in one line:
{a:1,b:2,c:3}.tap {|o| o.delete(:b) }.each {|k,v| puts k }</pre>
<h3>7. Fibers are lighter Threads</h3>
<p>Still have yet to dig into this one, but <a href="http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html">Dave Thomas</a> covers the new Fiber class. In short, they&#8217;re basically lambdas encapsulated in threads— but of course it’s not the implementation but the way you use these guys that makes them quite elegant. I can think of a few things right off the top of my head that involve the quick creation of threads from inline storable procedures.</p>
<h3>8. New Hash Key Syntax</h3>
<p><small>UPDATE:</small> Okay, I wasn&#8217;t going to put this in the list until I realized how the syntax can be applied to method calls. Consider the following 1.8 code:</p>
<pre class="sh_ruby">def open(filename, opts = {}) end

open('test.txt', :access => :read, :close => true)</pre>
<p>The same code in 1.9 can be called as:</p>
<pre class="sh_ruby">def open(filename, opts = {}) end

open('test.txt', access: :read, close: true)</pre>
<p>That <em>is</em> cool.</p><img src="http://feeds.feedburner.com/~r/connectnothing/~4/lrNjiehy2uI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://gnuu.org/2009/01/31/ruby-191-favorite-new-features/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://gnuu.org/2009/01/31/ruby-191-favorite-new-features/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 0.285 seconds. --><!-- Cached page generated by WP-Super-Cache on 2009-06-30 14:04:21 -->
