Press "Enter" to skip to content

Month: July 2006

Ruby vs. Python (take 147)

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 double-quote marks. Typography is an important component of human communication, and Ruby’s, on balance, is cleaner.

John Gruber concurs:

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

As a Python programmer (but not a Ruby programmer), I have to say:

Huh?

I respect both Bray and Gruber, but I don’t see their point. At all.

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

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 not writing PyObjC code. (Maybe he’s writing more special operators than I am.)

As for quote marks (single or double), the only “barrages” 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 — e.g., as keys in dictionaries (hash tables) — where Ruby has an actual symbol type, whose syntax is borrowed from Lisp keywords (a prefixed colon).

Whereas if one wanted to criticize a language for “clumsy” punctuation, one might point to any of the fourteen-odd uses of non-alphanumeric symbols in Ruby found here: marking different kinds of variables with $, @, @@, and &; four kinds of “quoting mechanisms” with %X{..}; etc. (Is that Perl I hear calling?)

Perhaps that’s why neither Bray nor Gruber commented on the controversial use of @ in Python to mark the user of a decorator function.

So I have to say I just don’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’s fine; if I had to throw together a quick web application I might investigate Rails too. Perhaps it’s just that I came to Python first and don’t really know Ruby very well.

Still, to me, saying Ruby’s use of punctuation is “cleaner” than Python’s is (to paraphrase Gruber) like criticizing the iPod because it doesn’t come in white…

Leave a Comment

It's official: the Orioles stink (update: so does Tampa)

That must have been the worst half-inning in ten years.

Double, single, homer, triple, single, single, single, strikeout.

Exit R. Lopez. Hope we can get a sack of baseballs for you now…

Enter Birkins. Fly ball, homer, walk, homer, double. Exit Birkins.

The fourteenth batter of the inning strikes out. 10 runs, 10 hits. Break up the Rays…

you know, this could be a pretty good team if the pitching shaped up a little. we oughta get a good pitching coach, like the one the braves used to have all those years … what was his name again?

Update: apparently while I was writing this very entry the O’s went single, single (pitching change), walk, sac fly, walk, single, single (pitching change), walk, single, RBI ground out, single (pitching change), single, single, strikeout. Not as much power, but more productive outs. Sadly, one run fewer: 9 runs, 8 hits.

Then the Orioles got the bases loaded with no out the next inning and couldn’t score. And that leads to your final: 13-12, Tampa. (Apparently the O’s couldn’t quite get into field goal range before time ran out in the 9th.)

Leave a Comment

To boldly split infinitives is fine

From [Coudal](http://69.36.40.53/archives/2006/07/common_errors_i.php) via [John Gruber]() comes this [list of common non-errors](http://www.wsu.edu/~brians/errors/nonerrors.html) in English. The first item on the list is split infinitives, and of course they give as an example the most famous split infinitive in Modern English: *”… to boldly go where no man has gone before”* (to give it its original, non-PC reading).

I can’t be the first person to notice that this phrase is (nearly) in [iambic pentameter](http://en.wikipedia.org/wiki/Iambic_pentameter), which is the standard meter for blank verse in English. So “correcting” the grammar ruins the poetry of the phrase (such as it is), but I rarely see this pointed out. Both [William Shatner](http://en.wikipedia.org/wiki/William_Shatner) and [Patrick Stewart](http://en.wikipedia.org/wiki/Patrick_Stewart) were classically trained, so *they* must have noticed…

Leave a Comment