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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
01-21-2011, 06:20 AM
|
#1
|
Member
Registered: Jan 2011
Posts: 37
Rep:
|
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.
|
|
|
01-21-2011, 06:28 AM
|
#2
|
Senior Member
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,281
|
Python is better for you. It learns good looking code.
|
|
|
01-21-2011, 06:48 AM
|
#3
|
Member
Registered: Jan 2011
Posts: 37
Original Poster
Rep:
|
Quote:
Originally Posted by eSelix
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
|
|
|
01-21-2011, 07:13 AM
|
#4
|
Member
Registered: Aug 2005
Location: /home/teebones
Distribution: sometimes this, sometimes that..
Posts: 502
Rep:
|
|
|
|
01-21-2011, 12:11 PM
|
#5
|
Moderator
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
|
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
|
|
|
01-21-2011, 12:14 PM
|
#6
|
LQ Guru
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,375
|
Quote:
Originally Posted by teebones
|
And when you're finished that,
http://www.diveintopython3.org/
|
|
|
01-21-2011, 12:35 PM
|
#7
|
Senior Member
Registered: May 2005
Posts: 4,481
|
Quote:
Originally Posted by eSelix
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).
|
|
|
01-21-2011, 09:42 PM
|
#8
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
Quote:
Originally Posted by Sergei Steshenko
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.
|
|
|
01-21-2011, 10:18 PM
|
#9
|
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:
|
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.
|
|
|
01-21-2011, 10:47 PM
|
#10
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
Quote:
Originally Posted by theKbStockpiler
Perl is more involved and you can do more with it
|
more involved and can do more? like what ?
|
|
|
01-23-2011, 01:12 PM
|
#11
|
Senior Member
Registered: May 2005
Posts: 4,481
|
Quote:
Originally Posted by ghostdog74
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.
|
01-23-2011, 01:15 PM
|
#12
|
Senior Member
Registered: May 2005
Posts: 4,481
|
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.
|
|
|
01-23-2011, 06:49 PM
|
#13
|
Senior Member
Registered: Aug 2006
Posts: 2,697
|
Quote:
Originally Posted by Sergei Steshenko
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.
|
|
|
01-23-2011, 08:09 PM
|
#14
|
Member
Registered: Jul 2008
Location: Orange County
Distribution: Ubuntu/Debian, CentOS, RHEL, FreeBSD, OS X
Posts: 75
Rep:
|
Quote:
Originally Posted by ajeesh.tr
i want to learn a scripting language,which one should i go for ,among perl and python.
|
Ruby
Enough said :-)
|
|
|
01-23-2011, 08:46 PM
|
#15
|
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
Rep:
|
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.
|
All times are GMT -5. The time now is 12:17 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|