SlideShare a Scribd company logo
1 of 24
Perl6
A Whistle Stop Tour
Obligatory About Me Slide
Hi.
I’m Simon. (Also known as Scimon in many places)
I write Perl and when I can Perl6.
I’ve been doing it for 15 years and a bit. (Not the Perl6… well)
Now working at Zoopla. We’re hiring, (not sure where we’ll put you…)
Wrote Timer::Breakable, writing more modules.
A Disclaimer
I am still learning Perl6.
It’s a massive powerful language with a lot of scope to create amazing stuff.
Some of the things I say today may be wrong.
This will be because I still don’t fully understand some of the really neat things I’m
playing with.
But all the code examples I give work!
I tested them all.
Humourous Caption Slide
The Year of Linux on the Desktop!
1998, 1999, 2000, 2001, 2002 …
The Year of Perl6 in Production ?
2018...
Multiple Programming Paradigms
What’s your poison?
● Functional Programming ?
● Object Orientated ?
● Reactive or Event Based ?
● Strongly Typed ?
● Weakly Typed ?
Perl6 builds in the concept of the swiss army chainsaw and gives you a toolbox
from which you can build whatever chainsaw you want.
List::Util
● reduce : [+] @a or @a.reduce(*+*)
● any : so any(@a) > 10
● all : so all(@a) > 10
● none : so none(@a) > 10
● first : @a.first( * > 10 )
● max : @a.max
● maxstr : @a.max( *.Str )
● min : @a.min
● minstr : @a.min( *.Str )
● product : [*] @a or @a.reduce(* * *)
● sum : @a ?? @a.sum !! Nil
● sum0 : @a.sum
● shuffle : @a.pick(@a)
● uniq : @a.unique
● uniqnum : @a.unique( :as( *.Num ) )
● uniqstr : @a.unique( :as( *.Str ) )
Perl6 has Pairs as a Type making the pair methods redundant.
Note that Perl6 is typed and casting a string to a number may raise an exception.
Junctions
my @array = ( False, False, False );
my ( $all, $none, $any ) = ( all(@array), none(@array), any(@array) );
say "All : {$all.so} None: {$none.so} Any: {$any.so}";
All: False None: True Any: False
@array[0] = True;
say "All : {$all.so} None: {$none.so} Any: {$any.so}";
All: False None: False Any: True
4 < 1^2^3^4^5 < 2 == True; # one(1,2,3,4,5)
4 < 1|2|3|4|5 < 2 == True; # any(1,2,3,4,5)
4 < 1&2&3&4&5 < 2 == False; # all(1,2,3,4,5)
Junction Sudoku
my @cells =
[ [ 2, 1, 3, 4 ],
[ 3, 4, 1, 2 ],
[ 2, 3, 4, 1 ],
[ 4, 1, 2, 3 ] ];
my @test-array;
for 0..3 -> $c {
@test-array.push(
one(
(0..3).map(
{
@cells[$c][$_]
}
)
)
);
}
Junction Sudoku
my @cells =
[ [ 2, 1, 3, 4 ],
[ 3, 4, 1, 2 ],
[ 2, 3, 4, 1 ],
[ 4, 1, 2, 3 ] ];
my @test-array;
for 0..3 -> $c {
@test-array.push(
one(
(0..3).map(
{
@cells[$_][$c]
}
)
)
);
}
Junction Sudoku
my @cells =
[ [ 2, 1, 3, 4 ],
[ 3, 4, 1, 2 ],
[ 2, 3, 4, 1 ],
[ 4, 1, 2, 3 ] ];
my @test-array;
for (0,0), (0,2),
(2,0), (2,2) -> ($y, $x) {
@test-array.push(
one(
@cells[$y][$x],
@cells[$y][$x+1],
@cells[$y+1][$x],
@cells[$y+1][$x+1]
)
);
}
Junction Sudoku
my @cells =
[ [ 2, 1, 3, 4 ],
[ 3, 4, 1, 2 ],
[ 2, 3, 4, 1 ],
[ 4, 1, 2, 3 ] ];
{ … Setup Here … }
my $test-all = all( @test-array );
sub test {
? [&&] (1..4).map( * == $test-all );
}
Junction Sudoku (Complete)
my @cells = [ [ 2, 1, 3, 4 ],
[ 3, 4, 1, 2 ],
[ 2, 3, 4, 1 ],
[ 4, 1, 2, 3 ] ];
my @test-array;
for (0,0), (0,2), (2,0), (2,2) -> ($y, $x) {
@test-array.push(
one( @cells[$y][$x], @cells[$y][$x+1],
@cells[$y+1][$x], @cells[$y+1][$x+1] ) );
}
for 0..3 -> $c {
@test-array.push(
one( (0..3).map( { @cells[$c][$_] } ) ) );
@test-array.push(
one( (0..3).map( { @cells[$_][$c] } ) ) );
}
my $test-all = all( @test-array );
sub test {
so [&&] (1..4).map( * == $test-all );
}
sub output {
@cells.map( *.join( " " ) ).join( "n" ).say;
}
output();
say test() ?? "Valid" !! "Invalid";
( @cells[0][0], @cells[0][1] ) =
( @cells[0][1], @cells[0][0] );
output();
say test() ?? "Valid" !! "Invalid";
Promises
“Asynchronous programming for mortals” or “No more callback hell”
my $p1 = start { sleep 3; print “Or a simple start? ”; };
my $p2 = Promise.in(2).then( { print “Why not use a timer? ” } );
my $p3 = Promise.anyof( $p1, $p2 ).then( { print “Something is done. ” } );
my $p4 = Promise.allof( $p1, $p2, $p3 ).then( { print “All the promises done.” } );
print “Promises Begun… ”;
await( $p1, $p2, $p3, $p4 );
say “All done.”;
Promises Begun… Why not use a timer? Something is done. Or a simple start? All the
promises done. All done.
With some pauses…
Channels and Supplies
constant children = 8;
sub MAIN( Str $text ) {
my $dir-channel = Channel.new();
my $file-channel = Channel.new();
my @readers;
for (^8) -> $idx {
@readers[$idx] = Promise.new();
my $sup = $file-channel.Supply.map( -> $path {
my @a = $path.lines.grep( {
defined $_.index($text)
} ); $path => @a
} ).tap( -> $data {
for $data.value { say("{$data.key} : {$_}") }
}, done => { @readers[$idx].keep } );
}
for dir( "." ) -> $p { $dir-channel.send($p) };
loop {
if $dir-channel.poll -> $path {
if ( $path.d ) {
$dir-channel.send( $_ )
for dir( $path )
} elsif ( $path.f ) {
$file-channel.send( $path );
}
} else {
$dir-channel.close;
$file-channel.close;
last;
}
}
await( @readers );
}
Channels and Supplies (Feeds : Secret Sauce)
my $sup = $file-channel.Supply
.map( -> $path {
my @a = $path.lines.grep( {
defined $_.index($text)
} ); $path => @a
} )
.tap( -> $data {
for $data.value { say("{$data.key} : {$_}") }
}, done => { @readers[$idx].keep } );
Sequences, Lazy Evaluation and Rational Numbers
my @primes = (1..*).grep( *.is-prime );
my @evens = 2,4,6...*;
my @fib = 1, 1, * + * ... *;
my $div0 = 42 / 0;
say $div0.nude; # NU(merator and) DE(nominator)
(42 0)
say 0.2 + 0.1 - 0.3 == 0; True
Sets and Bags
my @primes = (1..*).grep( *.is-prime );
my @fib = 1,2,*+*...*;
my $prime-set = set( @primes[0..50] );
say $_, " prime? ", $_ ∈ $prime-set
for @fib[0..5];
say $prime-set ∩ @fib[0..10];
(elem) and ∈ are synonyms as are (&) and ∩
Note : Set operators auto coerce their args to
Sets.
1 prime? False
2 prime? True
3 prime? True
5 prime? True
8 prime? False
13 prime? True
set(13 2 3 5 89)
Native Call
use Cairo;
given Cairo::Image.create(Cairo::FORMAT_ARGB32, 128, 128) {
given Cairo::Context.new($_) {
for 1..16 -> $x {
for 1..16 -> $y {
.rgb($x/16, $y/16, 0 );
.rectangle( 8 * ( $x - 1), 8 * ( $y - 1 ), 8 , 8 );
.fill;
}
}
};
.write_png("test2.png")
}
https://github.com/timo/cairo-p6
NativeCall (A peek inside)
method write_to_png(Str $filename)
returns int32
is native($cairolib)
is symbol('cairo_surface_write_to_png') {*}
method rectangle(num64 $x, num64 $y, num64 $w, num64 $h)
is native($cairolib)
is symbol('cairo_rectangle') {*}
That simple. Here $cairolib is either 'libcairo-2' or ('cairo', v2)
depending on the architecture.
Roles
Yeah you know roles right? Well what about this?
role logger {
method log-msg ( Str $msg ) { say “{$msg} : {self.perl}” }
};
my $num = 5;
$num.?log-msg( "Not a logger" );
$num does logger;
$num.?log-msg( "Loggable" );
Or
my $result = 0 but True;
Unicode
my $á1 = “c[LATIN SMALL LETTER A WITH ACUTE]”; # Smart Quotes!
my $á2 = “ax301”;
say “$á1 : $á2”;
á : á
say $á1 eq á2;
True
say “$á1 : $á2”.uc;
Á : Á
my $æ = 2;
$æ = ( $æ * ¾ )²;
say “æ => $æ”;
æ => 2.25
All the other stuff
● Grammars
● Imaginary Numbers
● Proper Exceptions
● CPAN
● Meta Objects
● Telemetry
● JVM
● RakudoJS
● IO::Notification
● Date and DateTime built in
● (And so much more)
Further Reading (and Viewing)
● Perl 6 Docs - https://docs.perl6.org/
● High End Unicode in Perl 6 - https://youtu.be/Oj_lgf7A2LM
● Perl6 Superglue for the 21st Century - https://www.youtube.com/watch?v=q8stPrG1rDo
● Think Perl 6 - http://greenteapress.com/wp/think-perl-6/
● Using Perl 6 - https://deeptext.media/using-perl6
● Learning Perl 6 (On the Way) - https://www.learningperl6.com/
● Cro - http://cro.services/
● Bailador - https://github.com/Bailador/Bailador
● Sparrowdo - https://github.com/melezhik/sparrowdo
● Spitsh - https://github.com/spitsh/spitsh
● Roles vs Inheritance - https://www.youtube.com/watch?v=cjoWu4eq1Tw
Questions?

More Related Content

What's hot

Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語ikdysfm
 
How to write code you won't hate tomorrow
How to write code you won't hate tomorrowHow to write code you won't hate tomorrow
How to write code you won't hate tomorrowPete McFarlane
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8XSolve
 
The Magic Of Tie
The Magic Of TieThe Magic Of Tie
The Magic Of Tiebrian d foy
 
Haskell in the Real World
Haskell in the Real WorldHaskell in the Real World
Haskell in the Real Worldosfameron
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedSusan Potter
 
Tuga it 2016 - What's New In C# 6
Tuga it 2016 - What's New In C# 6Tuga it 2016 - What's New In C# 6
Tuga it 2016 - What's New In C# 6Paulo Morgado
 
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPatrick Allaert
 
RxSwift 시작하기
RxSwift 시작하기RxSwift 시작하기
RxSwift 시작하기Suyeol Jeon
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonUC San Diego
 
PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)Nikita Popov
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in RustIngvar Stepanyan
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기JangHyuk You
 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Codestasimus
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureMike Fogus
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Nikita Popov
 

What's hot (19)

Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
How to write code you won't hate tomorrow
How to write code you won't hate tomorrowHow to write code you won't hate tomorrow
How to write code you won't hate tomorrow
 
Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8Xlab #1: Advantages of functional programming in Java 8
Xlab #1: Advantages of functional programming in Java 8
 
The Magic Of Tie
The Magic Of TieThe Magic Of Tie
The Magic Of Tie
 
What's New In C# 7
What's New In C# 7What's New In C# 7
What's New In C# 7
 
Haskell in the Real World
Haskell in the Real WorldHaskell in the Real World
Haskell in the Real World
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
 
Tuga it 2016 - What's New In C# 6
Tuga it 2016 - What's New In C# 6Tuga it 2016 - What's New In C# 6
Tuga it 2016 - What's New In C# 6
 
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, ItalyPHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
PHP data structures (and the impact of php 7 on them), phpDay Verona 2015, Italy
 
RxSwift 시작하기
RxSwift 시작하기RxSwift 시작하기
RxSwift 시작하기
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)PHP 7 – What changed internally? (PHP Barcelona 2015)
PHP 7 – What changed internally? (PHP Barcelona 2015)
 
CoffeeScript
CoffeeScriptCoffeeScript
CoffeeScript
 
Building fast interpreters in Rust
Building fast interpreters in RustBuilding fast interpreters in Rust
Building fast interpreters in Rust
 
Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기Programming Lisp Clojure - 2장 : 클로저 둘러보기
Programming Lisp Clojure - 2장 : 클로저 둘러보기
 
Groovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony CodeGroovy vs Boilerplate and Ceremony Code
Groovy vs Boilerplate and Ceremony Code
 
Fertile Ground: The Roots of Clojure
Fertile Ground: The Roots of ClojureFertile Ground: The Roots of Clojure
Fertile Ground: The Roots of Clojure
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)
 
Java Cheat Sheet
Java Cheat SheetJava Cheat Sheet
Java Cheat Sheet
 

Similar to Perl6 a whistle stop tour

Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Kang-min Liu
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6FITC
 
Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Lucas Witold Adamus
 
Functional perl
Functional perlFunctional perl
Functional perlErrorific
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlSway Wang
 
Writing Maintainable Perl
Writing Maintainable PerlWriting Maintainable Perl
Writing Maintainable Perltinypigdotcom
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic trapsDamien Seguy
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Seri Moth
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongersbrian d foy
 
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsPERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsSunil Kumar Gunasekaran
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developersStoyan Stefanov
 
Scripting3
Scripting3Scripting3
Scripting3Nao Dara
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type Systemabrummett
 
20220112 sac v1
20220112 sac v120220112 sac v1
20220112 sac v1Sharon Liu
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolveXSolve
 

Similar to Perl6 a whistle stop tour (20)

Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6
 
Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?Why async and functional programming in PHP7 suck and how to get overr it?
Why async and functional programming in PHP7 suck and how to get overr it?
 
Functional perl
Functional perlFunctional perl
Functional perl
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Writing Maintainable Perl
Writing Maintainable PerlWriting Maintainable Perl
Writing Maintainable Perl
 
Top 10 php classic traps
Top 10 php classic trapsTop 10 php classic traps
Top 10 php classic traps
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02Jsphp 110312161301-phpapp02
Jsphp 110312161301-phpapp02
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
PERL for QA - Important Commands and applications
PERL for QA - Important Commands and applicationsPERL for QA - Important Commands and applications
PERL for QA - Important Commands and applications
 
Short intro to ECMAScript
Short intro to ECMAScriptShort intro to ECMAScript
Short intro to ECMAScript
 
JavaScript for PHP developers
JavaScript for PHP developersJavaScript for PHP developers
JavaScript for PHP developers
 
Scripting3
Scripting3Scripting3
Scripting3
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Php functions
Php functionsPhp functions
Php functions
 
The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type System
 
20220112 sac v1
20220112 sac v120220112 sac v1
20220112 sac v1
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
 

More from Simon Proctor

An introduction to Raku
An introduction to RakuAn introduction to Raku
An introduction to RakuSimon Proctor
 
Building a raku module
Building a raku moduleBuilding a raku module
Building a raku moduleSimon Proctor
 
Perl6 operators and metaoperators
Perl6   operators and metaoperatorsPerl6   operators and metaoperators
Perl6 operators and metaoperatorsSimon Proctor
 
Perl 6 command line scripting
Perl 6 command line scriptingPerl 6 command line scripting
Perl 6 command line scriptingSimon Proctor
 
Perl6 signatures, types and multicall
Perl6 signatures, types and multicallPerl6 signatures, types and multicall
Perl6 signatures, types and multicallSimon Proctor
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tourSimon Proctor
 

More from Simon Proctor (10)

An introduction to Raku
An introduction to RakuAn introduction to Raku
An introduction to Raku
 
Building a raku module
Building a raku moduleBuilding a raku module
Building a raku module
 
Multi stage docker
Multi stage dockerMulti stage docker
Multi stage docker
 
Phasers to stunning
Phasers to stunningPhasers to stunning
Phasers to stunning
 
Perl6 operators and metaoperators
Perl6   operators and metaoperatorsPerl6   operators and metaoperators
Perl6 operators and metaoperators
 
24 uses for perl6
24 uses for perl624 uses for perl6
24 uses for perl6
 
Perl 6 command line scripting
Perl 6 command line scriptingPerl 6 command line scripting
Perl 6 command line scripting
 
Perl6 signatures, types and multicall
Perl6 signatures, types and multicallPerl6 signatures, types and multicall
Perl6 signatures, types and multicall
 
Perl6 signatures
Perl6 signaturesPerl6 signatures
Perl6 signatures
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 

Recently uploaded

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 

Recently uploaded (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Perl6 a whistle stop tour

  • 2. Obligatory About Me Slide Hi. I’m Simon. (Also known as Scimon in many places) I write Perl and when I can Perl6. I’ve been doing it for 15 years and a bit. (Not the Perl6… well) Now working at Zoopla. We’re hiring, (not sure where we’ll put you…) Wrote Timer::Breakable, writing more modules.
  • 3. A Disclaimer I am still learning Perl6. It’s a massive powerful language with a lot of scope to create amazing stuff. Some of the things I say today may be wrong. This will be because I still don’t fully understand some of the really neat things I’m playing with. But all the code examples I give work! I tested them all.
  • 4. Humourous Caption Slide The Year of Linux on the Desktop! 1998, 1999, 2000, 2001, 2002 … The Year of Perl6 in Production ? 2018...
  • 5. Multiple Programming Paradigms What’s your poison? ● Functional Programming ? ● Object Orientated ? ● Reactive or Event Based ? ● Strongly Typed ? ● Weakly Typed ? Perl6 builds in the concept of the swiss army chainsaw and gives you a toolbox from which you can build whatever chainsaw you want.
  • 6. List::Util ● reduce : [+] @a or @a.reduce(*+*) ● any : so any(@a) > 10 ● all : so all(@a) > 10 ● none : so none(@a) > 10 ● first : @a.first( * > 10 ) ● max : @a.max ● maxstr : @a.max( *.Str ) ● min : @a.min ● minstr : @a.min( *.Str ) ● product : [*] @a or @a.reduce(* * *) ● sum : @a ?? @a.sum !! Nil ● sum0 : @a.sum ● shuffle : @a.pick(@a) ● uniq : @a.unique ● uniqnum : @a.unique( :as( *.Num ) ) ● uniqstr : @a.unique( :as( *.Str ) ) Perl6 has Pairs as a Type making the pair methods redundant. Note that Perl6 is typed and casting a string to a number may raise an exception.
  • 7. Junctions my @array = ( False, False, False ); my ( $all, $none, $any ) = ( all(@array), none(@array), any(@array) ); say "All : {$all.so} None: {$none.so} Any: {$any.so}"; All: False None: True Any: False @array[0] = True; say "All : {$all.so} None: {$none.so} Any: {$any.so}"; All: False None: False Any: True 4 < 1^2^3^4^5 < 2 == True; # one(1,2,3,4,5) 4 < 1|2|3|4|5 < 2 == True; # any(1,2,3,4,5) 4 < 1&2&3&4&5 < 2 == False; # all(1,2,3,4,5)
  • 8. Junction Sudoku my @cells = [ [ 2, 1, 3, 4 ], [ 3, 4, 1, 2 ], [ 2, 3, 4, 1 ], [ 4, 1, 2, 3 ] ]; my @test-array; for 0..3 -> $c { @test-array.push( one( (0..3).map( { @cells[$c][$_] } ) ) ); }
  • 9. Junction Sudoku my @cells = [ [ 2, 1, 3, 4 ], [ 3, 4, 1, 2 ], [ 2, 3, 4, 1 ], [ 4, 1, 2, 3 ] ]; my @test-array; for 0..3 -> $c { @test-array.push( one( (0..3).map( { @cells[$_][$c] } ) ) ); }
  • 10. Junction Sudoku my @cells = [ [ 2, 1, 3, 4 ], [ 3, 4, 1, 2 ], [ 2, 3, 4, 1 ], [ 4, 1, 2, 3 ] ]; my @test-array; for (0,0), (0,2), (2,0), (2,2) -> ($y, $x) { @test-array.push( one( @cells[$y][$x], @cells[$y][$x+1], @cells[$y+1][$x], @cells[$y+1][$x+1] ) ); }
  • 11. Junction Sudoku my @cells = [ [ 2, 1, 3, 4 ], [ 3, 4, 1, 2 ], [ 2, 3, 4, 1 ], [ 4, 1, 2, 3 ] ]; { … Setup Here … } my $test-all = all( @test-array ); sub test { ? [&&] (1..4).map( * == $test-all ); }
  • 12. Junction Sudoku (Complete) my @cells = [ [ 2, 1, 3, 4 ], [ 3, 4, 1, 2 ], [ 2, 3, 4, 1 ], [ 4, 1, 2, 3 ] ]; my @test-array; for (0,0), (0,2), (2,0), (2,2) -> ($y, $x) { @test-array.push( one( @cells[$y][$x], @cells[$y][$x+1], @cells[$y+1][$x], @cells[$y+1][$x+1] ) ); } for 0..3 -> $c { @test-array.push( one( (0..3).map( { @cells[$c][$_] } ) ) ); @test-array.push( one( (0..3).map( { @cells[$_][$c] } ) ) ); } my $test-all = all( @test-array ); sub test { so [&&] (1..4).map( * == $test-all ); } sub output { @cells.map( *.join( " " ) ).join( "n" ).say; } output(); say test() ?? "Valid" !! "Invalid"; ( @cells[0][0], @cells[0][1] ) = ( @cells[0][1], @cells[0][0] ); output(); say test() ?? "Valid" !! "Invalid";
  • 13. Promises “Asynchronous programming for mortals” or “No more callback hell” my $p1 = start { sleep 3; print “Or a simple start? ”; }; my $p2 = Promise.in(2).then( { print “Why not use a timer? ” } ); my $p3 = Promise.anyof( $p1, $p2 ).then( { print “Something is done. ” } ); my $p4 = Promise.allof( $p1, $p2, $p3 ).then( { print “All the promises done.” } ); print “Promises Begun… ”; await( $p1, $p2, $p3, $p4 ); say “All done.”; Promises Begun… Why not use a timer? Something is done. Or a simple start? All the promises done. All done. With some pauses…
  • 14. Channels and Supplies constant children = 8; sub MAIN( Str $text ) { my $dir-channel = Channel.new(); my $file-channel = Channel.new(); my @readers; for (^8) -> $idx { @readers[$idx] = Promise.new(); my $sup = $file-channel.Supply.map( -> $path { my @a = $path.lines.grep( { defined $_.index($text) } ); $path => @a } ).tap( -> $data { for $data.value { say("{$data.key} : {$_}") } }, done => { @readers[$idx].keep } ); } for dir( "." ) -> $p { $dir-channel.send($p) }; loop { if $dir-channel.poll -> $path { if ( $path.d ) { $dir-channel.send( $_ ) for dir( $path ) } elsif ( $path.f ) { $file-channel.send( $path ); } } else { $dir-channel.close; $file-channel.close; last; } } await( @readers ); }
  • 15. Channels and Supplies (Feeds : Secret Sauce) my $sup = $file-channel.Supply .map( -> $path { my @a = $path.lines.grep( { defined $_.index($text) } ); $path => @a } ) .tap( -> $data { for $data.value { say("{$data.key} : {$_}") } }, done => { @readers[$idx].keep } );
  • 16. Sequences, Lazy Evaluation and Rational Numbers my @primes = (1..*).grep( *.is-prime ); my @evens = 2,4,6...*; my @fib = 1, 1, * + * ... *; my $div0 = 42 / 0; say $div0.nude; # NU(merator and) DE(nominator) (42 0) say 0.2 + 0.1 - 0.3 == 0; True
  • 17. Sets and Bags my @primes = (1..*).grep( *.is-prime ); my @fib = 1,2,*+*...*; my $prime-set = set( @primes[0..50] ); say $_, " prime? ", $_ ∈ $prime-set for @fib[0..5]; say $prime-set ∩ @fib[0..10]; (elem) and ∈ are synonyms as are (&) and ∩ Note : Set operators auto coerce their args to Sets. 1 prime? False 2 prime? True 3 prime? True 5 prime? True 8 prime? False 13 prime? True set(13 2 3 5 89)
  • 18. Native Call use Cairo; given Cairo::Image.create(Cairo::FORMAT_ARGB32, 128, 128) { given Cairo::Context.new($_) { for 1..16 -> $x { for 1..16 -> $y { .rgb($x/16, $y/16, 0 ); .rectangle( 8 * ( $x - 1), 8 * ( $y - 1 ), 8 , 8 ); .fill; } } }; .write_png("test2.png") } https://github.com/timo/cairo-p6
  • 19. NativeCall (A peek inside) method write_to_png(Str $filename) returns int32 is native($cairolib) is symbol('cairo_surface_write_to_png') {*} method rectangle(num64 $x, num64 $y, num64 $w, num64 $h) is native($cairolib) is symbol('cairo_rectangle') {*} That simple. Here $cairolib is either 'libcairo-2' or ('cairo', v2) depending on the architecture.
  • 20. Roles Yeah you know roles right? Well what about this? role logger { method log-msg ( Str $msg ) { say “{$msg} : {self.perl}” } }; my $num = 5; $num.?log-msg( "Not a logger" ); $num does logger; $num.?log-msg( "Loggable" ); Or my $result = 0 but True;
  • 21. Unicode my $á1 = “c[LATIN SMALL LETTER A WITH ACUTE]”; # Smart Quotes! my $á2 = “ax301”; say “$á1 : $á2”; á : á say $á1 eq á2; True say “$á1 : $á2”.uc; Á : Á my $æ = 2; $æ = ( $æ * ¾ )²; say “æ => $æ”; æ => 2.25
  • 22. All the other stuff ● Grammars ● Imaginary Numbers ● Proper Exceptions ● CPAN ● Meta Objects ● Telemetry ● JVM ● RakudoJS ● IO::Notification ● Date and DateTime built in ● (And so much more)
  • 23. Further Reading (and Viewing) ● Perl 6 Docs - https://docs.perl6.org/ ● High End Unicode in Perl 6 - https://youtu.be/Oj_lgf7A2LM ● Perl6 Superglue for the 21st Century - https://www.youtube.com/watch?v=q8stPrG1rDo ● Think Perl 6 - http://greenteapress.com/wp/think-perl-6/ ● Using Perl 6 - https://deeptext.media/using-perl6 ● Learning Perl 6 (On the Way) - https://www.learningperl6.com/ ● Cro - http://cro.services/ ● Bailador - https://github.com/Bailador/Bailador ● Sparrowdo - https://github.com/melezhik/sparrowdo ● Spitsh - https://github.com/spitsh/spitsh ● Roles vs Inheritance - https://www.youtube.com/watch?v=cjoWu4eq1Tw