[Purdue-pm] Threads and forks
Turner, Howard Robert
turne349 at purdue.edu
Thu Oct 22 16:15:44 PDT 2020
Dave,
Thanks for the suggestion on MCE. I'll read about it this weekend. To answer your other question. Essentially my Perl program is logging into a web application and running a utility that calls back to the system that the Perl script is running from. I was hoping to have the Perl program 'catch' call back or perhaps launch a thread or something that can listen for the call back. My terminology may be off so apologies in advance still learning! I hope this gets the idea/concept across though?
Mark,
Thanks for the Raku articles too. I'll take a look at them for my edification. At the moment, I'm really trying to focus on getting better at Perl 5 as work currently relies on it fairly heavily. Really need to look into Raku though just to be more versed on the differences between the two languages.
Rob
________________________________
From: Mark Senn <mark at purdue.edu>
Sent: Thursday, October 22, 2020 11:07:38 AM
To: Turner, Howard Robert <turne349 at purdue.edu>
Cc: perl at ecn.purdue.edu <perl at ecn.purdue.edu>; Purdue Perl Mongers <purdue-pm at pm.org>
Subject: Re: [Purdue-pm] Threads and forks
Rob Turner <turne349 at purdue.edu> wrote on 2020-10-22 at 01:10+00:
| Greetings again everyone.
|
| Looking for some advice. I'm writing a small program that talks to a
| webserver and ends waiting for a connection back from the
| webserver. Problem is I can only figure out to have the call back
| handled or my Perl program continue processing but not both.
|
| Started reading the Perl threads tutorial but it suggests not using
| threads and then started reading about fork instead. So a little
| overwhelmed in figuring out which one is "the right way".
|
| Anyone have suggestions and/or tutorials they'd suggest reviewing beyond
| the ones on perldoc?
|
| Respectfully,
| Rob
Rob,
I like Raku (formerly known as Perl 6) better than Perl 5. Raku is harder to
learn than Perl 5 because it is much more powerful. Fewer people know
Raku than Perl 5. Raku is not installed on as many computers. My return
on investment learning Raku has been excellent.
If you'd like to make the jump to Raku this quote
Raku is designed to support parallelism, asynchronicity and concurrency.
is from
https://docs.raku.org/language/concurrency
I'm guessing you want to go async because you're sending requests to
multiple webservers and/or sending a message to a single web server
that will require lots of computation. Is that correct?
See
https://zostay.com/posts/2019/12/01/introducing-async-concurrency-in-raku/
for around 20 other async/concurrency articles.
See
https://cro.services
for information on Cro. From the web page:
Cro is a set of libraries for building reactive distributed systems,
lovingly crafted to take advantage of all Raku (formerly Perl 6) has to
offer. The high level APIs make the easy things easy, and the
asynchronous pipeline concept at Cro's heart makes the hard things
possible.
https://raku.guide/ is a good intro to Raku. Raku is Object-Oriented,
OO stuff is built in on Raku, bolted on in Perl 5. From the web page
my @final-array = reverse(sort(unique(@array)));
is easier to read in my opinion in Raku
my @final-array = @array.unique.sort.reverse;
Raku has more functions, more operations, more flexibility.
Await may do what you want see
https://docs.raku.org/routine/await
but using Cro may be cleaner.
Raku does not have modules that help write PDF files as far as I know.
Perl 5 has way more modules. If you need a module that Perl 5 does
not have but Raku does and you don't want to write it you'll want to
use Perl 5. But, I can do most my work with Raku and love it.
Raku is written in Raku using a Raku "grammar". Raku regexes are more
powerful than Perl 5 regular expressions. Raku has "infinite" precision
arithmetic built in for integers and rational numbers.
-mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/purdue-pm/attachments/20201022/5fd29758/attachment.html>
More information about the Purdue-pm
mailing list