On Being a Computer Language Omnivore

| Editorial

I grew up in a physics and astronomy environment, and I've always admired people who know a lot of different things and do them in a variety of different ways. That's why, when it comes to OSes, text editors or computer languages, I always try to learn something new for the sake of learning -- without picking sides or casting aspersions. (Unless it's Windows XP.)

I am in the process of learning Python. It's a very nice scripting language, but like any language, it has its own unique approach. That's not lost on me who's been a Perl nutcase for the last 17 years.

Perhaps the biggest issue surrounding Perl vs. Python (and perhaps Ruby) is this idea of the readability of code. Perl has been pigeonholed as a "write only" language. That is, you can write good Perl code, but no one else can read it. And neither can you, six months later.

In order to prove how bad Perl is, I have seen code on the Internet and -- Heaven save them -- at WWDC last summer where the speaker throws up some god-awful Perl code, perhaps pattern matching, to demonstrate the depravity of the language. Immediately after that, some very clean, equivalent Python code is displayed, leading the reader to conclude that the horrors of Perl are best avoided.

Of course, the speaker has an agenda, and that's about what one would expect. In fact, any computer language, if mastered, is a powerful tool, and those with great mastery don't worry much about such things.

For example, here's some code I found on the Internet that purports to show how bad Perl is in "slurping" a file -- and adds that Perl should be embarrassed. (Slurping is the art of reading a file as quickly and as simply as possible.)

local( *FH ) ;
open( FH, $file ) or die "Problem\n"
my $text = do { local( $/ ) ;  } ;

Then that was compared to Python: "Mindlessly simple."

fileContents = file("filename").read()

But then, no one I know of reads a file like that in Perl. The simplest slurp command in Perl is nice, indeed intuitive. Even Perl beginners, learn it right away.

@list = `cat filename`;

Another readability issue is this idea of variable prefixes. Perl distinguishes scalar variables from arrays and hashes (associative list, paired values in a list) with a prefix. So $a, @a and %a are different animals. In Python, variables are distinguished by how they're initially set. That leads to a clean, "C-like" code, but Larry Wall, the father of Perl, will tell you that there are sound, almost linguistic, reasons for designing Perl that way.

Basically, those programmers who are susceptible to this kind of symbol shock will hate Perl and those who master Perl think nothing of it. I don't.

There's more to it than even that. There are some who argue that the readability of code is paramount because employees come and go. Maintenance is paramount. But readability is a function of a trained eye. Those who are beginner programmers will love Python for its clean syntax. On the other hand, should the readability of code for beginners be an attribute that defines the power of a language for grey-beard programmers with years of experience. I think not.

This is why I learn new languages and appreciate them for what they are without condemning the competition. I suspect that those people who have the strongest, emotional attachments to a language, simply have a psychological preference for one way of doing things -- and they don't have the experience or introspection to appreciate the nuances of multiple languages. So they wail, and viciously condemn alternatives.

The same war continues between Java and C++, text editors, computer operating systems, vacation spots, football teams, you name it.

My own motivation is to learn how to write Cocoa apps with Python via the Cocoa bridge instead of Objective-C, not because I don't like Obj-C, but because I think Python is a language that has more career potential, and I've always wanted to learn it. I think scripting languages like Groovy, Ruby, Python and Perl are cool. I'd love to learn them all.

Calmly, with curiosity, admiration, scholarship and no bad attitudes, I hope to do so.

Popular TMO Stories



Nice article. It’s funny how little some things change.

Years ago, in pre-web times when 2400 baud modems were typical, I watched a lot of debate between C and Forth programmers. After learning both, I could see how easy it was for one side to demonize the other, when both languages had both strengths and weaknesses. Is a hammer better than a wrench? Depends upon what you’re doing.

These days when I look at a programmer’s resume I like to see a range of skills that demonstrates deep interest in the profession. If I find someone who knows both Java and C#, or who has worked in Windows but dabbled in some Unix variant or hacked together a Mac app, or a device driver programmer who’s played with SQLite just for the sake of learning it, I know I’ve found a solid technical performer. I also know they’re capable of learning whatever technology will roll out next year, simply because they enjoy learning.

Programmers need to spend less time debating and more time learning new things; they need to venture outside their comfort zone. It was true 25 years ago, and it’s still true today.

John Martellaro

Dave:  Well said!
  - J.M.


No reason not to learn both Objective-C and Python, and even F-Script, for doing Cocoa programming. Each has something unique to offer in its way of doing things. Be an omnivore. Don’t skip Objective-C for the sake of Python. (And you can certainly make a good living knowing Obj-C.)


Actually, forking two processes (sh and cat) to slurp a file is kinda wasteful. I’d go with

open(FD, $file);
unset $/;
$text = <FD>

although I prefer ruby myself.

Gareth Harris

Well John, like you I have been in factories, physics, computers, astronomy, etc. for a long, long time. To me, there are no sacred computers, OSes, languages, databases or networks IMHO - BUT I do like some more than others. Having been in controls and computers for about half a century [ouch!], my brain still retains a lot of obsolete and useless crap I hope to never see again. [I remember one computer made by a supercomputer manufacturer who will remain nameless (such as CDC) which had peripherals made by - you guessed it - Mattel. They were swell!]

Like you, I occasionally try to measure how many languages, OS, etc. I have been involved with too. Languages seems to be about 40 or 50. [maybe a plus, maybe another ouch!] And I have written too many compilers to have much sense left.

Meanwhile, I agree with your comments about appealing to some gimmick as a measure of a language - not meaningful. But I have noticed that few people have a vision of what the compiler/linker are doing anymore while you write a line of code. And of course the holy attitude of brainlock on OO is really getting tiresome! Sorry, Alan, but I think it is off the track you intended.

The only thing that still amazes me is the new and creative ways software gets worse and worse.

As to Python, the reason I use python so much now is because I am so productive in it AND it satisfies my urge for minimalism, readability & portability. Plus I can understand it a couple of years later.

Having said that, my current project is to learn Objective C for iPhone development. I must admit I like it a lot more than C++ or Java which have become disaster areas because of all the cooks in the kitchen.
[my love of minimalism again? Maybe we need an article on what happened to minimalism?]

BTW, I have begun converting SimPy from python to ObjC for use on the iphone - anybody interested?


@garethharris - By all means! While waiting for my wife to finish trying on clothes, I’ve often said that I need “an object-oriented, process-based discrete-event simulation language” for my iPhone smile

Gareth Harris

@ctopher - excellent parry & riposte! Aaargh - through the heart!!!!!

Actually, I intend to try some famous models on the iPhone if they are small enough to drive on a queueing simulator. Don’t know if the iPhone can pull the load yet, but I want to start with Randall Beer’s famous neuron driven cockroach.

Then you could play with roaches while your wife tries on clothes.

BTW, should I name the roach Topher?

John-avandia lawyer

I am so glad to read such a nice post, I was looking for such type of post since a long time. Thanks for the information. Happy valentines day

Log in to comment (TMO, Twitter or Facebook) or Register for a TMO account