Q - Should I use Perl or Python?
Archive - Originally posted on "The Horse's Mouth" - 2008-07-23 17:38:13 - Graham EllisAn interesting question posed to me today - and not for the first time. And not for the first time, my answer had to be "tell me more about your application, and about the people who will be writing and maintaining it".

Perl is the ultimate "glueware" with the ability to link to virtually anything - it's been hevily used for a long time and is designed to be able to talk to technologies old and new. Python connectivity's pretty good too but it's not got quite the same wide range as Perl.
Perl has been provides with many ways of doing the same thing. Now while that's great in theory (and it's great in an environment where there are people spending most of their time writing and maintaining Perl, and they know the subtle differenceces), it's something of a nightmare in a scenario where code has been written by someone who's perhaps on holiday or has moved on, and/or where a particular way of doing something has been chosen because it's what the particulare code happened to know. Python, on the other had, has intentionally got a very limited number of ways of doing things - "that's a good alternative" was NOT used as an excuse to add something to the language.
Perl assumes you know what you are doing. Which if you do is fantastic - code can be written very fast indeed and got working very quickly - "far faster than in any other languagei" I could say ... but then if you're not entirely sure what you're doing Perl has some lovely traps that can extend you debugging cycle if you don't know the language very well, to the extent that development ends up being slower than Python.
Both languages include documentation systems - there's Perl's POD and Python's docstrings - and I'm delighted that both languages have something like this available, for it's important that your programs contain the executable code and programmer's comments anduser instructions.
Both languages originated in 1988. To remind you how long ago that is, it's the year of Perestroika (economic restructuring) in the USSR, and that same nation started their withdrawl from Afghanistan that year. Wimbledon won the FA Cup, and Stefan Edberg (now aged 42) and Steffi Graf (now aged 39) won the singles in the tennis at Wimbledon. It was 3 years before the announcement of Linux (25th August 1991) and 6 years before the very first website was created (7th October 1994). So both languages have a long pedigree.

Why, then, did Python take of slowly? In part because it's an "Object Oriented" scripting language [Today's article is not the place to sidetrack onto OO!] that burst (or perhaps just bubbled) into a world where scripting was structured coding if you were lucky. People weren't ready for it! In the case of Perl, it didn't start of as being an OO language - the OO features and capability were added in 1992 and to some extent had to be fashioned around the language as it then existed. But having said that, the OO model is very flexible. Result of all of this? You can write good code for medium sized to large projects in Perl, but you will - almost automatically - be pushed towards good coding if you use Python.
What conclusions can we draw?
1. It is far easier to maintain programming standards into the future in Python than it is in Perl - Perl provides lots of ways of doing things which means that you need a very strong and technical managegial setup to provide a framework in which to work if you're doing a lot of long term coding.
2. Thoroughly experienced programmers can develop and maintain quicker in Perl than in Python but the learning curve is a much longer one, and for most people the pendulum will swing towards Python (it certainly does for the customer who gave me the inspiration to write this article today).
Here's a view of a customer of ours, a great fan of the Python language who works for a company that's a "Perl shop". See how he confirms my statements ;-)
"Secretly, I do like Perl but I 'think' in Python, and hate the non-maintainability that I see in Perl programs of just a few hundred lines of code. I think Perl users have a style for one-liners that doesn't scale to larger Perl programs. People need to write larger Perl programs with maintenance in mind." - Donald McCarthy
Oh - I will ONLY run training courses in languages that I like, and for customers who I feel that the language they're learning is an excellent solution. And we provide both Perl Courses and Python Courses. My recommendation today was towards Python - "even though" that will cost me £500.00 per delegate in lower fees as the Python course is shorter [not so many alternatives and complexities to learn!] - but I would rather earn less or even loose a prospective customer completely than I would lead someone up a garden path!