develooper Front page | perl.perl5.porters | Postings from April 2018

Re: [perl #133021] Removed the word "discouraged" from threads'documentation

Thread Previous | Thread Next
From:
Tom Molesworth via perl5-porters
Date:
April 10, 2018 15:58
Subject:
Re: [perl #133021] Removed the word "discouraged" from threads'documentation
Message ID:
CAGXhHd=4QQ7CJppSASGDavsjW+KPoeBiG4V=qzxKRJHA_RGZyw@mail.gmail.com
On 10 April 2018 at 23:11, Dave Mitchell <davem@iabyn.com> wrote:

> On Tue, Apr 10, 2018 at 10:26:21PM +0800, Tom Molesworth via perl5-porters
> wrote:
> > On 10 April 2018 at 21:59, Dave Mitchell <davem@iabyn.com> wrote:
> > > Can you come up with a hypothetical scenario, e.g.  a multi-threaded
> > > program that uses libraries to connect to a database and retrieve and
> > > parse some XML data. Then got through it step by step so that I can see
> > > why using perl and CPAN is dangerous, but using (e.g.) java and a DB
> and
> > > XML library is safe? What is the crucial difference between the two
> that
> > > flips it from being safe to unsafe?
> > >
> >
> > Here's one trivial hacked-together example of code which I would argue
> > leads to "unexpected" results, at least from the perspective of a C or
> Java
> > programmer experienced in the ways of threads:
>
> That isn't a reply to the asked question, which was trying to eke out an
> understanding of why Christian believes the CPAN ecosystem in some way
> makes threading more hazardous on perl than in other languages (which it
> may, but I can't grasp the point he's trying to make).
>
> The example code you've given seems to be (at a quick glance), just the
> fact (again) that refs in different threads have different addresses in
> perl.
>

Related but slightly different: this time it's 2 different addresses
*within the same thread*, none of which match the refaddr in the other
thread. For something that's supposedly "shared", I'd call having 3
addresses surprising at best!

What I'm trying to demonstrate is it's easy to hit implementation details
in Perl, ones that go against the common understanding of "threads". I
don't think people should have to read Shared.xs before they can implement
a multithreaded XML+DB application. Documentation might help, but there's
an uphill struggle at the first word: what we call "threads", other
languages might call a nearly-unrecognisable special case!

(Eirik and Christian have already addressed the other comments I was going
to make, so I'll stop here - sorry for derailing the thread)

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About