October 2, 2011 at 11:44 PM by Dr. Drang
A reader1 asks:
It seems like everywhere I look people are pushing the Ruby programming language… What reasons are you using Python? Is it because of certain characteristics of the language itself or because you are more familiar with it (due to coming from a Perl background)?
A fair question, and I’m going to pretend that my answer is worth knowing.
Ruby is the it scripting language and has been since Rails came out several years ago. I’ve tried it in the past and—mainly because of MacRuby—will probably try it again. But there are things about Ruby that set my teeth on edge.
First, though, the titular question: why do I use Python? I can’t say my reasons for switching from Perl were entirely rational, but it was some combination of:
- The feeling that Perl 5 was a dead end (that had an awful object syntax) but that Perl 6 would never come online. The years have proved me right about Perl 6. Perl 5 isn’t the dead end I thought it would be, but it isn’t the vibrant language it was in the 90s, either.
- The no braces, no semicolons, no begin/end syntax. I think the people who hate Python’s use of indentation to denote structure are nuts. Unless you’re writing one-liners, you’re going to use indentation—why not take advantage of that to get rid of all the nonfunctional characters?
- The “batteries included” philosophy of the standard Python distribution. There’s seldom a question of which library to use; you use the one that came with Python.
- The NumPy package and the adoption of Python by many scientists and engineers. This turned out to be a false reason, as I’ve never used NumPy. But when I was thinking about which language to switch to, NumPy and SciPy were pluses for Python.
from __future__ import divisionstatement. This seems really stupid, but I hate when a scripting language tells me that 1/2 is zero instead of 0.5. I suppose this comes from my being an engineer instead of a programmer; I almost never use integer arithmetic and don’t like it when I have to think about how my language is going to interpret a simple division. In fact, I tried Python a couple of times in the 90s—before the
__future__module—and gave up because integer division mistakes were so frustrating. I was happy to see that Guido recognized his initial mistake and made floating point division the default in Python 3.
Items 2 and 3 (and yes, 5) are why I still use Python.
What annoys me about Ruby? Small things, mostly, some silly, some substantive:
- Integer division, obviously. That Ruby uses it seems especially odd to me, because Ruby is obviously and outgrowth of Perl, which uses floating point division. This is a case of Matz not learning from Larry Wall’s example.
requiresound like they should do the same thing. I know that if I used Ruby enough, I’d learn the difference (and probably just use
require99% of the time), but the seeming similarity bothers me.
- The ever-changing notion of the “right” way to do things. Maybe this is just the ignorance of an outsider, but it seems to me that Ruby best practices are a fast-moving target. For example, I get that the
gemsystem is the standard way to install modules, but I don’t see how a newcomer to the language is supposed to know whether
require 'rubygems'is a good idea or not.
- The accretion of tools built upon tools. This is similar to my previous complaint. When I read about some clever Ruby library/utility that I might consider using, the installation instructions often refer to
rmvor some other add-on. I appreciate that experienced, expert Rubyists can get a lot of leverage out of these tools, but they’re a barrier to entry for newcomers.
I know the solution to my problems with Ruby is to just dive in and start bulling my way through—the best way to learn a new system is to just keep using it. So far, though, I just haven’t had the need to stick with Ruby long enough to get comfortable. This is going to change. There once was a time when I thought PyObjC would let me write Mac-like programs in Python, but it’s clear now that MacRuby is the better choice. I need to expand.