<?xml version="1.0" encoding="utf-8"?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xml:lang="en">
<title>Josh Staiger</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/" />
<modified>2008-10-20T08:00:19Z</modified>
<tagline>My name is Josh Staiger and this is my personal website. Here I write about whatever happens to interest me at the moment, including technical matters on occasion.</tagline>
<id>tag:www.joshstaiger.org,2009://1</id>
<generator url="http://www.movabletype.org/" version="3.15">Movable Type</generator>
<copyright>Copyright (c) 2007, Josh Staiger</copyright>
<entry>
<title>Reboot</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2007/04/reboot.html" />
<modified>2008-10-20T08:00:19Z</modified>
<issued>2007-05-01T04:25:36Z</issued>
<id>tag:www.joshstaiger.org,2007://1.401</id>
<created>2007-05-01T04:25:36Z</created>
<summary type="text/plain"> I apologize if I&apos;ve been distant lately; right now I&apos;m in the process of rebooting my life. Friday will be my last day with IBM. Over the next few weeks I&apos;ll be relocating to the Bay Area to work for Google....</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>General</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<p><a href="http://www.flickr.com/photos/joshstaiger/147349438/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/49/147349438_d818250e7a_m.jpg" width="180" height="240" alt="san_francisco129.jpg" /></a></p>

<p>I apologize if I've been distant lately;  right now I'm in the process of rebooting my life.</p>

<p>Friday will be my last day with IBM.  </p>

<p>Over the next few weeks I'll be relocating to the Bay Area to work for <a href="http://google.com">Google</a>.  </p>]]>

</content>
</entry>
<entry>
<title>Jazz.net goes live</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2007/02/jazznet_goes_li.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2007-02-08T04:44:00Z</issued>
<id>tag:www.joshstaiger.org,2007://1.400</id>
<created>2007-02-08T04:44:00Z</created>
<summary type="text/plain"> If you&apos;d like a peek at what I&apos;ve been up to at work for the past eight months, head over to jazz.net, which just went live. The details are still kinda sketchy, but expect more real soon now :)...</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Technology and Software</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<p><a href="http://www.flickr.com/photos/joshstaiger/184750146/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/56/184750146_eee0279136_m.jpg" width="240" height="154" alt="paris.jpg" /></a></p>

<p>If you'd like a peek at what I've been up to at work for the past eight months, head over to <a href="http://jazz.net">jazz.net</a>, which just went live.</p>

<p>The details are still kinda sketchy, but expect more real soon now :)</p>]]>

</content>
</entry>
<entry>
<title>Eclipse is a dead system</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2007/01/eclipse_is_a_de_1.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2007-01-18T23:05:53Z</issued>
<id>tag:www.joshstaiger.org,2007://1.398</id>
<created>2007-01-18T23:05:53Z</created>
<summary type="text/plain"> (DON&apos;T PANIC! I probably don&apos;t mean what you think I mean.) On a long enough timeline, the survival rate for everyone drops to zero. Steve Yegge has a thought-provoking essay on living systems vs. dead systems, in essence: systems that can be modified at runtime vs. systems that you have to stop (kill) first to modify. In this context Eclipse is a &quot;dead system&quot; (or &quot;hardware&quot; as Stevey says). And this makes me sad :( In fact, it&apos;s saddened me for a while, though I&apos;ve never framed the issue in these terms. Even though Eclipse has a world-class extension system, we have to go through an onerous process of launching and relaunching Eclipse instances to make the slightest change to a plugin. In contrast, a &quot;living&quot; system like Emacs doesn&apos;t have this problem. In Emacs we can evaluate s-expression, set variables, rewrite functions, and swap code on the fly without having to relaunch - which is why writing Emacs extensions is an order of magnitude easier (and more fun) than writing Eclipse extensions. Stevey also draws a parallel between how long a system can stay running without reboot, and how long people will continue to use the system. *shrug* I think it has more to do with how close your system gets to hitting the best solutions to the problems people are trying to solve on any given day. But here&apos;s the thing: the problems of today aren&apos;t necessarily the problems of tomorrow, nor the problems of ten years from now. The more malleable your system is, the better its chance of solving the problems of 2007, and 2008, and 2017, and 2027. And as it happens, systems that can be modified without a reboot are much easier to modify and far more malleable than systems that can&apos;t. Eclipse has many advantages over Emacs (mostly in terms of gooeyness), but as ugly as Emacs looks on the outside, it&apos;s definitely the more malleable of the two. So, if I had to choose pick which one is more likely to be around in 100 years, my money would be on Emacs. And if history is any guide, that&apos;s probably not a bad bet. UPDATE: Hehe, as Bill points out in the comments, I do feel like kind of a bastard for writing this post (especially the inflammatory title). But my aim isn&apos;t to disparage Eclipse. I love Eclipse. It&apos;s a great platform, and it&apos;s very good at what it does. And no... it&apos;s certainly not &quot;dying&quot; :) My aim is to point out that there are other kinds of extensibility out there that we don&apos;t typically get with Eclipse... at least not right now, and it&apos;s the kind of extensibility I&apos;d very much like to see. And just for full disclosure, I work for the company that originally founded the Eclipse project. All views expressed here are my own and not those of my employer....</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Technology and Software</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<p><a href="http://www.flickr.com/photos/joshstaiger/47349364/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/27/47349364_55d2402904_m.jpg" width="240" height="160" alt="dead_fish.jpg" /></a></p>

<p>(<a href="/images/DontPanic_1024.jpg">DON'T PANIC!</a> I probably don't mean what you think I mean.)</p>

<p><em>On a long enough timeline, the survival rate for everyone <a href="http://www.theonion.com/content/node/39236">drops to zero</a>.</em></p>

<p>Steve Yegge has a thought-provoking essay on <a href="http://steve-yegge.blogspot.com/2007/01/pinocchio-problem.html">living systems vs. dead systems</a>, in essence: systems that can be modified at runtime vs. systems that you have to stop (kill) first to modify.</p>

<p>In this context <a href="http://www.eclipse.org/">Eclipse</a> is a "dead system" (or "hardware" as Stevey says).  And this makes me sad :(  </p>

<p>In fact, it's saddened me for a while, though I've never framed the issue in these terms.</p>

<p>Even though Eclipse has a <a href="http://www.eclipse.org/equinox/">world-class extension system</a>, we have to go through an onerous process of launching and relaunching Eclipse instances to make the slightest change to a plugin.</p>

<p>In contrast, a "living" system like Emacs doesn't have this problem.  In Emacs we can evaluate s-expression, set variables, rewrite functions, and swap code on the fly without having to relaunch - which is why writing Emacs extensions is an order of magnitude easier (and more fun) than writing Eclipse extensions.</p>

<p>Stevey also draws a parallel between how long a system can stay running without reboot, and how long people will continue to use the system.</p>

<p>*shrug*</p>

<p>I think it has more to do with how close your system gets to hitting the best solutions to the problems people are trying to solve on any given day.  But here's the thing: the problems of today aren't necessarily the problems of tomorrow, nor the problems of ten years from now.</p>

<p>The more malleable your system is, the better its chance of solving the problems of 2007, <em>and</em> 2008, <em>and</em> 2017, <em>and</em> 2027.  And as it happens, systems that can be modified without a reboot are <em>much</em> easier to modify and <em>far</em> more malleable than systems that can't.</p>

<p>Eclipse has many advantages over Emacs (mostly in terms of gooeyness), but as ugly as Emacs looks on the outside, it's definitely the more malleable of the two.  So, if I had to choose pick which one is more likely to be around in 100 years, my money would be on Emacs.  And if history is any guide, that's probably <a href="ttp://en.wikipedia.org/wiki/Emacs">not a bad bet</a>. </p>

<p>UPDATE:  </p>

<p>Hehe, as Bill points out in the comments, I do feel like kind of a <a href="http://www.joshstaiger.org/archives/2007/01/eclipse_is_a_de_1.html#comment803">bastard</a> for writing this post (especially the inflammatory title).  But my aim  isn't to disparage Eclipse.  I love Eclipse.  It's a great platform, and it's very good at what it does.  </p>

<p>And no... it's certainly not "dying" :)</p>

<p>My aim is to point out that there are other kinds of extensibility out there that we don't typically get with Eclipse... at least not <em>right now</em>, and it's the kind of extensibility I'd very much like to see.</p>

<p>And just for full disclosure, I <a href="http://www.joshstaiger.org/about/">work for the company</a> that originally founded the <a href="http://en.wikipedia.org/wiki/Eclipse_%28software%29">Eclipse project</a>.  All views expressed here are my own and not those of my employer.</p>]]>

</content>
</entry>
<entry>
<title>Raleigh bloggers meetup tonight @ Helios Coffee</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2007/01/raleigh_blog_me_4.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2007-01-16T14:00:42Z</issued>
<id>tag:www.joshstaiger.org,2007://1.397</id>
<created>2007-01-16T14:00:42Z</created>
<summary type="text/plain">Though it&apos;s been a while since I&apos;ve advertised it here, the Raleigh area blog meetup is still going strong. We meet twice a month: the first and third Tuesday, 6:30PM at the Helios Coffee Company. Details at the wiki. Tonight will be our first meetup of the year. If you live in Raleigh or around Raleigh, please join us! I&apos;d love to meet you in person. (Dave even has Helios photos)...</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Blogging</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<p>Though it's been a while since I've advertised it here, the Raleigh area blog meetup is still going strong.</p>

<p>We meet twice a month:  the first and third Tuesday, 6:30PM at the <a href="http://www.helioscoffee.com/frames.htm">Helios Coffee Company</a>.</p>

<p>Details at the <a href="http://joshstaiger.org/raleighbloggers/index.php?title=Main_Page">wiki</a>.</p>

<p>Tonight will be our first meetup of the year.  If you live in Raleigh or around Raleigh, please join us!  I'd love to meet you in person.</p>

<p>(<a href="http://rollerweblogger.org/roller/entry/raleigh_blogger_meetup_tuesday_at">Dave</a> even has Helios photos)</p>]]>

</content>
</entry>
<entry>
<title>links for 2007-01-16</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2007/01/links_for_20070_1.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2007-01-16T05:29:26Z</issued>
<id>tag:www.joshstaiger.org,2007://1.396</id>
<created>2007-01-16T05:29:26Z</created>
<summary type="text/plain"> Details of Google&apos;s Latest Security Hole &quot;I was able to create a page that was hosted on a google.com domain, which is something that should never be allowed to happen.&quot; (tags: google security) Paul Downey » Blog Archive » Web APIs Are Just Web Sites A great &quot;nutshell&quot; overview of writing a RESTful web service. (tags: web http rest) Trope (Ftrain.com) &quot;Justin Timberlake is not a guilty pleasure. Putting oven cleaner in your daughter&apos;s Similac is a guilty pleasure, or smearing birdseed on your balls and visiting an aviary.&quot; (tags: humor) We Have Fossils Bumper Sticker Yay for Darwin :D (tags: sience evolution humor religion) notmykids.jpg Why You Shouldn&apos;t Leave A Gallon Of Paint With Unsupervised Toddlers (tags: humor photos) PDA, Cellphone and Laptop 90 Years Ago It can be clearly seen that Communist’s coup was so successfull due to the help of time travelers who had come from the future equipped with PDAs, cell phones and laptops. (tags: humor) Raganwald: Why are local variables bad? This is a blog post I&apos;ve been wanting to write for a while. (tags: programming functional)...</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>

<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<ul class="delicious">
	<li>
		<div class="delicious-link"><a href="http://blog.outer-court.com/archive/2007-01-14-n21.html">Details of Google's Latest Security Hole</a></div>
		<div class="delicious-extended">"I was able to create a page that was hosted on a google.com domain, which is something that should never be allowed to happen."</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/google">google</a> <a href="http://del.icio.us/joshstaiger/security">security</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://blog.whatfettle.com/2007/01/11/good-web-apis-are-just-web-sites/">Paul Downey » Blog Archive » Web APIs Are Just Web Sites</a></div>
		<div class="delicious-extended">A great "nutshell" overview of writing a RESTful web service.</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/web">web</a> <a href="http://del.icio.us/joshstaiger/http">http</a> <a href="http://del.icio.us/joshstaiger/rest">rest</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://ftrain.com/trope-guilty-pleasure.html">Trope (Ftrain.com)</a></div>
		<div class="delicious-extended">"Justin Timberlake is not a guilty pleasure. Putting oven cleaner in your daughter's Similac is a guilty pleasure, or smearing birdseed on your balls and visiting an aviary."</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/humor">humor</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://www.stampandshout.com/shop/bumper-stickers/we-have-fossils.php">We Have Fossils Bumper Sticker</a></div>
		<div class="delicious-extended">Yay for Darwin :D</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/sience">sience</a> <a href="http://del.icio.us/joshstaiger/evolution">evolution</a> <a href="http://del.icio.us/joshstaiger/humor">humor</a> <a href="http://del.icio.us/joshstaiger/religion">religion</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://smg.photobucket.com/albums/v141/jumaduke/notmykids.jpg">notmykids.jpg</a></div>
		<div class="delicious-extended"> Why You Shouldn't Leave A Gallon Of Paint With Unsupervised Toddlers</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/humor">humor</a> <a href="http://del.icio.us/joshstaiger/photos">photos</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://englishrussia.com/?p=575">PDA, Cellphone and Laptop 90 Years Ago</a></div>
		<div class="delicious-extended">It can be clearly seen that Communist’s coup was so successfull due to the help of time travelers who had come from the future equipped with PDAs, cell phones and laptops.</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/humor">humor</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://weblog.raganwald.com/2006/10/why-are-local-variables-bad.html">Raganwald: Why are local variables bad?</a></div>
		<div class="delicious-extended">This is a blog post I've been wanting to write for a while.</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/programming">programming</a> <a href="http://del.icio.us/joshstaiger/functional">functional</a>)</div>
	</li>
</ul>
]]>

</content>
</entry>
<entry>
<title>How to install bzr on Dreamhost</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2007/01/bzr_on_dreamhos.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2007-01-16T03:54:47Z</issued>
<id>tag:www.joshstaiger.org,2007://1.395</id>
<created>2007-01-16T03:54:47Z</created>
<summary type="text/plain"> Bazaar or bzr is a Python-based source code management system that I&apos;ve noticed is becoming increasingly popular amongst small open-source projects. Right now I&apos;m not sure what advantages bzr might have over other SCM systems such as Subversion (I suspect it&apos;s more light-weight), but it&apos;s handy to have when you want to grab the source for a project like Planet Venus. Here&apos;s how I installed bzr on my Dreamhost shell account. (note: There&apos;s not anything special here. This is all pretty standard Unix tarball installation fair. In fact, there&apos;s little here that isn&apos;t already in the bzr installation guide. I&apos;m providing this as a confidence cushion for other Dreamhost users.) Fetch it Downloads of bzr are available here: http://bazaar-vcs.org/Download Fetch the tarball install into a directory of your choice: ~$ cd ~/incoming ~/incoming$ wget http://bazaar-vcs.org/releases/src/bzr-0.13.tar.gz Unzip it ~/incoming$ tar -zxvf bzr-0.13.tar.gz Install it ~/incoming$ cd bzr-0.13 ~/incoming/bzr-0.13$ python2.4 setup.py install --home ~ No problem... Adjust environmental variables ... except one hiccup when we try to run bzr: $ bzr bzr: ERROR: Couldn&apos;t import bzrlib and dependencies. Please check bzrlib is on your PYTHONPATH. Traceback (most recent call last): File &quot;/home/joshstaiger/bin/bzr&quot;, line 62, in ? import bzrlib ImportError: No module named bzrlib Because we installed bzr in our home directory, the Python code behind bzr is living in a nonstandard location that Python can&apos;t see. We add this location to our Python library path by setting the PYTHONPATH environmental variable in our .bashrc. Modify .bashrc as follows: echo &quot;export PYTHONPATH=/home/joshstaiger/lib/python&quot; &gt;&gt; ~/.bashrc (replace &quot;joshstaiger&quot; with your shell login name) We&apos;ll also want the bzr manual to be in our MANPATH if it isn&apos;t already, so we can read about bzr in our spare time instead of picking up women: echo &apos;export MANPATH=$MANPATH:/home/joshstaiger/man&apos; &gt;&gt; ~/.bashrc Source .bashrc (or relogin) to pick up our changes: . ~/.bashrc Run it And we&apos;re set: ~$ bzr Bazaar -- a free distributed version-control tool http://bazaar-vcs.org/ Basic commands: bzr init makes this directory a versioned branch bzr branch make a copy of another branch bzr add make files or directories versioned bzr ignore ignore a file or pattern bzr mv move or rename a versioned file bzr status summarize changes in working copy bzr diff show detailed diffs bzr merge pull in changes from another branch bzr commit save some or all changes bzr log show history of changes bzr check validate storage bzr help init more help on e.g. init command bzr help commands list all commands bzr help topics list all help topics...</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Technology and Software</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<a href="http://www.flickr.com/photos/joshstaiger/273593468/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/116/273593468_46f543cdec_m.jpg" width="160" height="240" alt="hot_dog_stand_05.jpg" /></a>

<p><a href="http://bazaar-vcs.org/">Bazaar</a> or <code>bzr</code> is a Python-based source code management system that I've noticed is becoming increasingly popular amongst small open-source projects.</p>

<p>Right now I'm not sure what advantages <code>bzr</code> might have over other SCM systems such as Subversion (I suspect it's more light-weight), but it's handy to have when you want to grab the source for a project like <a href="http://intertwingly.net/code/venus/">Planet Venus</a>.</p>

<p>Here's how I installed <code>bzr</code> on my <a href="http://www.dreamhost.com/rewards.cgi?joshstaiger">Dreamhost</a> shell account.</p>

<p>(note: There's not anything special here.  This is all pretty standard Unix tarball installation fair.  In fact, there's little here that isn't already in the <code>bzr</code> installation guide.  I'm providing this as a confidence cushion for other Dreamhost users.)</p>

<h4>Fetch it</h4>

<p>Downloads of <code>bzr</code> are available here: <a href="http://bazaar-vcs.org/Download">http://bazaar-vcs.org/Download</a></p>

<p>Fetch the tarball install into a directory of your choice:</p>

<pre class="code">
~$ cd ~/incoming
~/incoming$ wget http://bazaar-vcs.org/releases/src/bzr-0.13.tar.gz
</pre>

<h4>Unzip it</h4>

<pre class="code">
~/incoming$ tar -zxvf bzr-0.13.tar.gz
</pre>

<h4>Install it</h4>

<pre class="code">
~/incoming$ cd bzr-0.13
~/incoming/bzr-0.13$ python2.4 setup.py install --home ~
</pre>

<p>No problem...</p>

<h4>Adjust environmental variables</h4>

<p>... except one hiccup when we try to run <code>bzr</code>:</p>

<pre class="code">
$ bzr
bzr: ERROR: Couldn't import bzrlib and dependencies.
Please check bzrlib is on your PYTHONPATH.

Traceback (most recent call last):
  File "/home/joshstaiger/bin/bzr", line 62, in ?
    import bzrlib
ImportError: No module named bzrlib
</pre>

<p>Because we installed <code>bzr</code> in our home directory, the Python code behind <code>bzr</code> is living in a nonstandard location that Python can't see.  We add this location to our Python library path by setting the <code>PYTHONPATH</code> environmental variable in our <code>.bashrc</code>.</p>

<p>Modify <code>.bashrc</code> as follows:</p>

<pre class="code">
echo "export PYTHONPATH=/home/joshstaiger/lib/python" >> ~/.bashrc
</pre>

<p>(replace "joshstaiger" with your shell login name)</p>

<p>We'll also want the <code>bzr</code> manual to be in our <code>MANPATH</code> if it isn't already, so we can read about <code>bzr</code> in our spare time instead of picking up women:</p>

<pre class="code">
echo 'export MANPATH=$MANPATH:/home/joshstaiger/man' >> ~/.bashrc
</pre>

<p>Source .bashrc (or relogin) to pick up our changes:</p>

<pre class="code">
. ~/.bashrc
</pre>

<h4>Run it</h4>

And we're set:

<pre class="code">
~$ bzr
Bazaar -- a free distributed version-control tool
http://bazaar-vcs.org/

Basic commands:

  bzr init           makes this directory a versioned branch
  bzr branch         make a copy of another branch

  bzr add            make files or directories versioned
  bzr ignore         ignore a file or pattern
  bzr mv             move or rename a versioned file

  bzr status         summarize changes in working copy
  bzr diff           show detailed diffs

  bzr merge          pull in changes from another branch
  bzr commit         save some or all changes

  bzr log            show history of changes
  bzr check          validate storage

  bzr help init      more help on e.g. init command
  bzr help commands  list all commands
  bzr help topics    list all help topics
</pre>
]]>

</content>
</entry>
<entry>
<title>links for 2007-01-13</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2007/01/links_for_20070.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2007-01-14T04:29:04Z</issued>
<id>tag:www.joshstaiger.org,2007://1.394</id>
<created>2007-01-14T04:29:04Z</created>
<summary type="text/plain"><![CDATA[ hello, world. meet scarlet. ecdysis: a lisp-like syntax for python (tags: programming python lisp webdev web) without an e: What python looks like naked [01/10/2007 14:35:29] "Although this code is ugly, writing it gave me a feel for the real power of a language like lisp." (tags: python programming computerScience functional lambda) Google Security Hole Allows Account Hijacking all Tony needed to do was make a user who&rsquo;s logged into their Google Account visit a page of his, which happened to be on a &ldquo;trustworthy&rdquo; google.com sub-domain (tags: google security) Surfin&rsquo; Safari - Blog Archive &raquo; CSS3 Multi-Column Support WebKit now has some very basic support for multiple columns from CSS3. (tags: webdesign webdev css) Stephen Colbert &ldquo;Flaccid with Rage&rdquo; over iPhone by Apple Gazette The iPhone has given the nerd community it's hardest collective wood since Princess Leia wore a bronze bikini. (tags: mac iPhone Humor Video) Bunny suicides Ripped from Andy Riley's excellent "The Book of Bunny Suicides" and "Return of the Bunny Suicides". (tags: cartoon humor cute)...]]></summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>General</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<ul class="delicious">
	<li>
		<div class="delicious-link"><a href="http://scarletlambda.org/">hello, world. meet scarlet.</a></div>
		<div class="delicious-extended">ecdysis: a lisp-like syntax for python</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/programming">programming</a> <a href="http://del.icio.us/joshstaiger/python">python</a> <a href="http://del.icio.us/joshstaiger/lisp">lisp</a> <a href="http://del.icio.us/joshstaiger/webdev">webdev</a> <a href="http://del.icio.us/joshstaiger/web">web</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://withoutane.com/rants/2007/what-python-looks-like-naked">without an e: What python looks like naked [01/10/2007 14:35:29]</a></div>
		<div class="delicious-extended">"Although this code is ugly, writing it gave me a feel for the real power of a language like lisp."</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/python">python</a> <a href="http://del.icio.us/joshstaiger/programming">programming</a> <a href="http://del.icio.us/joshstaiger/computerScience">computerScience</a> <a href="http://del.icio.us/joshstaiger/functional">functional</a> <a href="http://del.icio.us/joshstaiger/lambda">lambda</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://blog.outer-court.com/archive/2007-01-12-n73.html">Google Security Hole Allows Account Hijacking</a></div>
		<div class="delicious-extended">all Tony needed to do was make a user who&rsquo;s logged into their Google Account visit a page of his, which happened to be on a &ldquo;trustworthy&rdquo; google.com sub-domain</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/google">google</a> <a href="http://del.icio.us/joshstaiger/security">security</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://webkit.org/blog/?p=88">Surfin&rsquo; Safari - Blog Archive &raquo; CSS3 Multi-Column Support</a></div>
		<div class="delicious-extended">WebKit now has some very basic support for multiple columns from CSS3.</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/webdesign">webdesign</a> <a href="http://del.icio.us/joshstaiger/webdev">webdev</a> <a href="http://del.icio.us/joshstaiger/css">css</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://www.applegazette.com/weird/steven-colbert-flacid-with-rage-over-iphone/">  Stephen Colbert &ldquo;Flaccid with Rage&rdquo; over iPhone by Apple Gazette</a></div>
		<div class="delicious-extended">The iPhone has given the nerd community it's hardest collective wood since Princess Leia wore a bronze bikini.</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/mac">mac</a> <a href="http://del.icio.us/joshstaiger/iPhone">iPhone</a> <a href="http://del.icio.us/joshstaiger/Humor">Humor</a> <a href="http://del.icio.us/joshstaiger/Video">Video</a>)</div>
	</li>
	<li>
		<div class="delicious-link"><a href="http://freenet-homepage.de/schnubelken/bunnys/">Bunny suicides</a></div>
		<div class="delicious-extended">Ripped from Andy Riley's excellent "The Book of Bunny Suicides" and "Return of the Bunny Suicides".</div>
		<div class="delicious-tags">(tags: <a href="http://del.icio.us/joshstaiger/cartoon">cartoon</a> <a href="http://del.icio.us/joshstaiger/humor">humor</a> <a href="http://del.icio.us/joshstaiger/cute">cute</a>)</div>
	</li>
</ul>
]]>

</content>
</entry>
<entry>
<title>The iPhone is NOT a platform</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2007/01/the_iphone_is_n.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2007-01-12T08:51:03Z</issued>
<id>tag:www.joshstaiger.org,2007://1.393</id>
<created>2007-01-12T08:51:03Z</created>
<summary type="text/plain"> Ok, I was wrong. Looks like they will be fighting us every step of the way. *shrug* Steve just lost my willingness to give him $599 and put my balls in a vice grip with his carrier (which I otherwise would have done gladly, just to play in the new sandbox). I will, however, continue to write webapps that incidentally work well on his phone, safe in the knowledge they&apos;ll no longer have to be crippled to be mobile....</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Technology and Software</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<p><a href="http://www.flickr.com/photos/joshstaiger/284232682/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/121/284232682_a136530f48_m.jpg" width="240" height="160" alt="apple-store-times-square-02.jpg" /></a></p>

<p>Ok, I was wrong.</p>

<p>Looks like they <em>will</em> be fighting us <a href="http://rollerweblogger.org/roller/entry/iphone_don_t_think_of">every step of the way</a>.</p>

<p>*shrug*</p>

<p>Steve just lost my willingness to give him $599 and put my balls in a vice grip with his carrier (which I otherwise would have done gladly, just to play in the new sandbox).</p>

<p>I will, however, continue to write webapps that <em>incidentally</em> work well on his phone, safe in the knowledge they'll no longer have to be crippled to be mobile.</p>]]>

</content>
</entry>
<entry>
<title>The iPhone as a platform</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2007/01/the_iphone_as_a.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2007-01-10T02:47:48Z</issued>
<id>tag:www.joshstaiger.org,2007://1.392</id>
<created>2007-01-10T02:47:48Z</created>
<summary type="text/plain"> Tonight, every nerd I know is salivating over the iPhone. Obviously people are orgasmic over the sexyness: the form-factor, the fluid touch-screen, the (for serious!) smart calling software, the media apps, and the internet connectivity. But I think the real story here is we finally have a real platform for mobile application development, complete with real OS, real apis, and a real web browser capable of running real web applications - all delivered by a company that isn&apos;t going to fight us every step of the way. And the sexyness ensures it&apos;s going to be very popular. It almost sounds like the mobile platform we&apos;ve been waiting for for the past ten years! This is going to be big :)...</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Technology and Software</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<p><a href="http://www.flickr.com/photos/joshstaiger/284232979/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/116/284232979_dcb1375e8f_m.jpg" width="240" height="160" alt="apple-store-times-square-07.jpg" /></a></p>

<p>Tonight, every nerd I know is salivating over the <a href="http://www.apple.com/iphone/">iPhone</a>.</p>

<p>Obviously people are <a href="http://stevenf.com/2007/01/a_special_post_live_from_macworld.php">orgasmic</a> over the sexyness: the form-factor, the fluid touch-screen, the (for serious!) smart calling software, the media apps, and the internet connectivity.</p>

<p>But I think the real story here is we finally have a <em>real</em> platform for mobile application development, complete with <em>real</em> OS, <em>real</em> apis, and a <em>real</em> web browser capable of running <em>real</em> web applications - all delivered by a company that <em>isn't</em> going to fight us every step of the way.</p>

<p>And the sexyness ensures it's going to be <em>very</em> popular.  </p>

<p>It almost sounds like the mobile platform we've been waiting for for the past ten years!</p>

<p>This is going to be big :)</p>]]>

</content>
</entry>
<entry>
<title>Metaprogramming method closures in Ruby</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2006/12/metaprogramming.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2006-12-29T23:34:05Z</issued>
<id>tag:www.joshstaiger.org,2006://1.391</id>
<created>2006-12-29T23:34:05Z</created>
<summary type="text/plain"><![CDATA[ In my previous post, Of Closures, methods, procs, scope, and Ruby, I discussed how blocks and procs are closures in Ruby while methods are not. To review, this won't work: class MyClass @friend hello_string = "Hello" def initialize @friend = "Kitty" end def say_hello puts hello_string + " " + @friend # Bzzt! hello_string is not in scope end end my_object = MyClass.new my_object.say_hello # Bzzt! And neither will this (at the toplevel): hello_string = "Hello, world!" def say_hello puts hello_string # Bzzt! hello_string is not in scope end say_hello # Bzzt! In response Kurt hypothesized we could get method closures in Ruby with a bit of metaprogramming. And he's right. As Bryce points out, Ruby's Module class has a private method nammed define_method that defines a new method given a symbol representing its name, and a block representing its body. Because the second parameter is a block, and blocks can be closures, this gives us the key to defining method closures. Within the context of a class definition: class MyClass @friend hello_string = "Hello" def initialize @friend = "Kitty" end define_method(:say_hello) { puts hello_string + " " + @friend } end my_object = MyClass.new my_object.say_hello # Hello Kitty Yay! But suppose we want to define one-off methods from the top-level instead. Because define_method is private, normally we wouldn't be able to call it outside a class definition, but we can get around this using the send hack. Let's define a convenience method: def lexdef(method_symbol, &block) self.class.send :define_method, method_symbol, &block end And now we can define method closures from the toplevel: hello_string = "Hello" lexdef :say_hello do |friend| puts hello_string + " " + friend end say_hello "Kitty" # Hello Kitty Voil&agrave;! An unobtrusive syntax for defining method closures! I like it :) As of Ruby 1.8, blocks don't yet support Ruby's first-class syntax for receiving block arguments. So this won't work: hello_string = "Hello" lexdef :say_hello do |friend, &formalize| # Bzzt! Syntax error puts hello_string + " " + yield(friend) end say_hello("Kitty") { |friend| "Ms. " + friend } But word on the street is &block arguments to blocks will be supported in Ruby 1.9....]]></summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Technology and Software</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<a href="http://www.flickr.com/photos/joshstaiger/251935422/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/85/251935422_912ba7eaf7_m.jpg" width="240" height="180" alt="night01.jpg" /></a>

<p>In my previous post, <a href="http://www.joshstaiger.org/archives/2006/12/of_closures_met_1.html">Of Closures, methods, procs, scope, and Ruby</a>, I discussed how blocks and procs are <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)">closures</a> in Ruby while methods are not.</p>

<p>To review, this won't work:</p>

<pre class="code">
class MyClass
    @friend

    hello_string = "Hello"

    def initialize
        @friend = "Kitty"
    end

    def say_hello
        puts hello_string + " " + @friend  # Bzzt!  hello_string is not in scope
    end
end

my_object = MyClass.new

my_object.say_hello # Bzzt!
</pre>

<p>And neither will this (at the toplevel):</p>

<pre class="code">
hello_string = "Hello, world!"

def say_hello
    puts hello_string  # Bzzt!  hello_string is not in scope
end

say_hello # Bzzt!
</pre>

<p>In response <a href="http://www.joshstaiger.org/archives/2006/12/of_closures_met_1.html#comment758">Kurt hypothesized</a> we could get method closures in Ruby with a bit of metaprogramming.</p>

<p>And he's right.</p>

<p>As <a href="http://www.joshstaiger.org/archives/2006/12/of_closures_met_1.html#comment760">Bryce points out</a>, Ruby's <code>Module</code> class has a private method nammed <code>define_method</code> that defines a new method given a symbol representing its name, and a block representing its body.</p>

<p>Because the second parameter is a block, and blocks can be closures, this gives us the key to defining method closures.</p>

<p>Within the context of a class definition:</p>

<pre class="code">
class MyClass
    @friend
    hello_string = "Hello"

    def initialize
        @friend = "Kitty"
    end

    define_method(:say_hello) { puts hello_string + " " + @friend }
end

my_object = MyClass.new  

my_object.say_hello # Hello Kitty
</pre>

<p>Yay!</p>

<p>But suppose we want to define one-off methods from the top-level instead.</p>

<p>Because <code>define_method</code> is private, normally we wouldn't be able to call it outside a class definition, but we can get around this using the <a href="http://www.joshstaiger.org/archives/2006/12/the_ruby_send_h.html">send hack</a>.</p>

<p>Let's define a convenience method:</p>

<pre class="code">
def lexdef(method_symbol, &block) 
    self.class.send :define_method, method_symbol, &block
end
</pre>

<p>And now we can define method closures from the toplevel:</p>

<pre class="code">
hello_string = "Hello"

lexdef :say_hello do |friend|
    puts hello_string + " " + friend
end

say_hello "Kitty" # Hello Kitty
</pre>

<p>Voil&agrave;!  An unobtrusive syntax for defining method closures!</p>

<p>I like it :)</p>

<p>As of Ruby 1.8, blocks don't yet support Ruby's first-class syntax for receiving block arguments.  So this won't work:</p>

<pre class="code">
hello_string = "Hello"

lexdef :say_hello do |friend, &formalize|   # Bzzt!  Syntax error
    puts hello_string + " " + yield(friend)
end

say_hello("Kitty") { |friend| "Ms. " + friend }
</pre>

<p>But <a href="http://eigenclass.org/hiki.rb?Changes+in+Ruby+1.9#l11">word on the street</a> is &block arguments to blocks <em>will</em> be supported in Ruby 1.9.</p>]]>

</content>
</entry>
<entry>
<title>The Ruby send hack: how to gain access to an object&apos;s privates</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2006/12/the_ruby_send_h.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2006-12-28T18:06:06Z</issued>
<id>tag:www.joshstaiger.org,2006://1.390</id>
<created>2006-12-28T18:06:06Z</created>
<summary type="text/plain"><![CDATA[ I stumbled across an interesting Ruby hack that doesn't seem to be written down anywhere. It turns out that private methods in Ruby aren't entirely private, and with a bit of indirection you can gain access to them as though they were public methods. In Ruby 1.8 all we have to do is use the Object#send method. To demonstrate: class MyClass private def say_hello(name) puts "Let's go back to my place, #{name}." end end my_object = MyClass.new So we get smacked if we try: &gt; my_object.say_hello Nomethoderror: private method `say_hello' called for #&lt;MyClass:0x820b4&gt; from (irb):8 from :0 but instead: &gt; my_object.send :say_hello, "world" Let's go back to my place, world. Touch&eacute;! Now, honestly, this strikes me as odd. Conceptually, I don't see why send should function differently from an ordinary method call with respect to access control. The rubydoc for send says nothing of this, and there is some debate on the mailinglist as to whether Ruby 1.9's send will maintain this behavior. But for now this can be very useful if you disagree with a class designer's method access choices....]]></summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Technology and Software</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<a href="http://www.flickr.com/photos/joshstaiger/241157627/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/92/241157627_5923f9faeb_m.jpg" width="240" height="180" alt="lady_liberty01.jpg" /></a>

<p>I stumbled across an interesting Ruby hack that doesn't seem to be written down anywhere.</p>

<p>It turns out that private methods in Ruby aren't entirely private, and with a bit of indirection you can gain access to them as though they were public methods.</p>

<p>In Ruby 1.8 all we have to do is use the <code>Object#send</code> method.</p>

<p>To demonstrate:</p>

<pre class="code">
class MyClass
    private
    def say_hello(name)
        puts "Let's go back to my place, #{name}."
    end
end

my_object = MyClass.new
</pre>

So we get smacked if we try:

<pre class="code">&gt; my_object.say_hello
Nomethoderror: private method `say_hello' called for #&lt;MyClass:0x820b4&gt;
	from (irb):8
	from :0</pre>

but instead:

<pre class="code">&gt; my_object.send :say_hello, "world"
Let's go back to my place, world.</pre>

<p>Touch&eacute;!</p>

<p>Now, honestly, this strikes me as odd.  Conceptually, I don't see why <code>send</code> should function differently from an ordinary method call with respect to access control.</p>

<p>The <a href="http://www.rubycentral.com/book/ref_c_object.html#Object.send">rubydoc for <code>send</code></a> says nothing of this, and there is <a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/7404">some debate on the mailinglist</a> as to whether Ruby 1.9's <code>send</code> will maintain this behavior.</p>

<p>But for now this can be very useful if you disagree with a class designer's method access choices.</p>]]>

</content>
</entry>
<entry>
<title>Of closures, methods, procs, scope, and Ruby</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2006/12/of_closures_met_1.html" />
<modified>2008-10-20T08:12:17Z</modified>
<issued>2006-12-26T22:54:08Z</issued>
<id>tag:www.joshstaiger.org,2006://1.389</id>
<created>2006-12-26T22:54:08Z</created>
<summary type="text/plain"> One thing I hate about Ruby is that Ruby methods aren&apos;t closures. For instance, this blows up: hello_string = &quot;Hello, world!\n&quot; def say_hello puts hello_string # bzzt! hello_string isn&apos;t in scope end say_hello # bzzt! Which is a little odd because Ruby does support closures on procs: hello_string = &quot;Hello, world!\n&quot; say_hello = Proc.new do puts hello_string end say_hello.call # Hello, world! It kinda sucks that every time I want to create a closure I&apos;m forced to use the less succinct &quot;.call&quot; syntax. So why can procs be closures while methods cannot? After a bit of thinking I realized this comes down to a design tradeoff on whether or not we have to type &quot;self&quot; or &quot;this&quot; all over the place when writing methods as we do in Python and JavaScript. In Ruby we don&apos;t have to do this, and Ruby accomplishes this by making procs and methods two different things with different scoping rules. Proc bodies have a lexical scope like functions in Lisp and JavaScript, meaning that when Ruby encounters a free variable inside a proc body, its value is resolved within the context the proc was defined. This is what makes closures possible. Methods are different, however. A method&apos;s context is the object to which they are bound. When Ruby encounters a free variable inside a method body, it assumes the variable refers to another method on the object, and this is what saves us from having to prefix same-object methods with &quot;this&quot; or &quot;self&quot;. To demonstrate: irb(main):171:0&gt; hello_string = &quot;Hello, world!&quot; =&gt; &quot;Hello, world!&quot; irb(main):172:0&gt; def say_hello irb(main):173:1&gt; puts hello_string irb(main):174:1&gt; end =&gt; nil irb(main):175:0&gt; say_hello NameError: undefined local variable or method `hello_string&apos; for # from (irb):173:in `say_hello&apos; from (irb):175 from :0 irb(main):176:0&gt; def hello_string irb(main):177:1&gt; &quot;Hello, world!&quot; irb(main):178:1&gt; end =&gt; nil irb(main):179:0&gt; say_hello Hello, world! =&gt; nil Personally, I&apos;m not sure I like this tradeoff. Procs and methods are conceptually very similar. They are both composed of a list of arguments, a block of code, and a context in which the block is evaluated. I&apos;m not sure they should be different things. The way I see it, a method should just be a special case of proc that happens to have an implicit &quot;self&quot; parameter. In this case methods would inherit the proc scoping rules and therefore could be used as closures. If this means we have to be verbose and type &quot;self&quot; to call other methods on the same object, I&apos;m fine with that. And in fact, this is how things work in JavaScript: var helloString = &quot;Hello&quot;; var myObject = { friend: &quot;Kitty&quot;, sayHello: function() { print(helloString + &quot; &quot; + this.friend); } }; myObject.sayHello(); // Hello Kitty Matz clearly recognizes that there are issues with Ruby&apos;s current scoping implementation, so maybe this is one of them. But, hey, this kind of tradeoff may just be a Rubyish thing to do, and I probably dig closures more than most....</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Technology and Software</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<p><a href="http://www.flickr.com/photos/joshstaiger/285083229/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/122/285083229_12a8a33efb_m.jpg" width="160" height="240" alt="giant-piano-06.jpg" /></a></p>

<p>One thing I hate about Ruby is that Ruby methods aren't <a href="http://en.wikipedia.org/wiki/Closure_(computer_science)">closures</a>.</p>

<p>For instance, this blows up:</p>

<pre class="code">hello_string = "Hello, world!\n"

def say_hello
    puts hello_string # bzzt! hello_string isn't in scope
end

say_hello # bzzt!</pre>

<p>Which is a little odd because Ruby <em>does</em> support closures on procs:</p>

<pre class="code">hello_string = "Hello, world!\n"

say_hello = Proc.new do
    puts hello_string
end

say_hello.call # Hello, world!</pre>

<p>It kinda sucks that every time I want to create a closure I'm forced to use the less succinct ".call" syntax.</p>

<p>So why can procs be closures while methods cannot?</p>

<p>After a bit of thinking I realized this comes down to a design tradeoff on whether or not we have to type "self" or "this" all over the place when writing methods as we do in Python and JavaScript.</p>

<p>In Ruby we <em>don't</em> have to do this, and Ruby accomplishes this by making procs and methods two different things with different scoping rules.</p>

<p>Proc bodies have a <a href="http://en.wikipedia.org/wiki/Scope_(programming)#Static_scoping">lexical scope</a> like functions in Lisp and JavaScript, meaning that when Ruby encounters a <a href="http://en.wikipedia.org/wiki/Free_variables_and_bound_variables">free variable</a> inside a proc body, its value is resolved within the context the proc was defined.  This is what makes closures possible.</p>

<p>Methods are different, however.  A method's context is the object to which they are bound.  When Ruby encounters a free variable inside a method body, it assumes the variable refers to another method on the object, and this is what saves us from having to prefix same-object methods with "this" or "self".</p>

<p>To demonstrate:</p>

<pre class="code">irb(main):171:0> hello_string = "Hello, world!"
=> "Hello, world!"
irb(main):172:0> def say_hello
irb(main):173:1>     puts hello_string
irb(main):174:1> end
=> nil
irb(main):175:0> say_hello
NameError: undefined local variable or method `hello_string' for #<Object:0x359e4>
	from (irb):173:in `say_hello'
	from (irb):175
	from :0
irb(main):176:0> def hello_string
irb(main):177:1>     "Hello, world!"
irb(main):178:1> end
=> nil
irb(main):179:0> say_hello
Hello, world!
=> nil</pre>

<p>Personally, I'm not sure I like this tradeoff.</p>

<p>Procs and methods are conceptually very similar.  They are both composed of a list of arguments, a block of code, and a context in which the block is evaluated.  I'm not sure they should be different things.</p>

<p>The way I see it, a method should just be a special case of proc that happens to have an implicit "self" parameter.  In this case methods would inherit the proc scoping rules and therefore <em>could</em> be used as closures.</p>

<p>If this means we have to be verbose and type "self" to call other methods on the same object, I'm fine with that.</p>

<p>And in fact, this is how things work in JavaScript:</p>

<pre class="code">var helloString = "Hello";

var myObject = { 
    friend: "Kitty",
    sayHello: function() { 
        print(helloString + " " + this.friend);
    }
};

myObject.sayHello(); // Hello Kitty</pre>

<p>Matz clearly <a href="http://www.rubyist.net/~matz/slides/rc2003/mgp00010.html">recognizes</a> that there are issues with Ruby's current scoping implementation, so maybe this is one of them.</p>

<p>But, hey, this kind of tradeoff may just be a Rubyish thing to do, and I probably dig closures more than most.</p>]]>

</content>
</entry>
<entry>
<title>Real life search</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2006/12/real_life_searc.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2006-12-21T01:39:03Z</issued>
<id>tag:www.joshstaiger.org,2006://1.388</id>
<created>2006-12-21T01:39:03Z</created>
<summary type="text/plain">I love how whenever I lose something in my house, my first instinct is: Oh, no problem. I&apos;ll just do a search. And a short instant later... Goddammit!...</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Technology and Software</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<p>I love how whenever I lose something in my house, my first instinct is:</p>

<p><em>Oh, no problem.  I'll just do a search.</em></p>

<p>And a short instant later...</p>

<p><em>Goddammit!</em></p>]]>

</content>
</entry>
<entry>
<title>Five things you didn&apos;t know about me</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2006/12/five_things_you.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2006-12-19T03:30:31Z</issued>
<id>tag:www.joshstaiger.org,2006://1.387</id>
<created>2006-12-19T03:30:31Z</created>
<summary type="text/plain"> There&apos;s a massive game of tag going around the blogosphere. I&apos;ve been tagged by Bill and Dave. So here goes. Five things you didn&apos;t know about me: I all but gave up Computer Science in favor of law my junior year of college. I even convinced my friend Evan to do the same... except he actually did :) I&apos;ve been to London, Paris, Amsterdam, and Zurich, but only set foot west of the Mississippi in May of this year. I scored higher on the language portion of the SAT than the math portion. I play piano. I&apos;ve been skydiving... twice. I tag Ryan, Jeff, Kurt, Vinnie, and Anton....</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Matters that are otherwise worthwhile</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<p><a href="http://www.flickr.com/photos/joshstaiger/74323959/" title="Photo Sharing"><img src="http://static.flickr.com/38/74323959_1a72092a81_m.jpg" width="240" height="180" alt="starfish_dance01.jpg" /></a></p>

<p>There's a massive game of tag going around the blogosphere. I've been tagged by <a href="http://www-03.ibm.com/developerworks/blogs/page/BillHiggins?entry=five_things">Bill</a> and <a href="http://rollerweblogger.org/roller/entry/five_things">Dave</a>.</p>

<p>So here goes.  Five things you didn't know about me:</p>

<ol>
<li>I all but gave up Computer Science in favor of law my junior year of college.  I even convinced my friend <a href="http://evanperry.org/">Evan</a> to do the same... except he actually did :)</li>
<li>I've been to London, Paris, Amsterdam, and Zurich, but only set foot west of the Mississippi in <a href="http://www.joshstaiger.org/archives/2006/05/my_trip_to_cali_1.html">May of this year</a>.</li>
<li>I scored higher on the language portion of the SAT than the math portion.</li>
<li>I play piano.</li>
<li>I've been skydiving... <em>twice</em>.</li>
</ol>

<p>I tag <a href="http://www.ryanirelan.com/">Ryan</a>, <a href="http://uncledirtae.vox.com/">Jeff</a>, <a href="http://kurtiss.org/">Kurt</a>, <a href="http://www.vinnie.net/">Vinnie</a>, and <a href="http://mistersugar.com/">Anton</a>.</p>]]>

</content>
</entry>
<entry>
<title>On Variable Naming in Code</title>
<link rel="alternate" type="text/html" href="http://www.joshstaiger.org/archives/2006/12/on_variable_nam.html" />
<modified>2008-02-13T10:07:04Z</modified>
<issued>2006-12-15T13:37:30Z</issued>
<id>tag:www.joshstaiger.org,2006://1.386</id>
<created>2006-12-15T13:37:30Z</created>
<summary type="text/plain"> Much is made of the pain of typing long variable names (or function names or class names), but code is usually read more often than it&apos;s typed. And when I&apos;m reading code (even if it&apos;s my own), I&apos;m grateful for names that err on the side of descriptiveness. This means: navigationElement instead of navigation or nav queryString instead of query, queryStr, string, or str libraryLookupUrl instead of libraryLookup or url The exceptions are common language idioms which any programmer could reasonably be expected to know (ie: cons in Lisp, def in Python, x as an index into array loops). These should be abbreviated as their meaning is more intrinsic and independent of the name....</summary>
<author>
<name>Josh Staiger</name>
<url>http://www.joshstaiger.org</url>
<email>joshstaiger@gmail.com</email>
</author>
<dc:subject>Technology and Software</dc:subject>
<content type="text/html" mode="escaped" xml:lang="en" xml:base="http://www.joshstaiger.org/">
<![CDATA[<p><a href="http://www.flickr.com/photos/joshstaiger/261107921/" title="Photo Sharing"><img src="http://static.flickr.com/89/261107921_1f988e31ce_m.jpg" width="160" height="240" alt="night" /></a></p>

<p>Much is made of the pain of typing long variable names (or function names or class names), but code is usually read more often than it's typed. And when I'm reading code (even if it's my own), I'm grateful for names that err on the side of descriptiveness.</p>

<p>This means:</p>

<ul>
<li><code>navigationElement</code> instead of <code>navigation</code> or <code>nav</code></li>
<li><code>queryString</code> instead of <code>query</code>, <code>queryStr</code>, <code>string</code>, or <code>str</code></li>
<li><code>libraryLookupUrl</code> instead of <code>libraryLookup</code> or <code>url</code>
</ul>

<p>The exceptions are common language idioms which any programmer could reasonably be expected to know (ie: cons in Lisp, def in Python, x as an index into array loops). These should be abbreviated as their meaning is more intrinsic and independent of the name.</p>]]>

</content>
</entry>

</feed>
