SlideShare a Scribd company logo
Perl 6 for
Concurrency and
Parallel Computing
or
Parallel Features

of Perl 6
The Parallel

Features

of the Perl Six
Parallel Futures

of Perl 6
Foreword
Interviews for
Pragmatic Perl
in 2013–2015
Perl 6 for Concurrency and Parallel Computing
What is the most important
feature of the programming
languages in the future?
Q:
I don’t knowA:
No idea (2 answers)
There’s no good answerA:
No idea (2 answers)
Natural-like languageA:
Syntax features (1/3)
MinimalismA:
Syntax features (2/3)
ExtendabilityA:
Syntax features (3/3)
Flexible type castingA:
Object system (1/3)
RobustnessA:
Object system (2/3)
Built-in introspectionA:
Object system (3/3)
JVM supportA:
Environment (1/4)
Execution in a browserA:
Environment (2/4)
Language inter-compatibilityA:
Environment (3/4)
EmbeddingA:
Environment (4/4)
CommunityA:
Humanity (1/8)
HumanismA:
Humanity (2/8)
Open sourceA:
Humanity (3/8)
PragmatismA:
Humanity (4/8)
Mind control (sic!)A:
Humanity (5/8)
Expressing things easilyA:
Humanity (6/8)
Domain orientedA:
Humanity (7/8)
UnobtrusivenessA:
Humanity (8/8)
Number 1 answer

Parallelism
ParallelismA:
Parallelism (1/12)
Working with parallel
resources
A:
Parallelism (2/12)
ParallelismA:
Parallelism (3/12)
Good paralleling modelA:
Parallelism (4/12)
Intuitive coroutines and
multi-core support
A:
Parallelism (5/12)
ParallelismA:
Parallelism (6/12)
Safe operation parallelismA:
Parallelism (7/12)
Built-in threadingA:
Parallelism (8/12)
Qualitative abstract threadingA:
Parallelism (9/12)
ParallelismA:
Parallelism (10/12)
Good parallelismA:
Parallelism (11/12)
Multi-taskingA:
Parallelism (12/12)
Back to Perl 6
The idea is

keeping things
transparent
A Perl 6 user
simply uses
concurrency
A Perl 6 compiler
makes it possible
A Perl 6 compiler
makes it possible
The Perl 6 compiler
makes it possible
Running examples
with Rakudo Star
Running examples
with Rakudo Star
on MoarVM
Two kinds

of parallel features
Roughly,
1) implicit
2) explicit
Operators
at a glance
1.
Hyperops
A hyper operator
is a

meta operator
+
operator
+=
meta operator
>>+<<
hyper operator
»+«
hyper operator
>>+
hyper operator
»+
hyper operator
>>+>>
hyper operator
<<+<<
hyper operator
«+«
hyper operator
Perl 6 for Concurrency and Parallel Computing
<<+>>
hyper operator
«+»
hyper operator
<<<>>
hyper operator
«<»
hyper operator
@c = @a >>+<< @b
@c = @a >>+<< @b
@c[0] = @a[0] + @b[0];
@c = @a >>+<< @b
@c[0] = @a[0] + @b[0];
@c[1] = @a[1] + @b[1];
@c = @a >>+<< @b
@c[0] = @a[0] + @b[0];
@c[1] = @a[1] + @b[1];
@c[2] = @a[2] + @b[2];
@c = @a >>+>> 1
@c = @a >>+>> 1
@c[0] = @a[0] + 1;
@c = @a >>+>> 1
@c[0] = @a[0] + 1;
@c[1] = @a[1] + 1;
@c = @a >>+>> 1
@c[0] = @a[0] + 1;
@c[1] = @a[1] + 1;
@c[2] = @a[2] + 1;
2.
Junctions
Or
Quantum
Superpositions
Many values as one
my $j = 1 | 2 | 3 | 5;
my $j = 1 | 2 | 3 | 5;
say 1 if 3 == $j;
my $j = 1 | 2 | 3 | 5;
say 1 if 3 == $j;
my $j = 1 | 2 | 3 | 5;
say 1 if 3 == $j;
my $j = 1 | 2 | 3 | 5;
say 1 if 3 == $j;
}
my $j = 1 | 2 | 3 | 5;
say 1 if 3 == $j;
}1
3.

Feeds
my @a = 1..10;
my @a = 1..10;	
@a ==> grep {$_ mod 2};
my @a = 1..10;	
@a ==> grep {$_ mod 2};	
!
1 3 5 7 9
my @a = 1..10;	
@a 	
==> grep {$_ mod 2}	
==> map {$_ ** 2};
my @a = 1..10;	
@a 	
==> grep {$_ mod 2}	
==> map {$_ ** 2};	
!
1 9 25 49 81
Perl 6 for Concurrency and Parallel Computing
4.

Channels
my $c = Channel.new;
my $c = Channel.new;	
$c.send(42);
my $c = Channel.new;	
$c.send(42);	
say $c.receive;	
!
42
my $ch = Channel.new;
my $ch = Channel.new;	
for <1 3 5 7 9> {	
$ch.send($_);	
}
my $ch = Channel.new;	
for <1 3 5 7 9> {	
$ch.send($_);	
}	
while $ch.poll -> $x {	
say $x;	
}
5.

Promises
my $p = Promise.new;
my $p = Promise.new;	
say $p.status;

Planned
my $p = Promise.new;	
$p.keep;
my $p = Promise.new;	
$p.keep;	
say $p.status;	
!
Kept
my $p = Promise.new;	
$p.break;
my $p = Promise.new;	
$p.break;	
say $p.status;	
!
Broken
Factory methods
start
my $p = start {42};
my $p = start {42};

say $p.WHAT;

(Promise)
my $p1 = start {sleep 2};
my $p1 = start {sleep 2};	
my $p2 = start {sleep 2};
my $p1 = start {sleep 2};	
say $p1.status;	
my $p2 = start {sleep 2};	
say $p2.status;
my $p1 = start {sleep 2};	
say $p1.status;	
my $p2 = start {sleep 2};	
say $p2.status;	
!
Planned	
Planned
my $p1 = start {sleep 2};	
my $p2 = start {sleep 2};	
sleep 3;
my $p1 = start {sleep 2};	
my $p2 = start {sleep 2};	
sleep 3;	
say $p1.status;	
say $p2.status;
my $p1 = start {sleep 2};	
my $p2 = start {sleep 2};	
sleep 3;	
say $p1.status	
say $p2.status	
Kept	
Kept
start

in a thread
in
my $p = Promise.in(3);
my $p = Promise.in(3);	
!
for 1..5 {	
say "$_ {$p.status}";

sleep 1;	
}
my $p = Promise.in(3);	
!
for 1..5 {	
say "$_ {$p.status}";

sleep 1;	
}
1 Planned
1 Planned	
2 Planned
1 Planned	
2 Planned	
3 Planned
1 Planned	
2 Planned	
3 Planned	
4 Kept
1 Planned	
2 Planned	
3 Planned	
4 Kept	
5 Kept
Example:

Sleep Sort
!
for @*ARGS -> $a {	
	
!
!
!
!
}
!
for @*ARGS -> $a {	
	
!
!
!
!
}
!
for @*ARGS -> $a {	
@promises.push(	
Promise.in($a).then({	
say $a;	
})	
);	
}	
!
await(|@promises);
my @promises;	
for @*ARGS -> $a {	
@promises.push(	
Promise.in($a).then({	
say $a;	
})	
);	
}	
!
await(|@promises);
my @promises;	
for @*ARGS -> $a {	
@promises.push(	
Promise.in($a).then({	
say $a;	
})	
);	
}	
!
await(|@promises);
my @promises;	
for @*ARGS -> $a {	
@promises.push(	
Promise.in($a).then({	
say $a;	
})	
);	
}	
!
await(|@promises);
my @promises;	
for @*ARGS -> $a {	
@promises.push(	
Promise.in($a).then({	
say $a;	
})	
);	
}	
!
await(|@promises);
$ ./sleep-sort.pl
$ ./sleep-sort.pl 3 1 2
$ ./sleep-sort.pl 3 1 2	
1
$ ./sleep-sort.pl 3 1 2	
1	
2
$ ./sleep-sort.pl 3 1 2	
1	
2	
3
Home work:

Channels inside
Promises
More:

Schedulers
More:

Suppliers
More:

I/O and Suppliers
More:

Signals
More:

Threads
More:

Atomic
More:

Locks
More:

Semaphores
__END__
Andrew Shitov
andy@shitov.ru April 2015

More Related Content

KEY
Perl 6 talk
Matt Follett
 
PDF
Creating a compiler in Perl 6
Andrew Shitov
 
PDF
The Perl6 Type System
abrummett
 
PDF
Perl6 in-production
Andrew Shitov
 
PDF
The Joy of Smartmatch
Andrew Shitov
 
PDF
Perl 6 by example
Andrew Shitov
 
PDF
Perl6 one-liners
Andrew Shitov
 
PDF
Perl 6 in Context
lichtkind
 
Perl 6 talk
Matt Follett
 
Creating a compiler in Perl 6
Andrew Shitov
 
The Perl6 Type System
abrummett
 
Perl6 in-production
Andrew Shitov
 
The Joy of Smartmatch
Andrew Shitov
 
Perl 6 by example
Andrew Shitov
 
Perl6 one-liners
Andrew Shitov
 
Perl 6 in Context
lichtkind
 

What's hot (20)

PDF
Wx::Perl::Smart
lichtkind
 
KEY
Perl세미나
Gyu-sun Youm
 
PDF
Functional Structures in PHP
Marcello Duarte
 
PDF
I, For One, Welcome Our New Perl6 Overlords
heumann
 
PDF
Learning Perl 6
brian d foy
 
PDF
Benchmarking Perl (Chicago UniForum 2006)
brian d foy
 
PDF
Perl세미나
Gyu-sun Youm
 
PDF
Perl 5.10 for People Who Aren't Totally Insane
Ricardo Signes
 
PDF
Learning Perl 6 (NPW 2007)
brian d foy
 
PDF
Zend Certification Preparation Tutorial
Lorna Mitchell
 
PPTX
Php 2
vivlinux
 
PDF
Improving Dev Assistant
Dave Cross
 
PDF
Good Evils In Perl
Kang-min Liu
 
PDF
Business Rules with Brick
brian d foy
 
ODP
Intermediate Perl
Dave Cross
 
ODP
Advanced Perl Techniques
Dave Cross
 
PPT
Functional Pe(a)rls version 2
osfameron
 
PDF
Introdução ao Perl 6
garux
 
ODP
Introduction to Perl
Dave Cross
 
PDF
Introduction to Perl
worr1244
 
Wx::Perl::Smart
lichtkind
 
Perl세미나
Gyu-sun Youm
 
Functional Structures in PHP
Marcello Duarte
 
I, For One, Welcome Our New Perl6 Overlords
heumann
 
Learning Perl 6
brian d foy
 
Benchmarking Perl (Chicago UniForum 2006)
brian d foy
 
Perl세미나
Gyu-sun Youm
 
Perl 5.10 for People Who Aren't Totally Insane
Ricardo Signes
 
Learning Perl 6 (NPW 2007)
brian d foy
 
Zend Certification Preparation Tutorial
Lorna Mitchell
 
Php 2
vivlinux
 
Improving Dev Assistant
Dave Cross
 
Good Evils In Perl
Kang-min Liu
 
Business Rules with Brick
brian d foy
 
Intermediate Perl
Dave Cross
 
Advanced Perl Techniques
Dave Cross
 
Functional Pe(a)rls version 2
osfameron
 
Introdução ao Perl 6
garux
 
Introduction to Perl
Dave Cross
 
Introduction to Perl
worr1244
 
Ad

Similar to Perl 6 for Concurrency and Parallel Computing (20)

PPTX
An introduction to Raku
Simon Proctor
 
PPTX
Perl6 a whistle stop tour
Simon Proctor
 
PDF
Perl6 a whistle stop tour
Simon Proctor
 
KEY
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
PPTX
Distributed Applications with Perl & Gearman
Issac Goldstand
 
KEY
Concurrency in ruby
Marco Borromeo
 
PPTX
Perl: Coro asynchronous
Shmuel Fomberg
 
PDF
Qore for the Perl Programmer
Brett Estrade
 
PDF
Ruby's Concurrency Management: Now and Future
Koichi Sasada
 
KEY
Ruby 1.9 Fibers
Kevin Ball
 
ODP
What's new in Perl 5.10?
acme
 
PDF
Concurrent and Distributed Applications with Akka, Java and Scala
Fernando Rodriguez
 
PDF
Dataflow: Declarative concurrency in Ruby
Larry Diehl
 
PPT
Reliable and Concurrent Software - Erlang
ssuser2637a1
 
PDF
Gearman and Perl
Andrew Shitov
 
PDF
Concurrency: Rubies, Plural
Eleanor McHugh
 
PDF
Concurrency: Rubies, plural
ehuard
 
PPT
Writing Prefork Workers / Servers
Kazuho Oku
 
PDF
Asynchronous Programming FTW! 2 (with AnyEvent)
xSawyer
 
An introduction to Raku
Simon Proctor
 
Perl6 a whistle stop tour
Simon Proctor
 
Perl6 a whistle stop tour
Simon Proctor
 
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
Distributed Applications with Perl & Gearman
Issac Goldstand
 
Concurrency in ruby
Marco Borromeo
 
Perl: Coro asynchronous
Shmuel Fomberg
 
Qore for the Perl Programmer
Brett Estrade
 
Ruby's Concurrency Management: Now and Future
Koichi Sasada
 
Ruby 1.9 Fibers
Kevin Ball
 
What's new in Perl 5.10?
acme
 
Concurrent and Distributed Applications with Akka, Java and Scala
Fernando Rodriguez
 
Dataflow: Declarative concurrency in Ruby
Larry Diehl
 
Reliable and Concurrent Software - Erlang
ssuser2637a1
 
Gearman and Perl
Andrew Shitov
 
Concurrency: Rubies, Plural
Eleanor McHugh
 
Concurrency: Rubies, plural
ehuard
 
Writing Prefork Workers / Servers
Kazuho Oku
 
Asynchronous Programming FTW! 2 (with AnyEvent)
xSawyer
 
Ad

More from Andrew Shitov (20)

PDF
Perl jobs market in 2024, how good is it?
Andrew Shitov
 
PPTX
Fun with Raspberry PI (and Perl)
Andrew Shitov
 
PDF
Параллельные вычисления в Perl 6
Andrew Shitov
 
PDF
AllPerlBooks.com
Andrew Shitov
 
PDF
YAPC::Europe 2013
Andrew Shitov
 
PDF
Perl 7, the story of
Andrew Shitov
 
PDF
Язык программирования Go для Perl-программистов
Andrew Shitov
 
PDF
Как очистить массив
Andrew Shitov
 
PDF
What's new in Perl 5.14
Andrew Shitov
 
PDF
Что нового в Perl 5.14
Andrew Shitov
 
PDF
Perl6 grammars
Andrew Shitov
 
PDF
Text in search queries with examples in Perl 6
Andrew Shitov
 
PDF
There's more than one way to empty it
Andrew Shitov
 
PDF
How to clean an array
Andrew Shitov
 
PDF
Perl 5.10 и 5.12
Andrew Shitov
 
PDF
Say Perl на весь мир
Andrew Shitov
 
PDF
Personal Perl 6 compiler
Andrew Shitov
 
PDF
Perl 5.10 in 2010
Andrew Shitov
 
PDF
Perl 5.10 в 2010-м
Andrew Shitov
 
PDF
‎Откуда узнать про Perl 6‎
Andrew Shitov
 
Perl jobs market in 2024, how good is it?
Andrew Shitov
 
Fun with Raspberry PI (and Perl)
Andrew Shitov
 
Параллельные вычисления в Perl 6
Andrew Shitov
 
AllPerlBooks.com
Andrew Shitov
 
YAPC::Europe 2013
Andrew Shitov
 
Perl 7, the story of
Andrew Shitov
 
Язык программирования Go для Perl-программистов
Andrew Shitov
 
Как очистить массив
Andrew Shitov
 
What's new in Perl 5.14
Andrew Shitov
 
Что нового в Perl 5.14
Andrew Shitov
 
Perl6 grammars
Andrew Shitov
 
Text in search queries with examples in Perl 6
Andrew Shitov
 
There's more than one way to empty it
Andrew Shitov
 
How to clean an array
Andrew Shitov
 
Perl 5.10 и 5.12
Andrew Shitov
 
Say Perl на весь мир
Andrew Shitov
 
Personal Perl 6 compiler
Andrew Shitov
 
Perl 5.10 in 2010
Andrew Shitov
 
Perl 5.10 в 2010-м
Andrew Shitov
 
‎Откуда узнать про Perl 6‎
Andrew Shitov
 

Recently uploaded (20)

PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
georgschmitzdoerner
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Doc9.....................................
SofiaCollazos
 
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
PDF
Google’s NotebookLM Unveils Video Overviews
SOFTTECHHUB
 
PDF
DevOps & Developer Experience Summer BBQ
AUGNYC
 
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Captain IT
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
CIFDAQ
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
madgavkar20181017ppt McKinsey Presentation.pdf
georgschmitzdoerner
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Doc9.....................................
SofiaCollazos
 
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
CIFDAQ
 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
Why Your AI & Cybersecurity Hiring Still Misses the Mark in 2025
Virtual Employee Pvt. Ltd.
 
Google’s NotebookLM Unveils Video Overviews
SOFTTECHHUB
 
DevOps & Developer Experience Summer BBQ
AUGNYC
 
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Captain IT
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
CIFDAQ
 
This slide provides an overview Technology
mineshkharadi333
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 

Perl 6 for Concurrency and Parallel Computing