LinuxQuestions.org
Help answer threads with 0 replies.
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 01-21-2011, 06:20 AM   #1
ajeesh.tr
Member
 
Registered: Jan 2011
Posts: 37

Rep: Reputation: 0
Question Perl vs Python which is easier to learn


i want to learn a scripting language,which one should i go for ,among perl and python.
 
Old 01-21-2011, 06:28 AM   #2
eSelix
Senior Member
 
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281

Rep: Reputation: 320Reputation: 320Reputation: 320Reputation: 320
Python is better for you. It learns good looking code.
 
Old 01-21-2011, 06:48 AM   #3
ajeesh.tr
Member
 
Registered: Jan 2011
Posts: 37

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by eSelix View Post
Python is better for you. It learns good looking code.
Am new to scripting if somebody could suggest me how to start that will be great
 
Old 01-21-2011, 07:13 AM   #4
teebones
Member
 
Registered: Aug 2005
Location: /home/teebones
Distribution: sometimes this, sometimes that..
Posts: 502

Rep: Reputation: 56
the python website?
http://wiki.python.org/moin/BeginnersGuide
 
Old 01-21-2011, 12:11 PM   #5
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 476Reputation: 476Reputation: 476Reputation: 476Reputation: 476
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 01-21-2011, 12:14 PM   #6
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,375

Rep: Reputation: 5389Reputation: 5389Reputation: 5389Reputation: 5389Reputation: 5389Reputation: 5389Reputation: 5389Reputation: 5389Reputation: 5389Reputation: 5389Reputation: 5389
Quote:
Originally Posted by teebones View Post
And when you're finished that,

http://www.diveintopython3.org/
 
Old 01-21-2011, 12:35 PM   #7
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by eSelix View Post
Python is better for you. It learns good looking code.
I saw some ugly Python code. Excessive use of '.' doesn't look good to me - regardless of language.

And you haven't touched the features yet - Python is slowly catching up with Perl (e.g. closures are there, but not yet lexical scope and anonymity).
 
Old 01-21-2011, 09:42 PM   #8
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by Sergei Steshenko View Post
I saw some ugly Python code. Excessive use of '.' doesn't look good to me - regardless of language.
that's Object orientation for you. Perl pales Python in that respect.
Code:
>>> s="a string"
>>> s[1:-1].replace("s","S")[0:-2]
' Str'
now, try doing that in Perl.
Perl is ugly by default. Excessive use of $,%, @ to denote array/hashes and variables.

Quote:
And you haven't touched the features yet - Python is slowly catching up with Perl (e.g. closures are there, but not yet lexical scope and anonymity).
No beginner is going to start learning lexical closures blah blah first. OP is new to scripting. There are many areas Perl lack as compared to Python as well. Perl is never going to catch up to Python in regards to readability and code maintenance.

FWIW, I would even recommend Ruby instead of Perl if OP has a choice between another language besides Python.

Last edited by ghostdog74; 01-21-2011 at 09:43 PM.
 
Old 01-21-2011, 10:18 PM   #9
theKbStockpiler
Senior Member
 
Registered: Sep 2009
Location: Central New York
Distribution: RPM Distros,Mostly Mandrake Forks;Drake Tools/Utilities all the way!GO MAGEIA!!!
Posts: 1,001

Rep: Reputation: 53
I'm not an expert but this may help.

It looks like you either want an easy to learn and get started with interpreted language that is common or one that is much, much more involved.

You are going to discover that there are a couple of languages you want to learn and then there are the ones that you end up learning. Python is recommended as being easy to learn and is held in high reguards by hackers.More Hackers choose to hack with Python. There are plenty of intentionally comprehensive guides and tutorials for Phython as well. Perl is more involved and you can do more with it but you are not going to automatically benefit by just trying to learn Perl and hit two birds with one stone. I don't think that Perl is recommended as a first language. If you can't get it done with Bash why not think of Java script? It's popular ,it's Linux and it's interpreted. Python was the first Language I studied and I pretty much learned close to nothing compared to C with it. Python is a way more higher of a Language than C. For a first Language I don't think Pascal should be overlooked but I think the common versions are compiled. There probably was a interpreted version of it at one time. I personally would not recommend a OOP language for a first Language because you won't realize how ridiculously abstracted OOP is.
 
Old 01-21-2011, 10:47 PM   #10
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by theKbStockpiler View Post
Perl is more involved and you can do more with it
more involved and can do more? like what ?
 
Old 01-23-2011, 01:12 PM   #11
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by ghostdog74 View Post
that's Object orientation for you. Perl pales Python in that respect.
Code:
>>> s="a string"
>>> s[1:-1].replace("s","S")[0:-2]
' Str'
now, try doing that in Perl.
Perl is ugly by default. Excessive use of $,%, @ to denote array/hashes and variables.


No beginner is going to start learning lexical closures blah blah first. OP is new to scripting. There are many areas Perl lack as compared to Python as well. Perl is never going to catch up to Python in regards to readability and code maintenance.

FWIW, I would even recommend Ruby instead of Perl if OP has a choice between another language besides Python.
Don't give a damn about object orientation. Furthermore, mostly refuse to think in a patchy manner (base + delta1 + delta2 + ... deltaN) manner - "how reusable, how unusable" (c).

Of course, $,%, @ are helpful - they help to understand what kind of thing it is

Code:
s[1:-1].replace("s","S")[0:-2]
- not quite readable.

In Perl:

Code:
sergei@amdam2:~/junk> perl -e '$s = "a string";warn do{$s=~s/s/S/;substr($s, 1, 4)};'
 Str at -e line 1.
 
1 members found this post helpful.
Old 01-23-2011, 01:15 PM   #12
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
http://blogs.perl.org/users/jeffrey_...with-perl.html - and a recent thread in this forum about things working in earlier Python version, but not a later one - I read about Python regularly breaking things elsewhere.
 
Old 01-23-2011, 06:49 PM   #13
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Quote:
Originally Posted by Sergei Steshenko View Post
Don't give a damn about object orientation.
you talked about excessive use of dot. I merely say they are just part of OO. I don't give a damn whether you care about OO or not.

Quote:
Of course, $,%, @ are helpful - they help to understand what kind of thing it is
they are just junk noise. Makes code hard to read.

Quote:
Code:
s[1:-1].replace("s","S")[0:-2]
- not quite readable.
more readable than ugly Perl as shown in your Perl equivalent example.

Quote:
In Perl:

Code:
sergei@amdam2:~/junk> perl -e '$s = "a string";warn do{$s=~s/s/S/;substr($s, 1, 4)};'
 Str at -e line 1.
not quite. Take a look at my code again. I want to get from 2nd character to last 2nd character of the string first, before I do the replacement. You will have to do an equivalent substr for that. And no, i am not emphasizing on the output.
 
Old 01-23-2011, 08:09 PM   #14
alpha01
Member
 
Registered: Jul 2008
Location: Orange County
Distribution: Ubuntu/Debian, CentOS, RHEL, FreeBSD, OS X
Posts: 75

Rep: Reputation: 19
Quote:
Originally Posted by ajeesh.tr View Post
i want to learn a scripting language,which one should i go for ,among perl and python.
Ruby

Enough said :-)
 
Old 01-23-2011, 08:46 PM   #15
binary_pearl
Member
 
Registered: Jul 2007
Location: Chicago Illinois
Distribution: SLES 10 SP2/SP3, SLES 11 SP1, OpenSUSE, Sabayon, Gentoo, Fedora 14, RHEL 3/4/5/6
Posts: 98
Blog Entries: 3

Rep: Reputation: 23
It really depends on the problem that you are trying to solve. I find learning a language for the sake of learning a language is not an effective way to remember it. It's more effective to use a language to solve a particular problem. If you don't have a specific problem...create one Maybe there are tasks you want to automate with getting input from a web site, or maybe you are looking to parse output to do something with it.

perl is my main weapon of choice, because my job is heavily based on local, server-side scripting. perl allows me to develop scripts rapidly; from configuring networking to watching VM's go down, to parsing output from many different commands. This is especially useful when only about 5% of my day can be spent on coding.

python, I haven't used as much, but my understanding is that it's more suited for object oriented programming and possibly web programming. (I'll let the python advocates speak more to this ). Perl code can get ugly if the script gets too large. python may inherently be able to handle this situation better.

Debating the subtle semantics of the languages though isn't going to help the original poster decide which language to use. The best thing is identify what the poster wanted to solve, and then give them suggestions on which language would be best to use. One that's determined, it's probably best to go to google and type "$language tutorial" and start following a tutorial to start learning the language in question.

--Shaun
 
1 members found this post helpful.
  


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
What to learn?.. HuMmMm.. Python? Perl? jhyland87 Programming 20 03-04-2010 02:11 PM
What is easier to learn/setup GRsecurity or SELinux? (OT) avalonit Linux - Security 5 11-16-2009 09:46 AM
What is easier to learn/setup GRsecurity or SELinux? abefroman Linux - Security 10 11-15-2009 07:38 AM
Documents to learn C language and Perl/python satimis Programming 5 03-19-2004 10:20 AM
How hard is it to learn gentoo? Easier than RH? silverbullet Linux - Newbie 3 11-29-2003 02:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:17 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration