A reader commented that
…the syntax of Perl is so hideous and mysterious it produces unmaintainable code (I know having maintained a multi-tier Perl webapp).
And, sadly, he’s not the only one that shares that belief. Perl has been written off by many talented developers because essentially every piece of Perl code they’ve ever encountered is, well, crap. But, when you get right down to it you’re basing your opinion of a language based on what people write with it. It’s like saying that the English language sucks because there are so many vile and crappy things written in it.
Perl is quite possibly the most flexible modern programming language. But, as with anything, great power comes with great responsibility. Perl geeks believe “There’s more than one way to do it.“ where as Python geeks follow a slightly different way
The Python philosophy [is] that “There should be one– and preferably only one –obvious way to do it.” That is, I can write a multitude of programs that do exactly the same thing in python in different styles and methods, but there is only one way that is Pythonic… What Python does is emphasize a standard quality and method for doing various tasks instead of just hacking it together. - Alexander Botero-Lowry
So, if you’re working with undisciplined idiots, there’s no question, choose a language like Python. But, what happens when the Pythonic way of expressing an idea doesn’t quite mesh with the idea you are trying to express?
In Python you’ll generally just have to deal and find a way of coding what you wanted to express that isn’t very “Pythonic” or that ends up being more verbose. In Perl there’s probably another handful of ways to express the same concept. It’s like always having a kick ass thesaurus available.
Yes, this means you’ll eventually speak with words other people aren’t familiar with yet or do things in ways others may not be so kosher with. But Perl is all about letting you work in whatever way / style feels best to you. This can obviously lead to situations where different people don’t agree with how something’s been implemented even if it’s very sensible. What you need to keep in mind though, is that the readability and maintainability are the direct result of the experience, discipline, and consideration given for other developers by the person writing the code.
The problem with Perl is that it makes it incredibly easy for a person with no discipline or limited experience to express themselves badly… very badly. Combine that with the fact that it’s so easy to get something that works in Perl when you haven’t a clue how to code well in any language and the problem just compounds itself.
It is very easy to write readable and maintainable Perl code, but to do so requires discipline. It’s the difference between giving a kindergartner a generous palette of oil paints and giving one to Michelangelo. The paint is capable of producing a masterpiece in his hands, but the kindergartner is just going to make a finger-paintey mess. Don’t blame the paint. Likewise, don’t blame Perl for the crap that idiots and newbs produce with it. Instead, go buy them a copy of Code Complete and make every-one’s life a little bit better.
And yes, before anyone mentions it, Perl’s OOP tools seem a bit hackish and can feel bolted on. But once you start to understand how they work they’re incredibly flexible and let you do things that you couldn’t hope to touch in Java. And yes, Perl does have a number of funky looking operators like $# but you really only need to know a few of them. If you don’t like them you’ll be happy to know that they weren’t too thrilled with the number of them when they started planning Perl 6. Speaking of which, there are some truly awesome things that have been put into Perl 6 and they’ve cleaned up a lot of the syntactic issues people frequently bitch about…but there will still always be more than one way to do “it” so you’ll still be able to write ugly code if you don’t know any better.
A note about Python: Python rocks. It just has a very different mindset to Perl. Python isn’t a language for “undisciplined idiots” as I implied above, but it is a better language to have undisciplined idiots coding in because while their code may still be crap you’ll at least be able to read it because of the formatting limitations and the intentionally limited number of choices for how to do any given thing.