[Purdue-pm] Threads and forks

Mark Senn mark at purdue.edu
Thu Oct 22 08:07:38 PDT 2020


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


More information about the Purdue-pm mailing list