3 ms·
> The advantage of threads is that it makes easier to share data Sharing of data is of marginal benefit when you have to pay the cost of duplicating all of you
by bbatha 11y ago
> The advantage of threads is that it makes easier to share data
Sharing of data is of marginal benefit when you have to pay the cost of duplicating all of your data to begin with. Perl also has modules that make forks just as easy to use as threads.[1] This is doubly so when most libraries have little to no regard for thread safety because perl's threading support it so bad.
> Also it is less costly to create a thread rather than a process.
Not unix because of copy on write processes [2][3]. Perl threads copy not just the interpreter but all local variables. [4] The only place threads are useful is on windows where the cost of a fork is higher than a thread.
[1] https://news.ycombinator.com/reply?id=10708168&goto=item%3Fid%3D10706695 https://news.ycombinator.com/reply?id=10708168&goto=item%3Fi...
[2] http://stackoverflow.com/a/16658623/2863146 http://stackoverflow.com/a/16658623/2863146
[3] http://www.perlmonks.org/?node_id=306089 http://www.perlmonks.org/?node_id=306089
[4] http://perldoc.perl.org/perlthrtut.html#Performance-considerations http://perldoc.perl.org/perlthrtut.html#Performance-consider...
- raiph 11y ago> most libraries have little to no regard for thread safety because perl's threading support it so bad. Fwiw Perl 6's concurrency and parallelism is very much one of its strengths, not one of its weaknesses. (It's pretty obvious to me that you are writing about Perl 5, not Perl 6, but it might not be obvious to others. Indeed some folk will even claim Perl 6 isn't a Perl, but Perl's original creator Larry Wall thinks Perl 6 is a Perl, and I think he has a point.)