LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perl vs Python which is easier to learn (https://www.linuxquestions.org/questions/programming-9/perl-vs-python-which-is-easier-to-learn-857758/)

ajeesh.tr 01-21-2011 06:20 AM

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.

eSelix 01-21-2011 06:28 AM

Python is better for you. It learns good looking code.

ajeesh.tr 01-21-2011 06:48 AM

Quote:

Originally Posted by eSelix (Post 4232876)
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

teebones 01-21-2011 07:13 AM

the python website?
http://wiki.python.org/moin/BeginnersGuide

XavierP 01-21-2011 12:11 PM

Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.

dugan 01-21-2011 12:14 PM

Quote:

Originally Posted by teebones (Post 4232931)

And when you're finished that,

http://www.diveintopython3.org/

Sergei Steshenko 01-21-2011 12:35 PM

Quote:

Originally Posted by eSelix (Post 4232876)
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).

ghostdog74 01-21-2011 09:42 PM

Quote:

Originally Posted by Sergei Steshenko (Post 4233245)
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.

theKbStockpiler 01-21-2011 10:18 PM

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.

ghostdog74 01-21-2011 10:47 PM

Quote:

Originally Posted by theKbStockpiler (Post 4233719)
Perl is more involved and you can do more with it

more involved and can do more? like what ?

Sergei Steshenko 01-23-2011 01:12 PM

Quote:

Originally Posted by ghostdog74 (Post 4233698)
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.


Sergei Steshenko 01-23-2011 01:15 PM

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.

ghostdog74 01-23-2011 06:49 PM

Quote:

Originally Posted by Sergei Steshenko (Post 4235131)
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.

alpha01 01-23-2011 08:09 PM

Quote:

Originally Posted by ajeesh.tr (Post 4232870)
i want to learn a scripting language,which one should i go for ,among perl and python.

Ruby

Enough said :-)

binary_pearl 01-23-2011 08:46 PM

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


All times are GMT -5. The time now is 08:49 AM.