I remember that when I was in school learning C++ (as the default language they taught at the time) I had a strong aversion to Java. I even got into a debate or two about C’s virtues when compared to Java’s. This is funny to me now because I’ve been doing professional Java programming for five years and probably couldn’t write a decent C program if I tried (not that I could then probably).
One of the things I noticed when I finally switched from C to Java was that a simple network socket program that took a page of code in C could be done in a couple of lines in Java. Neat. It wasn’t why I switched (that had to do with my interest in metadata and Java’s clear dominance in that domain), but I can’t say I minded the convenience either.
Lately, I’ve been seeing a lot of people comparing Python’s brevity to Java’s verbosity. At the conference today, I chatted with a fellow (who will be presenting a paper on SVG and music notation tomorrow) who works in Python. The first thing he said to me when I mentioned that I work in Java was “how verbose Java is.”
Not that this isn’t true. Java is more verbose than Python. It’s ironic, though, because I always see the same example illustrating this point (which Dorothea Salo, whose blog I love, just reproduced in her blog (so I’ll pick on her as the latest example of this, well, example)).
The ironic thing is that there is a way to do the same thing in the current version of Java just as concisely:
for (String string : list) System.out.println(string);
That will work with a list:
List <String> = Arrays.asList(new String[] {"a","b"});
or an array:
String[] list = new String[] {"a", "a"};
<teasing>So, what is it? Aren’t there better examples out there? Why do we keep seeing the same one?</teasing>
I have nothing against Python, mind you. It is the language I’m (very) slowly learning on the side (when I have time or a quick need for something). I also have no interest in getting into a language war. Those are rather pointless because they tend to devolve into techeological discussions (I’m proud I was able to work that word into a post, albeit in its negative sense).
I guess, though, what I’m getting at (I had to think for a second to remember where I was going with all this) is that brevity is not really going to convince me to change from one language to another. There are many more factors that, well, factor into my choice (for instance a good IDE and available resources (3rd party libraries)). After all, come on, think about it… aren’t you still reading this post? Couldn’t I have said what I wanted to say already (in much fewer words)?
Let’s face it… I like to write. Sometimes I regret what I write. Sometimes I feel uneasy about what I have written (thinking it makes me look like a fool (and sometimes it does)), but I’m not afraid of putting pen to paper (so to speak)… well, okay, sometimes I am afraid (but saying that doesn’t convey as much bravado — which is what I was going for there).
So anyway, for me, brevity != productivity. The equation isn’t that simple. This isn’t to say that I don’t (on occasion) want to work in Python (how’s that for a double negative?). I do… but it’s not because it’s concise… come on… (though, I admit, convenience is sometimes nice!)

Posts