LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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-23-2007, 12:07 PM   #1
raghuveerbabu
LQ Newbie
 
Registered: Aug 2007
Posts: 20

Rep: Reputation: 0
Smile Perl and Python


Hi all,
What're all the advantages of perl and phyton languages? For what purpose, they're usefull?
Thanks.
 
Old 08-23-2007, 01:54 PM   #2
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,743
Blog Entries: 4

Rep: Reputation: 76
They are both general-purpose languages, which essentially means they can both be used for pretty much anything other than low-level systems programming (ie: operating systems, device drivers). My personal preference is for Python (Actually Ruby, but given only two choices...).

Perl tends to be tightly integrated with the OS, and so works well for sysadmin shell scripts. Its strong regex support also means it works well for filtering text, creating reports from data etc. On the downside Perl (IMHO anyway) is very difficult to read/understand, especially after stepping away from the code for a while.

Python's greatest strength may be its huge standard library (ie: 'batteries included'), clean readable syntax, and it is useful for quickly prototyping software (that may or may not have parts re-written in another language later).

Again, IMHO Ruby has the best of both worlds, so that seems to be what I use the most these days, but you should generally try to find the best tool for a particular job.

Lots more reading at http://python.org and http://perl.org
 
Old 08-23-2007, 02:17 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
I was once marginally competent in C. Now, 25+ years later, I am learning Python. It is a great langauge, but I'm not yet smart enough to say why it's better than something else. One thing that did get my attention was the robust C interface--eg the ability to make specific modules in C (where speed is an issue).

I would apply the rule we had in the motorcycle repair shop--"If it works, it's OK."
 
Old 08-23-2007, 04:05 PM   #4
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by pixellany View Post
"If it works, it's OK."
it doesn't work this way unfortunately..at least that's what i think.

Last edited by ghostdog74; 08-23-2007 at 04:09 PM.
 
Old 08-23-2007, 04:08 PM   #5
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by raghuveerbabu View Post
Hi all,
What're all the advantages of perl and phyton languages? For what purpose, they're usefull?
Thanks.
your question will slowly lead to a language war. here's 2 things for you:
1) search google for this topic..try "Perl vs Python" for a start.
2) Learn both, and see the advantages for yourself. that's the best way.
 
Old 08-23-2007, 06:02 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Quote:
Originally Posted by ghostdog74 View Post
it doesn't work this way unfortunately..at least that's what i think.
Welllll...it sure did for the 1960s motorcycles....--especially the British models where 8 weeks to order parts was the norm. (We made our own parts)

Any examples of something that works that's NOT OK?? Note I never said "best"---just OK.
 
Old 08-23-2007, 07:02 PM   #7
choogendyk
Senior Member
 
Registered: Aug 2007
Location: Massachusetts, USA
Distribution: Solaris 9 & 10, Mac OS X, Ubuntu Server
Posts: 1,189

Rep: Reputation: 105Reputation: 105
Quote:
Originally Posted by ghostdog74 View Post
your question will slowly lead to a language war. here's 2 things for you:
1) search google for this topic..try "Perl vs Python" for a start.
2) Learn both, and see the advantages for yourself. that's the best way.
I second all of that. I've learned a bit of both, more of perl, but I wouldn't call myself fluent in either. I've been more of a sysadmin than a developer in recent years.

Because I'm more a sysadmin, and I'm into minimal systems, I've shifted more to perl. If you just want to learn programming, python would probably be a better place to start. The batteries included comment by bulliver would apply if you wanted to do something with a graphical interface for example.

Learning a language is partly learning the concepts and ideas of programming in general, and then adding another language is almost like translating and is easier. In my early years, I could claim to program in over 20 full languages (not scripting environments) and to be fluent in about half a dozen. Because of the incremental ease of learning yet another, that's not as hard as it may sound.

So, if you're just starting and want to learn a language, dive into python. If you tend toward the sysadmin, start learning perl. You'll need it anyway, and it turns out that quite a few open source programs that you might install have perl components and utilities even though the main program may be in C or C++.
 
Old 08-23-2007, 09:24 PM   #8
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by pixellany View Post
Any examples of something that works that's NOT OK?? Note I never said "best"---just OK.
yes. regular expressions for example. however, please excuse me for not posting elaborations on this. thks
 
Old 08-23-2007, 09:29 PM   #9
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 241Reputation: 241Reputation: 241
Quote:
Originally Posted by choogendyk View Post
Because I'm more a sysadmin, and I'm into minimal systems, I've shifted more to perl.
i am a sysadmin too, however, i have shifted from Perl to Python, have converted all my scripts to Python and have never regretted since. My codes are more readable by other fellow sysadmins now. $0.02
 
Old 08-24-2007, 08:30 AM   #10
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,269

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
Well, Perl has a large library of pre-written modules at search.cpan.org.
As has been said before, you can write good or unreadable code in any lang. It's down to the dev to be disciplined.
Have a look at both.
 
Old 08-24-2007, 08:45 AM   #11
trashbird1240
Member
 
Registered: Sep 2006
Location: Durham, NC
Distribution: Slackware, Ubuntu (yes, both)
Posts: 463

Rep: Reputation: 31
Quote:
Originally Posted by raghuveerbabu View Post
Hi all,
What're all the advantages of perl and phyton languages? For what purpose, they're usefull?
Thanks.
My input:

Both are useful for just about everything you can do with a computer. However, you can do many of the simpler things they are both good at with other tools (see below).

My own experience was this:
1) I learned Python to learn programming in general; I did a few cool things like a program that deals poker hands and stuff like that. However, I failed to see anything useful in it, and most of the promotion went over my head, as it was aimed at people who already knew how to program, .e.g., in C++. I actively avoided Perl.
2) I picked up Perl because the documentation I read ("Learning Perl") showed me right away something I could use it for: processing text files. I perfected a program that takes comma-separated-values and turns them into LaTeX tables.
3) That Perl program was ugly. It worked, and it worked well, however after a while of tweaking, the code was incomprehensible: I really had trouble finding where I had done what, despite all my comments. Then I realized that Perl was overkill; so I redid it in AWK.

Now I am a big fan of shell-scripting. For any task that would be too much to enter command-by-command, or that is too complex for a single command, I write a script in sh or zsh if I want fancy globbing or error-prone pattern matching on filenames.

So, my take on scripting languages as of now: Perl is "shell on steroids", i.e., a lot of things you can do with Perl can be done with sed, grep, awk and Co tied together with the shell of your choice (you can also tie these tools together with Perl, but that is redundant). If all you are doing is processing text, in particular, and you don't need to access system resources, connect to a database or any of that (which incidentally can be done in zsh), then consider using shell instead of Perl or Python. If you want anything above that level, then consider what your priorities are as a programmer: do you want compact, elegant code? Or do you want "there's more than one way to do it?"

I highly recommend Learning Perl for Perl and Classic Shell Scripting for shell scripting, both from O'Reilly.

Joel
 
  


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
Python or Perl drdroid Programming 29 12-22-2006 09:54 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 05:22 AM.

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