python vs perl lines of code

Edward Elliott nobody at
Thu May 18 01:29:55 CEST 2006

brian d  foy wrote:

> You have to note that rewriting a program, even in the same language,
> tends to make it shorter, too. These things are measures of programmer
> skill, not the usefulness or merit of a particular language.

I completely agree.  But you have to start somewhere.
> Shorter doesn't really mean anything though, and line count means even
> less. The number of statements or the statement density might be
> slightly more meaningful. Furthermore, you can't judge a script by just
> the lines you see. Count the lines of all the libraries and support
> files that come into play. Even then, that's next to meaningless unless
> the two things do exactly the same thing and have exactly the same
> features and capabilities.

For an objective measure of which language/environment is more optimal for a
given task, your statement is completely accurate.  OTOH for a 
quick-and-dirty real-world comparison of line counts, and possibly a rough
approximation of complexity, the libraries don't matter if they offer
more-or-less comparable functionality.  Especially if those libraries are
the standard ones most people rely on.

I'm not attaching any special significance to line counts.  They're just a
data point that's easy to quantify.  What if anything do they mean?  How
does one measure statement density?  What's the divisor in the density
ratio - lines, characters, units of work, etc?  These are all interesting
questions with no easy answers.

> I can write a one line (or very short) program (in any language) that
> does the same thing your scripts do just by hiding the good stuff in a
> library. One of my friends likes to talk about his program that
> implements Tetris in one statement (because he hardwired everything
> into a chip). That doesn't lead us to any greater understanding of
> anything though.

Of course.  Extreme cases are just that.

Edward Elliott
UC Berkeley School of Law (Boalt Hall)
complangpython at eddeye dot net

More information about the Python-list mailing list