Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: What technical benfits perl offers over python + few more questions.

by hippo (Bishop)
on Nov 13, 2021 at 11:46 UTC ( [id://11138779]=note: print w/replies, xml ) Need Help??


in reply to What technical benfits perl offers over python + few more questions.

I checked a few articles though, and they all seem to say that 1) Python offers better error handling than Perl

It is a shame that you have not linked to these articles - not even one of them - so that we can discover in what way the authors think that Python offers better error handling. All I can do therefore is say that in all my many years of working with Perl never once have I thought "Perl's error handling could be better".

2)Functions are first class citizens in Python

Super. What does that give you that you can do with functions in Python that you cannot do with functions (subroutines) in Perl?

3)Even for the kind of reporting I am looking for, Python would be a better choice.

Again, no link so no reason why. Here, I'll say it: "Perl would be a better choice". I present as much evidence to back up this claim as you have done so far, ie. none.

Actually, I'll do better than that. Perl has CPAN and CPAN has many modules for working with accursed Excel spreadsheets should you so need - even on non-native Excel platforms. Perl is (almost entirely) backwards compatible with itself so you don't need to ask, "python2 or python3"? Perl is already installed on any O/S you might be using (except MSWin, of course).

For any given task, to choose the language which is most appropriate you must consider the key aspects of that task and then you can whittle down your choice to those languages which satisfy those requirements. Then you can dig into nuance. And finally there is the choice of which language you want to use and why. I almost always want to use Perl because (a) it has all the tools, (b) it is expressive and (c) is it (to me) intuitive. Its speed and ubiquity are just bonuses.


🦛

Replies are listed 'Best First'.
Re^2: What technical benfits perl offers over python + few more questions.
by Anonymous Monk on Nov 14, 2021 at 18:49 UTC

    Hi Hippo

    Here is one of the links that talks about exceptions not being part of Perl. My bad again, I got mixed up with errors and exceptions, and if you berate me for that I would totally understand- https://www.oreilly.com/library/view/mastering-perl/9780596527242/ch12.html

    Given below is paragraph from the chapter -

    Exceptions Perl doesn’t have exceptions. Let’s just get that clear right now. Lik +e some other things Perl doesn’t really have, people have figured out + how to fake them. If you’re used to languages, such as Java or Pytho +n, set the bar much lower so you aren’t too disappointed. In those ot +her languages, exceptions are part of the fundamental design, and tha +t’s how I’m supposed to deal with all errors. Exceptions aren’t part +of Perl’s design, and it’s not how Perl programmers tend to deal with + errors.

    Unfortunately I could not find other links. I was just going from one article to another and that is how I stumbled across the said articles.

    Note:- I am not hear to badmouth about Perl. Just really badly wanting to get some clarity (which the ensuing answers have provided in truckloads).

      Exceptions are not an explicit part of the Perl language, but fatal errors are and can serve a similar purpose. However, as with many other topics, exceptions are well catered for on CPAN with almost 4000 results for "exception". If you do want to use exceptions with Perl there are many ways to do so.


      🦛

      Perl has exceptions, and that's nothing new. Exceptions are thrown using die, and caught using eval BLOCK.

      Differences:

      • Perl operators don't throw exceptions, while the corresponding IO libraries in other languages might.

      • Perl exceptions don't automatically come with a stack trace, whereas it's common elsewhere. It's definitely possible to get stack trace from exceptions in Perl, through. See Carp::Always.

        > Perl operators don't throw exceptions, while the corresponding IO libraries in other languages might.

        could you please elaborate what you mean?

        DB<37> eval { 1/0 } or print "<$@>" <Illegal division by zero at (eval 46)[c:/Strawberry/perl/lib/perl5db. +pl:738] line 2. > DB<38>

        edit

        Probably you are talking about the kind of non-error "message" exceptions , e.g. thrown by iterators like in Python???

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11138779]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-29 12:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found