LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-26-2010, 10:45 AM   #1
vbx_wx
Member
 
Registered: Feb 2010
Posts: 181

Rep: Reputation: 16
Perl or Python ?


Whats its best to learn, Pear or Python ?
 
Old 08-26-2010, 10:52 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 240Reputation: 240Reputation: 240
This topic is subjective and argumentative. The only solution to your problem, is to learn both and then find the one best suited for yourself.

Last edited by ghostdog74; 08-26-2010 at 10:53 AM.
 
Old 08-26-2010, 12:02 PM   #3
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by vbx_wx View Post
Whats its best to learn, Perl or Python?
Perl gives you a lot of ways of doing essentially the same thing. This is a feature that Perl users are proud of.

Python is deliberately more terse, requires a specific type of indentation, and has no way of indicating the end of a function.

If you want ultimate flexibility at the cost of having to spend more time choosing which method you want to use to solve a problem, use Perl.

If you are more interested in solving problems quickly and don't mind being forced to write your code in a specific style, use Python.
 
Old 08-26-2010, 12:32 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
The difference is that Perl has in it much more from functional programming paradigm ( http://en.wikipedia.org/wiki/Functional_programming ). Python is slowly catching up (i.e. Python 3.* vs Python 2.*).

I find the functional features quite convenient.

This may sound odd, but in order to appreciate Perl read on Higher Order Perl: http://hop.perl.plover.com/ .
 
Old 08-26-2010, 02:56 PM   #5
b0uncer
Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
I'm learning both. I'd like to say "know", but as it is, there's so very much I don't master yet (in both languages) even though I do get results and have built up scripts/programs that are hundreds of lines long. The thing is, neither was very difficult to learn and neither took long to learn to use. Pros: I can now work with either of them, depending on which one I have available or want to use or suits better for the given situation. Cons: knowing only one would probably have been sufficient, so I've "thrown away" some time by learning both. Not a con really.

In short, learn both of them. You're not going to lose anything. Instead if you only learn either one, but not both, you very probably will be haunted by the thought "was this really the best choice?" for the rest of your life, or up to the point where you do learn the other as well.

Next question you're going to ask is "should I learn Python 2 or Python 3, or Perl 5 or Perl 6?". Answer: all of them
 
Old 08-26-2010, 03:37 PM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by b0uncer View Post
... Perl 5 or Perl 6?". Answer: all of them
I am looking at Perl6, and my feelings are getting sadder and sadder, even though they've made a usable release. The sad feelings about Perl 6 are coming from its early testers' reports - it is slow and bloated, though it shouldn't necessarily be.

And the main developer wrote that strict typing, when used, makes the code slower though conceptually it should enable faster code.

So, my intent to learn OCaml instead of Perl 6 steadily grows; Perl 5 is still my favorite language at the moment.
 
Old 08-26-2010, 05:14 PM   #7
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,324
Blog Entries: 3

Rep: Reputation: 86
Quote:
Originally Posted by b0uncer View Post
...
In short, learn both of them. You're not going to lose anything. Instead if you only learn either one, but not both, you very probably will be haunted by the thought "was this really the best choice?" for the rest of your life, or up to the point where you do learn the other as well.
...
Most programming languages are very similar. Make sure that you learn enough to be able to read both Perl and Python. Then read, read, ... read software learning coding styles and common patterns
of statements and expressions.

As with natural languages (English, Greek, Persian, etc), it is much harder to learn to speak and write the language than it is to hear and read that same language. As you read, you'll find that either Perl or Python suits your personal style.

Cheers,
~~~ 0;-Dan
 
Old 08-26-2010, 07:34 PM   #8
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 240Reputation: 240Reputation: 240
Quote:
Originally Posted by David1357 View Post
Perl gives you a lot of ways of doing essentially the same thing. This is a feature that Perl users are proud of.
there's more than one ways to do it. But some ways are not obvious and "beats around the bush" before solving the problem. There should be only just one obvious way to do it without beating about the bush.

Quote:
Python is deliberately more terse, requires a specific type of indentation, and has no way of indicating the end of a function.
Indentation to the first timer may seem irksome, but it all takes time to get used to. what do you mean by "doesn't know how to end a function"?
 
Old 08-26-2010, 07:57 PM   #9
pr_deltoid
Member
 
Registered: Jun 2010
Distribution: Fedora
Posts: 289

Rep: Reputation: 41
Quote:
Originally Posted by Sergei Steshenko View Post
So, my intent to learn OCaml instead of Perl 6 steadily grows;
Do you have any specific problems with Ruby? It seems like a very good language to me, and it borrows ideas from Python, Perl, Smalltalk, etc. I've been having a hard time making a decision between Ruby and Python, but Python is used so much and for so many different things that it seems like a better language to learn as far as existing software being written in it or using it.
 
Old 08-26-2010, 08:04 PM   #10
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,442

Rep: Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880Reputation: 1880
I am in the learn as much as you can group, although as pointed out in earlier posts this can make it difficult to become a guru in any language
quickly. I agree with Dan's post too that most languages use a commonish ground work (not trying to start a flame here) so to this end you can also look at it that
if you become accomplished in one language it will generally be less of an arduous task to learn another.
 
Old 08-26-2010, 08:28 PM   #11
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by prdeltoid View Post
Do you have any specific problems with Ruby? It seems like a very good language to me, and it borrows ideas from Python, Perl, Smalltalk, etc. I've been having a hard time making a decision between Ruby and Python, but Python is used so much and for so many different things that it seems like a better language to learn as far as existing software being written in it or using it.
I am using Perl since 1993 or 1994. Until very recently Ruby used to be very slow.

What can Ruby do Perl can't ? I mean not only built-in functions, but things like closures, anonymity, scoping rules and the like.

...

I've been looking closely at Perl6 because I want a language which allows both loose and strict typing - Perl6 allows. It looks like I'll look for strict typing in OCaml, and will still be using Perl5 for loosely typed programs.

Last edited by Sergei Steshenko; 08-26-2010 at 08:31 PM.
 
Old 08-26-2010, 08:48 PM   #12
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by ghostdog74 View Post
... There should be only just one obvious way to do it without beating about the bush. ...
Because as a person who knows Perl I also know that a string can be split both using 'split' and regular expression, and because Python allows both these ways two, there is more than one way to it in Python too.
 
Old 08-26-2010, 09:26 PM   #13
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 240Reputation: 240Reputation: 240
Quote:
Originally Posted by Sergei Steshenko View Post
Because as a person who knows Perl I also know that a string can be split both using 'split' and regular expression, and because Python allows both these ways two, there is more than one way to it in Python too.
wrong. Python's split doesn't allow regular expression. It shows you don't know Python enough to fairly comment on this. If one wants to use regex, he has import the re module and then use re.split(). Python's design encourage one to produce consistent code.

An example out of the many, see this FAQ for Perl to count substrings. True to Perl's mantra, there are a few ways to do it as stated in the FAQ.
With Python, there is only one obvious way (note the word obvious),
Code:
>>> string = "ThisXlineXhasXsomeXx'sXinXit"
>>> string.count('X')
6
Another example, you can open filehandles with 2 ways, one with brackets, one without
Code:
open FILE, '<', "foo.txt" or die "Can't open: $!";
open(FILE,"<foo.txt") or die "....";
In Python, you only need to use one way.
Code:
open('foo.txt')
These are examples of why Perl can encourage inconsistency in code programming.

you really have no reason to argue with me on this point of "more than one ways in Perl vs that in Python", if you have used Python long enough as you had used Perl.

Last edited by ghostdog74; 08-26-2010 at 11:01 PM.
 
Old 08-26-2010, 10:18 PM   #14
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by ghostdog74 View Post
wrong. Python's split doesn't allow regular expression. ...
I didn't mean that. I meant that using regular expressions (not in the 'split'' function) a string can be split - because matches in regular expression can be collected in buffers (what in Perl is called $1, $2, etc).

So, conceptually there is a 'split' way to split a string and a regular expression way to split a string - both way are present in both langauges.

So, as I said, there is more than one way to do it.
 
Old 08-26-2010, 10:36 PM   #15
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 240Reputation: 240Reputation: 240
Quote:
Originally Posted by Sergei Steshenko View Post
So, as I said, there is more than one way to do it.
There's more than one way to do it, but sometimes consistency is not a bad thing either (TIMTOWTDIBSCINABTE). You can follow TIMTOWTDI mantra all you want, that's your business and i don't care.

Last edited by ghostdog74; 08-26-2010 at 10:45 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Vs python knockout_artist Linux - Newbie 6 10-15-2008 11:06 AM
perl vs python yenonn Programming 6 08-01-2006 05:44 AM
Perl or Python JJX Programming 4 04-17-2006 02:42 PM
Perl or Python JJX Programming 6 10-27-2004 03:58 AM
Perl or Python ! linuxlover1 Programming 13 04-19-2004 07:33 AM


All times are GMT -5. The time now is 08:34 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration