Perl neq Python

B

Berk Birand

Hi,

I have learned coding in Perl couple of weeks ago, and have recently added
Python to my repertoire. I know that there are loads of web pages
comparing the two languages, and that you are probably sick of guys asking
which one to learn. However my question is slightly different.

You see I have the time and the energy to do my best in both languages (at
least until I begin college this august). That's precisely why I have
decided to learn everything I could. The question that I have been asking
myself is the following:

Under what circumstances should I use Perl, Python or straight shell
scripting?

I believe I have made my point clear that I am not asking for a
comparison, but some guidelines as to which one to use for a specific task.

So far I have figured that Perl is a better tool for applications using
regular expressions, and Python more appropriate for bigger projects
(because of its object-oriented programming model and its "readability")

What do you think?

Thanks
BB
 
T

Tore Aursand

I have learned coding in Perl couple of weeks ago
[...]

Are you saying that you learned Perl _in_ a couple of weeks? If so,
that's bullshit.
Under what circumstances should I use Perl, Python or straight shell
scripting?

If you _really_ know each of these programming languages/techniques, you
know what to use and when to use it.
 
1

187

Tore said:
I have learned coding in Perl couple of weeks ago
[...]

Are you saying that you learned Perl _in_ a couple of weeks? If so,
that's bullshit.

Geezus Smite, don't have to be so anal. Maybe he meant he learned Perl
as in the basics a few weeks. And for that matter, I've known people who
have picked up a language like this fairly quickly. If you are an
experienced programmer also with shell and Linux, and maybe with tolls
like sed and awk, Perl can be a fairly quick pick up, for the most part.
Maybe not the most advanced stuff but quite possibly the basics of it.

Whose to say this guy hasn't picked it up quickly? You never know who
has a nature nack for it.
If you _really_ know each of these programming languages/techniques,
you know what to use and when to use it.

Re read his question. He never claimed to be an expert.
 
T

Tore Aursand

I have learned coding in Perl couple of weeks ago
[...]
Are you saying that you learned Perl _in_ a couple of weeks? If so,
that's bullshit.
Geezus Smite, don't have to be so anal. Maybe he meant he learned Perl
as in the basics a few weeks.

I just wanted to make sure that he knows the difference between knowing
Perl and _knowing_ Perl. I've been programming Perl for the last 6 years,
and I still have _a lot_ to learn.
Re read his question. He never claimed to be an expert.

I never said that, either. My point is still valid: If you _really_ know
a bunch of different languages, you automatically knows which language is
the best to solve the task(s) you have in front of you.

"The right tool for the right job", so to speak. Perl doesn't solve
everything in this world (it's close, though), and other languages fill in
where Perl isn't at its strongest.
 
J

Joe Smith

187 said:
Re read his question. He never claimed to be an expert.

I agree with Tore; it's sort of a Zen question.
If you have to ask, it means you won't understand the answer.
If you know enough to understand the answer, you won't need the question.

A good exercise is to find an interesting task, then implement it in
all three languages. Take notes of how long it takes to write, then
benchmark how fast each one is. Repeat a couple dozen times.

Have fun.
-Joe
 
P

Peter Hickman

Berk said:
Under what circumstances should I use Perl, Python or straight shell
scripting?

Perl
----
Perl is useful if you intend to earn money and is a sort of defacto
sysadmin tool. If only because many of the tools a sysadmin will use are
written in perl - especially with web sites. So Perl is a usefull skill
to have to get work.

Perl has CPAN, your problem might already have been solved and posted to
CPAN. For a quick solution the ability to download 50%-90% of the code
from CPAN is a real boon.

Python
------
I use it for fun, like a lot of languages I use. However it can be used
in all the places you can use Perl, its just finding an employer who
actually wants Python skills. Also wxWindows is better developed in
Python than in Perl. If I want a cross platform GUI I go for Python and
wxWindows (unless I feel like a challenge and go for tcl/tk). This alone
is a very big plus for Python, it is the only portable language (I'm not
counting C/C++ here - dont flame) with a portable GUI, other than Java
but lets not go there.

Shell scripts
-------------
If your Perl/Python scripts end up being just a bunch of system calls
then you should probably have used a shell script. Actually the ability
to write shell scripts should be a given if you are getting into a
programming, just like knowing how to use vi, cvs, sed and awk - tools
of the trade.

Most of the time, when the problem seems simple, I start with a shell
script and promote to Perl or Python as it gets either bigger or critical.

Summary
 
T

Tore Aursand

[...]
A good exercise is to find an interesting task, then implement it in all
three languages. Take notes of how long it takes to write, then
benchmark how fast each one is. Repeat a couple dozen times.

....and when you're done, don't be surprised if your boss - or even the
customer for whom you're creating the application - haven't heard about
the language of your choice and insists that you write it in a language
which everyone has heard about, but that's not really suitable for the
problem. :)


--
Tore Aursand <[email protected]>
"Omit needless words. Vigorous writing is concise. A sentence should
contain no unnecessary words, a paragraph no unnecessary sentences,
for the same reason that a drawing should have no unnecessary lines
and a machine no unnecessary parts." -- William Strunk Jr.
 
J

Jim Cochrane

Perl
----
Perl is useful if you intend to earn money and is a sort of defacto
sysadmin tool. If only because many of the tools a sysadmin will use are
written in perl - especially with web sites. So Perl is a usefull skill
to have to get work.

Perl has CPAN, your problem might already have been solved and posted to
CPAN. For a quick solution the ability to download 50%-90% of the code
from CPAN is a real boon.

Python
------
I use it for fun, like a lot of languages I use. However it can be used
in all the places you can use Perl, its just finding an employer who
actually wants Python skills. Also wxWindows is better developed in
Python than in Perl. If I want a cross platform GUI I go for Python and
wxWindows (unless I feel like a challenge and go for tcl/tk). This alone
is a very big plus for Python, it is the only portable language (I'm not
counting C/C++ here - dont flame) with a portable GUI, other than Java
but lets not go there.

Sorry to introduce an off-topic response, but I think a correction is
needed to the above statement. Eiffel is a portable language, and Eiffel
Software's compiler includes a portable GUI library (EiffelVision2).
Now if you amend the statement to something like: "it is the only portable
language (I'm not counting C/C++ here - dont flame) with a portable,
well-known, open-source or freely available GUI, other than Java but lets
not go there", then it might be true. However, I'm still not sure if this
is true - what about Perl? And don't some of the functional languages
(e.g., scheme, Haskell) have a portable GUI library available?
 
M

Michele Dondi

I agree with Tore; it's sort of a Zen question.
If you have to ask, it means you won't understand the answer.
If you know enough to understand the answer, you won't need the question.

Cool!

OTOH the OP may be interested in reading:

perldoc -q 'How does Perl compare with other languages'
perldoc -q 'Can I do [task] in Perl'
perldoc -q 'When shouldn\'t I program in Perl?'


Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

How do I solidify my Python skills 1
C++ vs Python 3
python 2
Math python question 10
Processing in Python help 0
Python ideas 0
Trying to access hdml from an open browser using Python. 1
Python battle game help 2

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,120
Latest member
ShelaWalli
Top