<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Russell Finn&#039;s Weblog &#187; Python</title>
	<atom:link href="http://russellfinn.com/category/programming/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://russellfinn.com</link>
	<description>…another proud member of the reality-based community.</description>
	<lastBuildDate>Sun, 29 Nov 2009 02:32:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>OCPython, anyone?</title>
		<link>http://russellfinn.com/2008/12/05/ocpython-anyone/</link>
		<comments>http://russellfinn.com/2008/12/05/ocpython-anyone/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 18:54:53 +0000</pubDate>
		<dc:creator>rsfinn</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.sprucehill.com/rsf/blog/?p=112</guid>
		<description><![CDATA[As dynamic scripting languages become more widely used, many developers are interested in using them to write &#8220;native&#8221; Mac OS X software, rather than having to learn Objective-C (which, of course, is a dynamic language in its own right).  And in fact it is often possible to do so, using Apple&#8217;s BridgeSupport to generate [...]]]></description>
			<content:encoded><![CDATA[<p>As dynamic scripting languages become more widely used, many developers are interested in using them to write &#8220;native&#8221; Mac OS X software, rather than having to learn Objective-C (which, of course, is a dynamic language in its own right).  And in fact it is often possible to do so, using Apple&#8217;s <a href="http://bridgesupport.macosforge.org/">BridgeSupport</a> to generate the necessary metadata.  Apple explicitly supports bridges for Ruby (<a href="http://rubycocoa.sourceforge.net/">RubyCocoa</a>) and Python (<a href="http://pyobjc.sourceforge.net/">PyObjC</a>).</p>

<p>Nevertheless, there is necessarily an impedance mismatch between the runtime models &#8212; when passing objects to Cocoa, the bridge must convert the object from the dynamic language&#8217;s runtime to an Objective-C object derived from NSObject, and vice versa.  This introduces a certain amount of inefficiency, which is not normally a big problem, but it would be desirable to avoid it.</p>

<p>Now, over the last few months, I&#8217;ve seen a variety of projects to do this by using the Objective-C 2.0 runtime to implement the object model for the dynamic language.  In other words, objects in the dynamic language <em>are</em> subclasses of NSObject and no conversion is necessary.</p>

<p>These range from the venerable <a href="http://www.fscript.org/">F-Script</a>, which is even closer to Smalltalk than Objective-C, to Tim Burks&#8217; original language <a href="http://programming.nu">Nu</a>, which uses a Lisp-like syntax.  I believe I&#8217;ve seen a reference to a JavaScript implementation as well, but I can&#8217;t seem to find it now.</p>

<p>The project that seems to be getting the most buzz in the Mac community right now is <a href="http://www.macruby.org/">MacRuby</a>, a port of Ruby 1.9 done by the developer of RubyCocoa (who is also an Apple employee).  There was even a <a href="http://developer.apple.com/mac/articles/scriptingautomation/cocoaappswithmacruby.html">article</a> about it featured on the Apple developer site recently.</p>

<p>Conspicuous by its absence from this list is my preferred dynamic language Python.  I would love to see an implementation of Python hosted on the Objective-C runtime.  I&#8217;ve always felt Python&#8217;s language model was a good match for Cocoa (of course, PyObjC not only predates BridgeSupport but even Cocoa itself, going back to the days of NextStep), and I&#8217;m personally more familiar with it than Ruby or other dynamic languages.  So it seems like a logical step to take.</p>

<p>This project couldn&#8217;t be called MacPython, because that name has already been used to denote the Mac port of Python.  For now I&#8217;m calling it &#8220;OCPython&#8221;, but I&#8217;m certainly open to a cleverer name (especially if there&#8217;s one that can riff on IronPython; unfortunately the element most associated with Mac OS X is Carbon, which is entirely wrong for this project).</p>

<p>I&#8217;ve been thinking about which version of Python to use as a jumping-off point; originally I was leaning towards 2.5 because it&#8217;s the version shipped with Leopard, but now I&#8217;m persuaded by <a href="http://www.friday.com/bbum/2008/11/11/autozone-the-objective-c-garbage-collector/#comment-189318">Bill Bumgarner&#8217;s comment</a> to use 3.0 and take advantage of the revised, less crufty implementation.  (This is based on the stated goal of the 3.0 development project; I haven&#8217;t actually looked at the source code yet.)</p>

<p>I wish I could say I&#8217;m prepared to get the project off the ground myself, but right now I&#8217;m between jobs, as they say, and given the current financial situation I&#8217;m actively looking for full-time employment and can&#8217;t dedicate much time to something that won&#8217;t bring in any revenue.  (Of course, if anyone out there would like to <em>fund</em> development of OCPython, contact me immediately.)</p>
]]></content:encoded>
			<wfw:commentRss>http://russellfinn.com/2008/12/05/ocpython-anyone/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Ruby vs. Python (take 147)</title>
		<link>http://russellfinn.com/2006/07/25/ruby-vs-python-take-147/</link>
		<comments>http://russellfinn.com/2006/07/25/ruby-vs-python-take-147/#comments</comments>
		<pubDate>Tue, 25 Jul 2006 16:54:45 +0000</pubDate>
		<dc:creator>rsfinn</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.sprucehill.com/rsf/blog/2006/07/25/ruby-vs-python-take-147/</guid>
		<description><![CDATA[Tim Bray, a new student of Ruby, admires it for its readability, and compares it to Python:


  In theory, Python ought to do better, lacking all those silly end statements cluttering up the screen. But in practice, when I look at Python code I find my eyes distracted by a barrage of underscores and [...]]]></description>
			<content:encoded><![CDATA[<p>Tim Bray, a new student of Ruby, <a href="http://www.tbray.org/ongoing/When/200x/2006/07/24/Ruby">admires it</a> for its readability, and compares it to Python:</p>

<blockquote>
  <p>In theory, Python ought to do better, lacking all those silly end statements cluttering up the screen. But in practice, when I look at Python code I find my eyes distracted by a barrage of underscores and double-quote marks. Typography is an important component of human communication, and Ruby&rsquo;s, on balance, is cleaner.</p>
</blockquote>

<p>John Gruber <a href="http://daringfireball.net/linked/2006/july#mon-24-bray_ruby">concurs</a>:</p>

<blockquote>
  <p>Now that I think about, those underscores and extra quotes are exactly why Python does not appeal to me. I find Python&rsquo;s indentation-as-block rule to be quite elegant, but its use of punctuation feels clumsy.</p>
</blockquote>

<p>As a Python programmer (but not a Ruby programmer), I have to say:</p>

<p>Huh?</p>

<p>I respect both Bray and Gruber, but I don&#8217;t see their point.  At all.</p>

<p>When I look at my Python code, I see underscores in two contexts.  The first is in the names of &#8220;special&#8221; methods and attributes. In practice for me, this is largely limited to <code>__init__</code>, since I rarely need to overload operators.  (And this syntax makes such identifiers stand out as &#8220;special&#8221;.  Who&#8217;s to say that this is less attractive than Ruby&#8217;s use of <code>$</code> to mark global variables?  Are underscores uglier than dollar signs?)</p>

<p>The second, more common use of underscores in my code is in long Cocoa method names, because by convention in PyObjC they replace the colons in the Objective-C selectors.  Those underscores are generally acknowledged as ugly by the PyObjC community, but accepted as a necessary evil.  I suspect Tim Bray is <em>not</em> writing PyObjC code.  (Maybe he&#8217;s writing more special operators than I am.)</p>

<p>As for quote marks (single or double), the only &#8220;barrages&#8221; I can think of are in multi-line string literals, which are frequently used as documentation strings (or comments, effectively).  I suppose this criticism might come from the common use of string literals as symbols &#8212; e.g., as keys in dictionaries (hash tables) &#8212; where Ruby has an actual symbol type, whose syntax is borrowed from Lisp keywords (a prefixed colon).</p>

<p>Whereas if one wanted to criticize a language for &#8220;clumsy&#8221; punctuation, one might point to any of the fourteen-odd uses of non-alphanumeric symbols in Ruby found <a href="http://www.rubygarden.org/faq/entry/show/137">here</a>:  marking different kinds of variables with <code>$</code>, <code>@</code>, <code>@@</code>, and <code>&amp;</code>; <em>four</em> kinds of &#8220;quoting mechanisms&#8221; with <code>%X{..}</code>; etc.  (Is that Perl I hear calling?)</p>

<p>Perhaps that&#8217;s why neither Bray nor Gruber commented on the controversial use of <code>@</code> in Python to mark the user of a <a href="http://www.python.org/dev/peps/pep-0318/">decorator</a> function.</p>

<p>So I have to say I just don&#8217;t get it.  To each his own, I guess.  I see that Ruby is getting a lot of buzz these days, in large part because of the success of Rails, and that&#8217;s fine; if I had to throw together a quick web application I might investigate Rails too.  Perhaps it&#8217;s just that I came to Python first and don&#8217;t really know Ruby very well.</p>

<p>Still, to me, saying Ruby&#8217;s use of punctuation is &#8220;cleaner&#8221; than Python&#8217;s is (to paraphrase Gruber) like criticizing the iPod because it doesn&#8217;t come in white&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://russellfinn.com/2006/07/25/ruby-vs-python-take-147/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyWikit</title>
		<link>http://russellfinn.com/2006/06/22/pywikit/</link>
		<comments>http://russellfinn.com/2006/06/22/pywikit/#comments</comments>
		<pubDate>Thu, 22 Jun 2006 19:09:12 +0000</pubDate>
		<dc:creator>rsfinn</dc:creator>
				<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.sprucehill.com/rsf/blog/2006/06/22/pywikit/</guid>
		<description><![CDATA[In response to a challenge in the Mac forum at Ars Technica, I&#8217;ve banged out a quick service that adds &#8220;Search With Wikipedia&#8221; to your Services menu (right below &#8220;Search With Google&#8221;).  It&#8217;s called PyWikit because (a) somebody suggested &#8220;Wikit&#8221; for the name and (b) I wrote it in Python, using PyObjC.

To use it, [...]]]></description>
			<content:encoded><![CDATA[<p>In response to a <a href="http://episteme.arstechnica.com/eve/forums?a=tpc&amp;s=50009562&amp;f=8300945231&amp;m=165004279731&amp;r=130002579731#130002579731">challenge</a> in the Mac forum at Ars Technica, I&#8217;ve banged out a quick service that adds &#8220;Search With Wikipedia&#8221; to your Services menu (right below &#8220;Search With Google&#8221;).  It&#8217;s called <a href="http://www.sprucehill.com/rsf/software/python/PyWikit.service.zip">PyWikit</a> because (a) somebody suggested &#8220;Wikit&#8221; for the name and (b) I wrote it in <a href="http://www.python.org">Python</a>, using <a href="http://pyobjc.sourceforge.net">PyObjC</a>.</p>

<p>To use it, <a href="http://www.sprucehill.com/rsf/software/python/PyWikit.service.zip">download</a> it and move it to your ~/Library/Services folder.  At the moment you will probably have to log out and log in again to update your Services menu.  If I get motivated I&#8217;ll build an installer, someday.  (Unlikely since I&#8217;ve only spent about an hour on this, most of which was taken up building a universal binary for PyObjC.  While it is true that PyObjC rocks, its universalness is still a little, uh, rocky.)</p>
]]></content:encoded>
			<wfw:commentRss>http://russellfinn.com/2006/06/22/pywikit/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
