In my earlier article, I described why I think that people should use easier languages (in particular Python) rather than more complex languages (in particular C++ and Perl). I did not go into detail about what I consider a complex language or one that produces unmaintainable code. One reader (so far) has asked for elaboration on these points.
First, let me say that there is no way that an article like this could convince everyone, everywhere. It is possible that there are some people whose brain is no naturally attuned to Perl that they would not recognize why so many people consider it difficult, complex or unreadable. Perl-brains, this article is not for you.
I have heard the argument that Perl is designed in a manner similar to natural languages. Unfortunately, natural languages are very difficult to learn. Once you put in the effort, the payoff is huge in terms of communicating with another human being, but the difficulty is still massive. Why would we make our interface with the computer similarly difficult? I do not believe that there is a similar payoff because millions of programmers achieve high productivity with simple, orthogonal languages.
Here are the properties that make the Perl language difficult to learn:
while (<>){
while ( /(.*?<!--)(.[^-]*)(.*$)/){
print $2."\n";
$_=$3;
}
}
This code was submitted to me as evidence of cool stuff you can do with a few lines of Perl code. Figuring out what it does is an exercise for the reader. It should be easy for the accomplished Perl programmer but for anyone else, I would suggest you proceed with a good Perl tutorial, not with a reference manual.
Perl tries to merge ideas from AWK, sed, C++ and other languages. Stealing ideas is not in and of itself a bad thing. The problem is that Perl does so in unbelievably bizarre ways. Perl reuses its runtime string evalution keyword as its exception handling construct. This causes no end of confusion. Perl supporters tell me that its reference feature and object oriented features are similarly bizarre. Perl literature is littered with apologies for why this stuff is so difficult but for a new programmer, excuses don't add up to much!
One of Perl's greatest fans agrees with me on this (and some other!) points.
When you read code that seems to be operating magically on information that you have not provided, what documentation do you consult to understand it? In general, implicit data and behavior is a special case of context specificity, but one that deserves special mention.
Obviously the language designer must have some special powers that language users do not. They must choose the basic syntax for the language for example. On the other hand, it is confusing if the built-in types and functions have features and behaviors that could not be implemented in a third-party library. It means that over time, newer types get "out of sync" with the built-in types.
All of these things make a language harder to learn and make the language's code harder to read. If you agree, and agree that Perl is harder to learn than it could be, and also harder to learn than Python, then I will direct you to the original article which argues that you (even as a hot-shot professional computer programmer) should choose to program in the language that is easier to learn.
Let me now make the argument from maintenance. Consider the following definition of "maintainable:"
That is one datapoint.Now try the same experiment where the programmers only have six months and then a single month to learn the language and solve the problem.
My feeling based on anecdotal evidence is that at all data points Python would win in a statistically representative experiment, but I have no way to conduct it. Even so, I supect that most readers that know both languages, even Perl fans, will agree with me.