zedin
Posts: 38
Joined: Tue Oct 18, 2011 1:20 pm

Python or perl? (co-workers know perl)

Mon Sep 10, 2012 11:00 pm

So a bit of background.. I am a biologist who's job is starting to get into bioinformatics. We have several scripts written for us in python for some of the data analysis (large text files of sequence). The conundrum I have is do I learn python or perl to make/tweak tools for our use.

At our company we have several programmers who are great with perl but have never touched python. On the otherhand I hear how much better python can be in terms of readability and function. I doubt I have the time to devote to learn both right now (doing this on my own time).

Do folks suggest going with perl and in-house expertise for asking questions or the more readable and clear python?

JustThisGuy
Posts: 114
Joined: Thu Jan 05, 2012 11:22 pm

Re: Python or perl? (co-workers know perl)

Mon Sep 10, 2012 11:17 pm

A couple of thoughts. (Oh, grohd I'm stepping into a language war. :o )

Does your organization have a preference? Even different departments within organizations often have differing tastes in languages.

Since Perl is slightly :D older than python there is a slew of modules that do just about anything, some of those things surprisingly well. If there's a perl module that does the data crunching you need, use it. Then when you've got it up and running you can port it to python. Vice versa for python modules.

Past that, your post implies a preference for python. Go with your preference of language.
Any conversation about a sufficiently complex subject is indistinguishable from babble.

stevech
Posts: 144
Joined: Sun Jul 15, 2012 11:53 pm

Re: Python or perl? (co-workers know perl)

Tue Sep 11, 2012 1:39 am

I've just done my first non-trivial work using Python. (decades of software writing in ASM, C/C++, Pascal, VB, VBS, Jscript, and many others, mostly on microprocessors).

Python was thrust upon me, not a choice.
It is fairly portable. Avoid Python 3 for now. Stick with v2.4 or stretch for 2.7.

The indented style of Python (no braces or semi-colons) was so odd to me, but an hour or two later, I got it, with the help of a Python-specific IDE tool.

So if it's NOT web page/HTML oriented, and you don't want to use Microsoft VB script.net (a great but proprietary tool), and not Javascript, and not Java (a computer science trip), then Python is a good choice. If you get paid to be an ex-spurt in other than programming, and scripts are just a means to an end, then why not VB script.net? Or Visual Basic itself. Or MATLAB.

The issue with all script languages, Python, VBS, JS, etc., is that there's little design-time source code checking. You write the program, test a little, then if its use repeatedly, esp. by others, it hits a case that causes heretofore code to run and blow up. That's maddening. Repulsive. Happens with scripting. It's the ying and yang of scripting, which is sort of like skipping the advice "if it's work doing, it's worth doing right", i.e., programming versus hacking a throw-away script.

If the code is for analysis is for algorithms or data-reduction for an experiment, maybe MATLAB is a better choice.

So, as ever, it depends.
But I wouldn't elect to use Perl today.

The Matthew
Posts: 1
Joined: Tue Sep 11, 2012 7:11 pm

Re: Python or perl? (co-workers know perl)

Tue Sep 11, 2012 7:35 pm

My personal preference is Perl, simply because I found it far and away the easiest to learn of all the languages I've used. But really you should use the language you're most likely to be able to use again in your environment. However, if the work involves pattern matching Perl is probably the only sensible choice, as pattern matching is a fundamental part of the language. Matching complex expressions and extracting the interesting parts is as easy in Perl as comparing two numbers is in other languages.

It's probably best to ignore any arguments based on readability. Python supporters in particular seem to love to characterise Perl as an unreadable language but they do so by contrasting well-written Python with badly-written Perl, and often from the viewpoint of someone who knows Python but not Perl. Well-written code in either language is easy to read and badly-written code in either language is incomprehensible even to people who know it.

brs
Posts: 70
Joined: Fri Aug 17, 2012 9:27 pm
Location: Zurich

Re: Python or perl? (co-workers know perl)

Tue Sep 11, 2012 8:20 pm

Python and Perl are reasonably equivalent and differ more in style than in substance. Maybe that's why there are so many heated religious arguments between the advocates of either language. [Disclaimer: I clearly prefer Python over Perl]

The Python philosophy favors readability and regularity over saving a few key-strokes and advocates that there should be ideally be one standard way to do any one thing. Perl is incredibly terse and flexible and advocates that there should be many ways to do any one thing, so that anybody can develop their preferred idiom and dialect.

If you want to learn a more systematic approach to software development, build up a non-trivial application over a long period of time and still be able to read and understand your code after you haven't touched if for 6month, then you should probably favor Python. If you want to learn how to manipulate and slice data very quickly in all kinds of interesting and non-obvious ways and are more interested in getting results quickly than in the long-term maintainability of the code, then you should favor Perl. In balance though it's probably easier to write readable code in Perl than it is to do quick and dirty data analysis scripts in Python.

User avatar
piglet
Posts: 915
Joined: Sat Aug 27, 2011 1:16 pm

Re: Python or perl? (co-workers know perl)

Tue Sep 11, 2012 9:00 pm

Python and Perl are reasonably equivalent and differ more in style than in substance. Maybe that's why there are so many heated religious arguments between the advocates of either language. [Disclaimer: I clearly prefer Perl over Python]

Yes, you can write totally unitelligable stuff in Perl. Then again I can do the same with a ball point pen without any effort. It's not the pen's fault. I've written Perl one-liners in seconds that would have taken my collegues most of the day to do in their preferred language, and also lovely beautifully written verbose maintainable code where needed.

My motto is "anything but Java".

zedin
Posts: 38
Joined: Tue Oct 18, 2011 1:20 pm

Re: Python or perl? (co-workers know perl)

Tue Sep 11, 2012 11:16 pm

Thanks for the input all. As it stands I think I am just going to learn both =p My boss agreed to let me take a bit of work time to learn the stuff since I am using it to make tools we are going to use so I might be able to fit both into my schedule. Think I am going to start with python since nobody here knows it and learn perl on the side by picking apart what other co-worker is making for our group base on our needs (so I have examples that are applicable to what we want).

(MATLAB and others is probably not the best option for what I am doing which is basically tons of text file manipulation and comparisions; just 10gig text files...)

User avatar
piglet
Posts: 915
Joined: Sat Aug 27, 2011 1:16 pm

Re: Python or perl? (co-workers know perl)

Fri Sep 14, 2012 9:43 am

For text manipulation perl is probably more suited. That's my main use of Perl: dragging information kicking and screaming out of huge masses of poorly formatted data.

Return to “General programming discussion”