Perl or Python?

Madison Kelly linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Wed Jul 1 19:57:10 UTC 2009


Rajinder Yadav wrote:
> I am considering investing some time learning a script language to automate stuff etc.
> 
> Has anyone here used both/either perl and python? I would like to get their feel on which is better for writing powerful yet simple scripts? I am a C++ developer so I don't need to learn about programming, just want to know which of the two script is really easy to pick up and has all the module support I could ever need?
> 
> I assume python was designed to be object-oriented from the start and thus would lend to clean OO coding. Can python do everything perl can in terms of text manipulation and extraction?
> 
> comments, feedback welcome.
> 
> Kind Regards,
> Rajinder Yadav

As a perl coder, I've been told by many people that I should try python. :)

For what I gather, Python enforces more rigid coding style, so I think 
it is hard to shoot yourself in the foot. Also, people often tell me 
that it's language is much more "natural" compared to spoken English. 
I've decided that once I get to a point where I feel comfortable as a 
perl programmer (if), I will give Python a go.

As for Perl;

I think that people see it's strengths as it's weaknesses. It really 
enforces nothing. This can lend itself to very creative applications of 
the language. You can also drive yourself mad trying to find bugs 
because just about everything is a valid statement is some way or another.

For example, I recently beat my head against the wall for over an hour 
trying to figure out why:

my @months=["", "January", "February", "...", "December"];

Was not returning the month when I tried:

my $this_month=$months[2];

I expected "February", but got nothing. The reason? I was using square 
brackets '[]' instead of braces '()'. This was valid in perl, so no 
errors were generated. What I actually did was create an array whose 
first element was a reference to an anonymous array containing my 
months. To get the date out with the error in place, I would have had to 
say 'my $this_month=$months[0]->[2]'.

It comes down to personality, I think. I personally *love* the 
flexibility of perl and frequently exploit it's many quirks. to get 
complex issues done with relative ease. However, I am arguably quite 
crazy, too, so there you go. :)

No one will be able to answer for you what is best for you to learn. You 
will probably be best served by thinking of some problem you'd like to 
solve and then try solving that problem in both Python and Perl, and 
decide based on which you liked working in the most.

Best of luck!

Madi
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list