Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Choosing the right module

by sectokia (Pilgrim)
on Oct 23, 2022 at 21:26 UTC ( [id://11147616]=note: print w/replies, xml ) Need Help??


in reply to Choosing the right module

Over a long time I have eventually learned that you should never use a synchronous library when an asynchronous one exists - especially for anything that takes time - like remote communications.

The reason is that async code is going to be so much more flexible and has far more re-usability (and of course can be used as 'sync' code if you want).

So in this case I would go to AnyEvent::HTTP. The benefits over the 3 you mention is ability to simultaneously do multiple requests, and simultaneously handle user input to start new requests or abandon ones already in progress etc. This also gives you the flexibility to more easily convert your script/program to a on-demand service (example: your program could use AnyEvent::HTTPD to have its own web server where users could go to it in a webbrowser and on-demand get your program to do whatever it is that it does).

Furthermore, with modules like 'Promises' you can write async code very much like sync code.

Replies are listed 'Best First'.
Re^2: Choosing the right module
by cavac (Parson) on Oct 25, 2022 at 08:17 UTC

    I do many a thing async as well. But for code that isn't time critical, i prefer the "sync" path, because it makes the code (almost always) more readable and easier to understand and to bugfix.

    This goes especially for the first versions of a new code (proof of concept, one-off project, etc). The last thing you want to deal with is network lag based race conditions when you are just trying to find out if your basic idea will even work.

    PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP

Log In?
Username:
Password:

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

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

    No recent polls found