I have no experience with Perl and therefore always choose to use Python. So far I've heard that they're in basics the same and that a project being programmed in Perl or Python is usually decided what the group/person starting the project is most comfortable with. I am wondering what the ups and downs are for choosing one over the other.
For those that are proficient with both, why/when do you choose Python over Perl?
whenever you have to write a quick and dirty script that uses regular expressions or that executes system commands. Perl has been designed for automating operations on files and file systems; in fact, in perl to use regular expressions or to call system commands you don't need to import anything, while in python, you need to import a library to do these operations.
perl programmers usually adopt the Unix Philosophy of "Make one tool that does only one specific task". This is the reason why most perl script don't even include functions, not to speak of objects. Each perl script must be written in order to execute a single task, and then the scripts are piped together through the Unix piping system. However, consider that this approach can lead to a lot of confusion, and is generally difficult to mantain. Moreover, you can do "One tool one task" in python, too; the only difference is that you will have to import sys in every script.
whenever you need to use a library available only for perl. Have a look at the modules in CPAN. I think that BioPerl is still slightly more complete than BioPython, and that there are more bioinformatics-oriented modules for perl than for python (unfortunately). The Ensembl APIs are also available only for perl.
When to use python:
whenever you need to use the script more than once.
whenever there is a even remote possibility that one of your colleagues or someone else will ever use your script.
whenever you need to use functions or objects. As I was saying before, the majority of perl scripts don't even include functions, because they are more difficult to write than in python. For example, in perl, you need to learn how to pass the reference to a variable, etc.. and this leads to scripts that are more difficult to understand (in perl).
if this is the first programming language you are learning, I suggest you to start with Python. Python is much cleaner than Perl, and is designed to respect some good practices that any programmer should know. Have a look at the Python Zen for some ideas.
Edit after 5 years:
Python has now support for tabular-like data structure (data frames), which are very important for data analysts. Use Python or R whenever you have to work with tables
Python has now excellent support for machine learning algorithms and data analysis in general. Use Python or R whenever you need to do one of these things.
After about 5 years of using Perl I've moved to Python. I can't really think of something I can do in Perl but not in Python. Python, in my opinion, is much cleaner than Perl and have the great advantage of being object oriented. Building modules is much easier in Python hence the code you write is more reusable.
I think very few people are completely agnostic about programming languages especially when it comes to languages with very similar strengths and weaknesses like: perl/python/ruby - therefore there is no general reason for using one language vs the other.
It is more common to find someone equally proficient in C and perl, than say equally proficient in perl and python. My guess would be that complementary languages require complementary skill sets that occupy different parts of the brain, whereas similar concepts will clash more easily.
You are totally correct with your initial assumption. This question is similar to choosing between Spanish and English, which language to choose? Well if you go to Spain,...
All (programming) languages are equal, in the sense of that you can solve the same class of problems with them. Once you know one language, you can easily learn all imperative languages.
Use the language that you already master or that suits your style. Both (Perl & Python) are interpreted languages and have their merits. Both have extensive Bio-libraries, and both have large archives of contributed packages.
An important criterion to decide is the availability of rich, stable, and well maintained libraries. Choose the language that provides the library you need. For example, if you want to program web-services (using SOAP not web-sites), you better use Java or maybe C#.
Conclusion: it does no harm to learn new languages.
And no flame wars please.
Python forces you to write cleaner code and gets you thinking about objects from the beginning, which should make the transition to object-oriented coding easier. If someone is new to programming, Python is likely the better choice. But that doesn't mean people, especially beginners, will automatically write code that can be easily understood by others. Perl only makes it easier for people to write confusing code.
If someone is already a competent Perl programmer, I don't think there's any overwhelming reason to switch. Most employers will understand that someone competent in one of those languages will quickly pick up the other. The time may be better invested learning Java or R scripting.
Like bioinformatics, many other areas share the problem of dealing with "big data" and Data Mining. In industry and computer science, Python (and Java) is more common than Perl in these areas. You may find programming in Python beneficial because you would be able to leverage the work and infrastructure of others in related fields.
Hi ! Here's a list of few areas which are important from point of view of Bioprogramming and the winner among Perl and Python in each :-
1) Ease of programming : Python[?]
2) Regex use and speed of execution of engine : Perl (Python will soon catch up with its 3.x)[?]
3) Bio* packages : Are available for both for Python and Perl, though here Python is the clear winner due to its inherent OOP philosophy.[?]
4) Syntax : Python any day (God, I don't know why people use Pseudocode when there's Python!). a geek joke says : "Perl is the only language whose code looks same before and after RSA encryption"[?]
5) Wrappers : Python has excellent SWIG wrappers for cross-language implementation of code. All popluar languages : C, Java and .NET have a combined distro with Python (Cython, Jython, IronPython etc.)[?]
6) Web programming : Ah! Here comes the most useful thing for Bioprogrammers, Perl CGI or Python ? With almost all bioinformatics knowledge housed in online biological databases, and with computing done by online tools, the choice of language for this one is important. I am once again not being biased towards Python, but apart from CGI functionality in both, Python's web frameworks are better than that of Perl (google these : web2py, Django etc). With these the development time gets reduced to half. Also, Python has an enhanced functionality in the form of ModPython and its even faster relative : ModPython Publisher. It gives performance as fast as PHP and even a C-CGI code.[?]