SlideShare a Scribd company logo
1 of 335
Download to read offline
Pugs
An implementation of

     Perl 6
              Audrey Tang
≝
Pugs...
Pugs...
≝   Perl 6 Compiler
Pugs...
≝   Perl 6 Compiler
≝   Perl 6 Runtime
Pugs...
≝   Perl 6 Compiler
≝   Perl 6 Runtime
≝   Perl 6 Test Suite
✓
Perl 6 Code
Perl 6 Code

✓ 130+ Modules
Perl 6 Code

✓ 130+ Modules
✓ 160+ Examples
Perl 6 Code

✓ 130+ Modules
✓ 160+ Examples
✓ 18,000+ Unit Tests
“Official Perl 6”
“Official Perl 6”
✓ Defined by semantics,
  not by accidents of history
“Official Perl 6”
✓ Defined by semantics,
  not by accidents of history
✓ Compatibility test suite
  (cf. JavaTest/TCK)
Spec   Test


   ✓
Test   Spec


       ✓
⇚
Perl, circa 1995
Perl, circa 1995
• use   5.000;
Perl, circa 1995
• use 5.000;
• require 'fastcwd.pl';
Perl, circa 1995
• use 5.000;
• require 'fastcwd.pl';
• require 'newgetopt.pl';
Perl, circa 1995
• use 5.000;
• require 'fastcwd.pl';
• require 'newgetopt.pl';
• require 'exceptions.pl';
Perl, circa 2005
Perl, circa 2005
• use   v6-alpha;
Perl, circa 2005
• use   v6-alpha;
• use   perl5:DBI;
Perl, circa 2005
• use   v6-alpha;
• use   perl5:DBI;
• use   perl5:Encode <encode decode>;
Perl, circa 2005
• use   v6-alpha;
• use   perl5:DBI;
• use   perl5:Encode <encode decode>;
• use   perl5:Template;
Perl, circa 2005
• use v6-alpha;
• use perl5:DBI;
• use perl5:Encode <encode decode>;
• use perl5:Template;
• # Implementation of "crypt"
  eval "crypt()" :lang<perl5>;
Hybrid Runcore
                  Pugs


           GHC           Perl 5
          Runtime       Runtime


           Pugs.Eval   Pugs::Runtime
          Pugs.Prim    Pugs::Compiler
          Pugs.Types   Pugs::Grammar
Hybrid Runcore
                     Pugs
⇚ Perl 5
              GHC           Perl 5
             Runtime       Runtime


              Pugs.Eval   Pugs::Runtime
             Pugs.Prim    Pugs::Compiler
             Pugs.Types   Pugs::Grammar
Hybrid Runcore
                     Pugs
⇚ Perl 5
              GHC           Perl 5
⇚ Haskell    Runtime       Runtime


              Pugs.Eval   Pugs::Runtime
             Pugs.Prim    Pugs::Compiler
             Pugs.Types   Pugs::Grammar
Hybrid Runcore
                         Pugs
⇚ Perl 5
                  GHC           Perl 5
⇚ Haskell        Runtime       Runtime



⇚ C (.so/.dll)    Pugs.Eval
                 Pugs.Prim
                 Pugs.Types
                              Pugs::Runtime
                              Pugs::Compiler
                              Pugs::Grammar
⇛
Pugs
Intermediate
Language
Compilation Flow
Backends

          Pugs




 Java
          Haskell   Perl 5
 Script
Backends
JVM?                                         YARV?

                       Pugs

       CLR?                               PyPy?




              Java
                       Haskell   Perl 5
              Script
Perl 5 Backend
                           Tool Support
                           CPAN, PAUSE
                         Perldoc, Perl::Tidy ...

                               Syntax
                                v6.pm
                        Pugs::Compiler::Perl6 ...

                           Perl 5 Sugar
                      Moose, Moose::Autobox ...


                             Semantics
                        Data::Bind, Class::MOP
                 Pugs::Runtime, Pugs::Compiler::Rule ...

            Augmentation (XS) Infrastructure
            PadWalker, Devel::Caller       Parse::Yapp
             autobox, re::override ...   Module::Compile ...

                                 Core
                                 perl
Perl 5 Backend
⇛ Augment P5VM                  Tool Support
                                CPAN, PAUSE
                              Perldoc, Perl::Tidy ...

                                    Syntax
                                     v6.pm
                             Pugs::Compiler::Perl6 ...

                                Perl 5 Sugar
                           Moose, Moose::Autobox ...


                                  Semantics
                             Data::Bind, Class::MOP
                      Pugs::Runtime, Pugs::Compiler::Rule ...

                 Augmentation (XS) Infrastructure
                 PadWalker, Devel::Caller       Parse::Yapp
                  autobox, re::override ...   Module::Compile ...

                                      Core
                                      perl
Perl 5 Backend
⇛ Augment P5VM                     Tool Support
                                   CPAN, PAUSE
                                 Perldoc, Perl::Tidy ...

                                       Syntax
                                        v6.pm
                                Pugs::Compiler::Perl6 ...




⇛ Deploy P6 as P5                  Perl 5 Sugar
                              Moose, Moose::Autobox ...


                                     Semantics
                                Data::Bind, Class::MOP
                         Pugs::Runtime, Pugs::Compiler::Rule ...

                    Augmentation (XS) Infrastructure
                    PadWalker, Devel::Caller       Parse::Yapp
                     autobox, re::override ...   Module::Compile ...

                                         Core
                                         perl
Perl 5 Backend
⇛ Augment P5VM                     Tool Support
                                   CPAN, PAUSE
                                 Perldoc, Perl::Tidy ...

                                       Syntax
                                        v6.pm
                                Pugs::Compiler::Perl6 ...




⇛ Deploy P6 as P5                  Perl 5 Sugar
                              Moose, Moose::Autobox ...


                                     Semantics
                                Data::Bind, Class::MOP
                         Pugs::Runtime, Pugs::Compiler::Rule ...




⇛ v6.pm on CPAN
                    Augmentation (XS) Infrastructure
                    PadWalker, Devel::Caller       Parse::Yapp
                     autobox, re::override ...   Module::Compile ...

                                         Core
                                         perl
JavaScript Backend
JavaScript Backend
⇛ Like GWT, Hop, Links...
JavaScript Backend
⇛ Like GWT, Hop, Links...
⇛ Passes 90% of tests
JavaScript Backend
⇛ Like GWT, Hop, Links...
⇛ Passes 90% of tests
⇛ Slow - Aim for JS2/Tamarin
䷗
6.0
Primitives
    ䷁
6.2
Functions
   ䷗
6.28
Objects
  ䷒
6.283
Grammars
   ䷊
6.2831
Types
  ䷡
6.28318
Macros
   ䷪
6.283185
Self Hosting
     ䷀
2π
Perl 6!
≠
“Frivolous Toy
  interpreter”
(as seen on Slashdot)
“Frivolous
Toy interpreter”
“Frivolous
Toy interpreter”
“Toy interpreter”
“Toy interpreter”
“Toy”
-Ofun
☺
Arrow length
               15500+ commits




               290+ committers




                       Time
Test Driven
Test Driven

☺Bug report ➟ Test
Test Driven

☺Bug report ➟ Test
☺Smoke Server
Test Driven

☺Bug report ➟ Test
☺Smoke Server
☺:todo<unspecced>
Anarchistic
Anarchistic

☺10+ languages
Anarchistic

☺10+ languages
☺30+ sub-projects
Anarchistic

☺10+ languages
☺30+ sub-projects
☺Aggressive recruiting
Patches Welcome !
Patches Welcome !
Commits Welcome!
✆
irc.freenode.net
      #perl6
λ Camels
λ Camels

✆ 200+ People
λ Camels

✆ 200+ People
✆ 20+ Regulars
λ Camels

✆ 200+ People
✆ 20+ Regulars
✆ TimToady++
svnbot6
evalbot6
devbot6
lambdabot
IRC.pugscode.org
Run.pugscode.org
Dev.pugscode.org
Invite.pugscode.org
Smoke.pugscode.org
Spec.pugscode.org
Blog.pugscode.org
Mailing Lists
Mailing Lists

✆ perl6-users
Mailing Lists

✆ perl6-users
✆ perl6-language
Mailing Lists

✆ perl6-users
✆ perl6-language
✆ perl6-compiler
Repositories
Repositories
     http://svn.pugscode.org/pugs/
Repositories
     http://svn.pugscode.org/pugs/

    http://darcs.pugscode.org/pugs/
Repositories
     http://svn.pugscode.org/pugs/

    http://darcs.pugscode.org/pugs/




    SVK
Erdösing
Erdösing




  2006..*
Hackathons
Hackathons
Taipei
Hackathons
Taipei
Vienna
Hackathons
Taipei
Vienna
Toronto
Hackathons
Taipei
Vienna
Toronto
Amsterdam
Hackathons
Taipei
Vienna
Toronto
Amsterdam
Echt
Hackathons
Taipei
Vienna
Toronto
Amsterdam
Echt
Lismore
Hackathons
Taipei
Vienna
Toronto
Amsterdam
Echt
Lismore
Mt. Arbel
Hackathons
Taipei      Vienna2


Vienna
Toronto
Amsterdam
Echt
Lismore
Mt. Arbel
Hackathons
Taipei      Vienna2


Vienna      Tokyo
Toronto
Amsterdam
Echt
Lismore
Mt. Arbel
Hackathons
Taipei      Vienna2


Vienna      Tokyo
Toronto     Redmond
Amsterdam
Echt
Lismore
Mt. Arbel
Hackathons
Taipei      Vienna2


Vienna      Tokyo
Toronto     Redmond
Amsterdam   Chicago
Echt
Lismore
Mt. Arbel
Hackathons
Taipei      Vienna2


Vienna      Tokyo
Toronto     Redmond
Amsterdam   Chicago
Echt        Boston
Lismore
Mt. Arbel
Hackathons
Taipei      Vienna2


Vienna      Tokyo
Toronto     Redmond
Amsterdam   Chicago
Echt        Boston
Lismore     Portland
Mt. Arbel
Hackathons
Taipei      Vienna2


Vienna      Tokyo
Toronto     Redmond
Amsterdam   Chicago
Echt        Boston
Lismore     Portland
Mt. Arbel   Sao Paulo
Hackathons
Taipei      Vienna2


Vienna      Tokyo
Toronto     Redmond
Amsterdam   Chicago
Echt        Boston
Lismore     Portland
Mt. Arbel   Sao Paulo
            Mountain View?
Perl 6
 Reconciling the
Irreconcilable
             Audrey Tang
ℙ
Practical
∀
Abstractions
  ➥ Sexy
Closures
sub make_counter {
    my $start = shift;
    return sub { ++$start };
}

my $from_ten = make_counter(10);
my $from_three = make_counter(3);

print $from_three->(); # 4
print $from_three->(); # 5
print $from_ten->();   # 11
Staged Evaluation
BEGIN {
    print "Compile-time";
    eval $generated_code;
    print "Still in compiler";
}
print "Normal runtime";
eval $more_generated_code;
Runtime Typecasting

my $piece = Pawn->new;
bless $piece, Queen;
S
Shorthands
 ➥ Natural
Contexts
# Scalar vs. List context
my $one = <STDIN>; # Read one line
my @all = <STDIN>; # Read all lines

# String vs. Numeric context
print "Lines: @all" if @all < 10;
Tied Variables

tie my %search => 'Tie::Google';
print $search{'Perl Pugs'}[0]{URL};
# http://www.pugscode.org/
Regular Expresisons
# DeCSS
s''$/=2048;while(<>){G=29;R=142;if((@a=unqT="C*",_)[20]&48){D=89;_=unqb24,qT,@
b=map{ord qB8,unqb8,qT,_^$a[--D]}@INC;s/...$/1$&/;Q=unqV,qb25,_;H=73;O=$b[4]<<9
|256|$b[3];Q=Q>>8^(P=(E=255)&(Q>>12^Q>>4^Q/8^Q))<<17,O=O>>8^(E&(F=(S=O>>14&7^O)
^S*8^S<<6))<<9,_=(map{U=_%16orE^=R^=110&(S=(unqT,"xbntdxbzx14d")[_/16%8]);E
^=(72,@z=(64,72,G^=12*(U-2?0:S&17)),H^=_%64?12:0,@z)[_%8]}(16..271))[_]^((D>>=8
)+=P+(~F&E))for@a[128..$#a]}print+qT,@a}';s/[D-HO-U_]/$$&/g;s/q/pack+/g;eval
Best coding
➥ No coding
CPAN
CPAN

11 years
CPAN

11 years
5500+ authors
CPAN

11 years
5500+ authors
11000+ modules
Services
Services
Package Management
Services
Package Management
Rating & Discussion
Services
Package Management
Rating & Discussion
Smoke Testing
Services
Package Management
Rating & Discussion
Smoke Testing
Issue Tracking
Vocabulary
 ≩ Syntax
“The Best thing
happened to Perl”
But...
Perl 5
is not the best thing
      for CPAN
☣
Syntax
Redundancy
    ☣
•   use v5;
•   use v5;
•   sub render {
•   use v5;
•   sub render {
•       my $self = shift;
•   use v5;
•   sub render {
•       my $self = shift;
•       my %opts = (x => 1, y => 1, z => 0, %{$_[0]});
•   use v5;
•   sub render {
•       my $self = shift;
•       my %opts = (x => 1, y => 1, z => 0, %{$_[0]});
•       for my $item ( $self->filter(@{ $self->{items} }) ) {
•   use v5;
•   sub render {
•       my $self = shift;
•       my %opts = (x => 1, y => 1, z => 0, %{$_[0]});
•       for my $item ( $self->filter(@{ $self->{items} }) ) {
•           print $item->draw({
                x => $opts{x},
                y => $opts{y},
                z => $opts{z},
            }), "n";
•   use v5;
•   sub render {
•       my $self = shift;
•       my %opts = (x => 1, y => 1, z => 0, %{$_[0]});
•       for my $item ( $self->filter(@{ $self->{items} }) ) {
•           print $item->draw({
                x => $opts{x},
                y => $opts{y},
                z => $opts{z},
            }), "n";
•       }
    }
• use   v6-alpha;
• use v6-alpha;
• method render   ($x = 1, $y = 1, $z = 0) {
• use v6-alpha;
• method render ($x = 1, $y   = 1, $z = 0) {
• for @.filter(@.items)       {
• use v6-alpha;
• method render ($x = 1, $y =   1, $z = 0) {
• for @.filter(@.items) {
•         say .draw(:$x, :$y,   :$z);
      }
  }
Jenga
Internals
   ☣
Bug-for-bug
compatibility
     ☣
Best Practice
takes discipline
Best Practice
should be Natural!
2000
RFCs
2001
Parrot
2002
Apocalypses
2003
          Ponie
(late, as in the late Arthur Dent)
2004
Synopses
2005
Pugs
2006
v6-alpha
Reconcile the Irreconcilable
Static Typing
      vs
Dynamic Typing
Types
  ☺
Typing
  ☹
Static
(C++, OCaml...)
Static
(C++, OCaml...)


 Efficient
Static
(C++, OCaml...)


 Efficient
 Robust
Static            Dynamic
(C++, OCaml...)   (Python, Ruby, ...)


 Efficient
 Robust
Static            Dynamic
(C++, OCaml...)   (Python, Ruby, ...)


 Efficient         Productive
 Robust
Static            Dynamic
(C++, OCaml...)   (Python, Ruby, ...)


 Efficient         Productive
 Robust            Flexible
Gradual Typing
 with Annotations
 and Type Inference
• use v5;
• sub f {
• sqrt($_[0]**2 + $_[1]**2);
•}
• my $five = f( 3, 4 );
• use v6-alpha;
• sub f {
• sqrt(@_[0]**2 + @_[1]**2);
•}
• my $five = f( 3, 4 );
•sub f (Num $x,   Num $y) {
• sqrt($x**2      + $y**2);
•}
•my Num $five =   f( 3, 4 );
• subset   Positive of Num where { $_ > 0 }
• subset Positive   of Num where { $_ > 0 }

• sub f (
        Positive $x, Positive $y
        --> Positive where { $_ > ($x & $y) }
  ) {
• subset Positive    of Num where { $_ > 0 }

• sub f (
          Positive $x, Positive $y
          --> Positive where { $_ > ($x & $y) }
    ) {
•         sqrt($x ** 2 + $y ** 2);
    }
• subset Positive   of Num where { $_ > 0 }

• sub f (
        Positive $x, Positive $y
        --> Positive where { $_ > ($x & $y) }
  ) {
•       sqrt($x ** 2 + $y ** 2);
  }
•
  my $five := f(3, 4); # inferred as Positive
Domain Specific
      vs
General Purpose
DSL
(SQL, Regex, ...)
DSL
(SQL, Regex, ...)


 Concise
DSL
(SQL, Regex, ...)


 Concise
 Expressive
DSL               GPL
(SQL, Regex, ...)   (Lisp, C, ...)


 Concise
 Expressive
DSL                GPL
(SQL, Regex, ...)    (Lisp, C, ...)


 Concise            Versatile
 Expressive
DSL                GPL
(SQL, Regex, ...)    (Lisp, C, ...)


 Concise            Versatile
 Expressive         Reusable
Extensible
Compilation
Macros
Macros

Compile-time evaluation
Macros

Compile-time evaluation
All parts are swappable
Macros

Compile-time evaluation
All parts are swappable
Even the lexer!
• macro circumfix:</* */> ($x)
• is parsed /.*?/
• { '' }
•
• /* This is a C-style comment   */
•
• sub   postfix:<!> ($x) {
•       [*] 1..$x
•}
•
• say   10!; # 3628800
• macro GREETING () {
• # A late-bound macro
• q:code(:COMPILING){ "Hello,    $s" };
•}
• my $s = "world";
• say GREETING; # Hello, world
Lazy Evaluation
       vs
Eager Evaluation
Lazy
(Haskell, Unix pipes)
Lazy
(Haskell, Unix pipes)


    Modular
Lazy
(Haskell, Unix pipes)


    Modular
    Reasonable
Lazy                Eager
(Haskell, Unix pipes)   (everybody else)


    Modular
    Reasonable
Lazy                Eager
(Haskell, Unix pipes)   (everybody else)


    Modular             Direct
    Reasonable
Lazy                Eager
(Haskell, Unix pipes)   (everybody else)


    Modular             Direct
    Reasonable          Predictable
Return-type Polymorphism
 with Laziness Annotations
•# "cat"
 for =<> { .say }
•# "cat"
 for =<> { .say }

•# "cat", together with line numbers
 for each(1..*; =<>) {
     say "Line $^num: $^text";
 }
•#   Lists are lazy by default
• # Lists   are lazy by default
• my @fib   := (
• # Lists are lazy   by default
• my @fib := (
• 0, 1,
• # Lists are lazy by default
• my @fib := (
• 0, 1,
• each(@fib; @fib[1..*]).map(&infix:<+>)
  );
• # Lists are lazy by default
• my @fib := (
• 0, 1,
• each(@fib; @fib[1..*]).map(&infix:<+>)
  );
•
  say "The first ten numbers are: @fib[^10]";
•#   Items are eager values. However...
• # Items are   eager values. However...
• my $ignored   = lazy { 10 ** (10 * 10) };
• # Items are eager values. However...
• my $ignored = lazy { 10 ** (10 * 10) };
• my $unused = lazy { say 1..$ignored };
• # Items are eager values. However...
• my $ignored = lazy { 10 ** (10 * 10) };
• my $unused = lazy { say 1..$ignored };
• say "Hello, world!";
Classes
    vs
Prototypes
Classes
(Java, Smalltalk, ...)
Classes
(Java, Smalltalk, ...)


  Typeful
Classes
(Java, Smalltalk, ...)


  Typeful
  Disciplined
Classes                 Prototypes
(Java, Smalltalk, ...)    (JavaScript, Lua, ...)


  Typeful
  Disciplined
Classes                 Prototypes
(Java, Smalltalk, ...)    (JavaScript, Lua, ...)


  Typeful                   Adaptive
  Disciplined
Classes                 Prototypes
(Java, Smalltalk, ...)    (JavaScript, Lua, ...)


  Typeful                   Adaptive
  Disciplined               Convenient
Meta-Object
 Protocol
• class   Dog is Mammal does Companion {
• class   Dog is Mammal does Companion {
•
      my $.count where 0..100;
• class Dog is Mammal does Companion   {
•
      my $.count where 0..100;
•
      has $!brain;
• class Dog is Mammal does Companion   {
•
      my $.count where 0..100;
•
      has $!brain;

•     has &.vocalize = &say;
      has $.name is rw = "Fido";
• class Dog is Mammal does Companion   {
•
      my $.count where 0..100;
•
      has $!brain;

•     has &.vocalize = &say;
      has $.name is rw = "Fido";

•     has $.fur handles Groomable;
      has $.tail handles <wag hang>;
• class Dog is Mammal does Companion     {
•
      my $.count where 0..100;
•
        has $!brain;

•       has &.vocalize = &say;
        has $.name is rw = "Fido";

•       has $.fur handles Groomable;
        has $.tail handles <wag hang>;
•
        method companion handles s/^owner_// { ... }
    }
• my   Dog $fido .= new;
• my   Dog $fido .= new;
•
  $fido.HOW;    # the meta object for Dog
• my Dog $fido   .= new;
•
  $fido.HOW;     # the meta object for Dog
• $fido.WHAT;    # the Dog prototype object
• my Dog $fido   .= new;
•
  $fido.HOW;     # the meta object for Dog
• $fido.WHAT;    # the Dog prototype object
• $fido.WHICH;   # $fido’s Object ID
• my Dog $fido .= new;
•
  $fido.HOW;   # the meta object for Dog
• $fido.WHAT; # the Dog prototype object
• $fido.WHICH; # $fido’s Object ID
• Dog.isa(Dog); $fido.isa(Dog);
• $fido.HOW.add_method(
       'bark',
       method () { $.vocalize('Woof!') }
  );
• $fido.HOW.add_method(
       'bark',
       method () { $.vocalize('Woof!') }
  );

• Dog.can('bark');   $fido.can('bark');
Threads
   vs
Processes
Threads
(Implicit sharing)
Threads
(Implicit sharing)


Intuitive
Threads
(Implicit sharing)


Intuitive
Parallelizable
Threads              Processes
(Implicit sharing)    (Explicit sharing)


Intuitive
Parallelizable
Threads              Processes
(Implicit sharing)    (Explicit sharing)


Intuitive             Deterministic
Parallelizable
Threads              Processes
(Implicit sharing)    (Explicit sharing)


Intuitive             Deterministic
Parallelizable        Manageable
Concurrency
  ☺☺☺
Locking
☹☹☹
•
async {
   $x.withdraw(3);

    $y.deposit(3);
}
•
async {
   $x.withdraw(3);
    ☣ Race Condition ☣
    $y.deposit(3);
}
• async {
      $x.lock;
      $y.lock;
• async   {
        $x.lock;
        $y.lock;
•       $x.withdraw(3);
        $y.deposit(3);
    }
• async   {               • async {
        $x.lock;                $y.lock;
        $y.lock;                $x.lock;
•       $x.withdraw(3);     }
        $y.deposit(3);
    }
☣ Deadlock ☣

• async   {               • async {
        $x.lock;                $y.lock;
        $y.lock;                $x.lock;
•       $x.withdraw(3);     }
        $y.deposit(3);
    }
Software
Transactional
  Memory
•   async {
•     contend {
        # begin transaction
•       $x.withdraw(3);
        $y.deposit(3);
•      } # commit or rollback
•   }
•# Retry with "defer"
 method withdraw ($n) {
    defer if $.balance < $n;
    $.balance -= $n;
 }
•#    Retry with "defer"
    method withdraw ($n) {
       defer if $.balance < $n;
       $.balance -= $n;
    }
•
    # Choice with "maybe"
    sub transfer ($x1, $x2, $y) {
       maybe { $x1.withdraw(3) }
       maybe { $x2.withdraw(3) }
       $y.deposit(3);
    }
•#    Retry with "defer"
    method withdraw ($n) {
       defer if $.balance < $n;
       $.balance -= $n;
    }
•
    # Choice with "maybe"
    sub transfer ($x1, $x2, $y) {
       maybe { $x1.withdraw(3) }
       maybe { $x2.withdraw(3) }
       $y.deposit(3);
    }
•
    # Composable with nested "maybe"
    contend {
       maybe { transfer($x1, $x2, $y) }
       maybe { transfer($x3, $x4, $y) }
    }
SIMD
 vs
MIMD
SIMD
(APL, Fortran)
SIMD
(APL, Fortran)


Simple
SIMD
(APL, Fortran)


Simple
Scalable
SIMD             MIMD
(APL, Fortran)   (everybody else)


Simple
Scalable
SIMD             MIMD
(APL, Fortran)   (everybody else)


Simple           Richer types
Scalable
SIMD             MIMD
(APL, Fortran)   (everybody else)


Simple           Richer types
Scalable         Familiar flow
•# Hyper Operator (SSE/GPU friendly)
 [1, 1, 2, 3, 5] »+« [1, 2, 3, 5, 8];
• # Hyper Operator (SSE/GPU friendly)
  [1, 1, 2, 3, 5] »+« [1, 2, 3, 5, 8];
• # === [2, 3, 5, 8, 13]
•# Recursive Visits
 -« [[1, 2], 3];
• # Recursive Visits
  -« [[1, 2], 3];
• # === [[-1, -2], -3]
•# Hyper Methods
 [1, 4, 9, 16]».sqrt;
•# Hyper Methods
 [1, 4, 9, 16]».sqrt;
•# === [1, 2, 3, 4]
•   % time        pugs -e '(1..100000)>>.sqrt'
    real 9.387s
    user 9.219s
•   % time               pugs -e '(1..100000)>>.sqrt'
    real 9.387s
    user 9.219s
•
    % time env GHCRTS=-N2 pugs -e '(1..100000)>>.sqrt'
    real 5.807s
    user 6.959s
•# Junctions
 sub is_prime (Int $n --> Bool) {
    $n % all(2 .. $n.sqrt+1);
 }
•#    Junctions
    sub is_prime (Int $n --> Bool) {
       $n % all(2 .. $n.sqrt+1);
    }
•
    sub has_twin_prime (Int $n --> Bool) {
       is_prime($n & ($n ± 2));
    }
•#    Junctions
    sub is_prime (Int $n --> Bool) {
       $n % all(2 .. $n.sqrt+1);
    }
•
    sub has_twin_prime (Int $n --> Bool) {
       is_prime($n & ($n ± 2));
    }
•
    sub infix:<±> ($x, $y) {
       ($x + $y) | ($x - $y);
    }
•#    Junctions
    sub is_prime (Int $n --> Bool) {
       $n % all(2 .. $n.sqrt+1);
    }
•
    sub has_twin_prime (Int $n --> Bool) {
       is_prime($n & ($n ± 2));
    }
•
    sub infix:<±> ($x, $y) {
       ($x + $y) | ($x - $y);
    }
•
My Language
     vs
Your Language
Perl 6
Perl 6
 Better
Perl 6
 Better
 Better
Perl 6    Others
 Better
 Better
Perl 6    Others
 Better    Better
 Better
Perl 6    Others
 Better    Better
 Better    Better
•use   jsan:DOM;
•use   perl5:DBI;
•use   haskell:Numeric;
•use   your_language:FavouriteModule;
JVM?                                         YARV?

                       Pugs

       CLR?                               PyPy?




              Java
                       Haskell   Perl 5
              Script
✈
When will
Perl 6 be released?
By Christmas!
When Perl 6 arrives,
every day will be like
    Christmas!
        ❆
Thank you!
   ☺

More Related Content

What's hot

parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorial
tutorialsruby
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platform
deimos
 

What's hot (20)

parenscript-tutorial
parenscript-tutorialparenscript-tutorial
parenscript-tutorial
 
Modern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real WorldModern Black Mages Fighting in the Real World
Modern Black Mages Fighting in the Real World
 
Linux Binary Exploitation - Return-oritend Programing
Linux Binary Exploitation - Return-oritend ProgramingLinux Binary Exploitation - Return-oritend Programing
Linux Binary Exploitation - Return-oritend Programing
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
Debugging Python with gdb
Debugging Python with gdbDebugging Python with gdb
Debugging Python with gdb
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl ProgrammerModern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
 
Zend expressive workshop
Zend expressive workshopZend expressive workshop
Zend expressive workshop
 
Deploying Perl apps on dotCloud
Deploying Perl apps on dotCloudDeploying Perl apps on dotCloud
Deploying Perl apps on dotCloud
 
PGroonga – Make PostgreSQL fast full text search platform for all languages!
PGroonga – Make PostgreSQL fast full text search platform for all languages!PGroonga – Make PostgreSQL fast full text search platform for all languages!
PGroonga – Make PostgreSQL fast full text search platform for all languages!
 
Getting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::CGetting started with Perl XS and Inline::C
Getting started with Perl XS and Inline::C
 
SIP Tutorial/Workshop 3
SIP Tutorial/Workshop 3SIP Tutorial/Workshop 3
SIP Tutorial/Workshop 3
 
CRUFT! - Peter Kriens, President, aQute
CRUFT! - Peter Kriens, President, aQuteCRUFT! - Peter Kriens, President, aQute
CRUFT! - Peter Kriens, President, aQute
 
upload test 1
upload test 1upload test 1
upload test 1
 
Sharing (or stealing) the jewels of python with big data &amp; the jvm (1)
Sharing (or stealing) the jewels of python with big data &amp; the jvm (1)Sharing (or stealing) the jewels of python with big data &amp; the jvm (1)
Sharing (or stealing) the jewels of python with big data &amp; the jvm (1)
 
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
 
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
Kicking off with Zend Expressive and Doctrine ORM (ZendCon 2016)
 
PSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressivePSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend Expressive
 
Ola Bini Evolving The Java Platform
Ola Bini Evolving The Java PlatformOla Bini Evolving The Java Platform
Ola Bini Evolving The Java Platform
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18
 
Tail Call Elimination in Open Smalltalk
Tail Call Elimination in Open SmalltalkTail Call Elimination in Open Smalltalk
Tail Call Elimination in Open Smalltalk
 

Similar to Pugs: A Perl 6 Implementation

これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
goccy
 

Similar to Pugs: A Perl 6 Implementation (20)

YASPS OPENNING
YASPS OPENNINGYASPS OPENNING
YASPS OPENNING
 
21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci21st Century CPAN Testing: CPANci
21st Century CPAN Testing: CPANci
 
Enterprise Perl
Enterprise PerlEnterprise Perl
Enterprise Perl
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 
Perl6 meets JVM
Perl6 meets JVMPerl6 meets JVM
Perl6 meets JVM
 
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
 
How CPAN Testers helped me improve my module
How CPAN Testers helped me improve my moduleHow CPAN Testers helped me improve my module
How CPAN Testers helped me improve my module
 
perl
perlperl
perl
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
Perl 5.16 and beyond
Perl 5.16 and beyondPerl 5.16 and beyond
Perl 5.16 and beyond
 
Publishing a Perl6 Module
Publishing a Perl6 ModulePublishing a Perl6 Module
Publishing a Perl6 Module
 
CPAN 模組二三事
CPAN 模組二三事CPAN 模組二三事
CPAN 模組二三事
 
Better detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codeBetter detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 code
 
Le PERL est mort
Le PERL est mortLe PERL est mort
Le PERL est mort
 
Introduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlIntroduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable Perl
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic  Perl ProgrammerModern Perl for the Unfrozen Paleolithic  Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
 
DevOps in PHP environment
DevOps in PHP environmentDevOps in PHP environment
DevOps in PHP environment
 
Perl family: 15 years of Perl 6 and Perl 5
Perl family: 15 years of Perl 6 and Perl 5Perl family: 15 years of Perl 6 and Perl 5
Perl family: 15 years of Perl 6 and Perl 5
 
Erlang sucks. EUC 2012
Erlang sucks. EUC 2012Erlang sucks. EUC 2012
Erlang sucks. EUC 2012
 

More from Audrey Tang

TEDxTaipei 2017: 社會企業
TEDxTaipei 2017: 社會企業TEDxTaipei 2017: 社會企業
TEDxTaipei 2017: 社會企業
Audrey Tang
 
唐鳳政務委員業務工作報告
唐鳳政務委員業務工作報告唐鳳政務委員業務工作報告
唐鳳政務委員業務工作報告
Audrey Tang
 
共通性應用程式介面規範
共通性應用程式介面規範共通性應用程式介面規範
共通性應用程式介面規範
Audrey Tang
 

More from Audrey Tang (20)

Social Innovation & Digital Transformation
Social Innovation & Digital TransformationSocial Innovation & Digital Transformation
Social Innovation & Digital Transformation
 
Stories from the Future of Democracy
Stories from the Future of DemocracyStories from the Future of Democracy
Stories from the Future of Democracy
 
TEDxTaipei 2017: 社會企業
TEDxTaipei 2017: 社會企業TEDxTaipei 2017: 社會企業
TEDxTaipei 2017: 社會企業
 
唐鳳政務委員業務工作報告
唐鳳政務委員業務工作報告唐鳳政務委員業務工作報告
唐鳳政務委員業務工作報告
 
資訊服務採購契約範本 修正明細對照 1060713
資訊服務採購契約範本 修正明細對照 1060713資訊服務採購契約範本 修正明細對照 1060713
資訊服務採購契約範本 修正明細對照 1060713
 
服務型智慧政府推動計畫 v9
服務型智慧政府推動計畫 v9服務型智慧政府推動計畫 v9
服務型智慧政府推動計畫 v9
 
共通性應用程式介面規範
共通性應用程式介面規範共通性應用程式介面規範
共通性應用程式介面規範
 
打造一站式的防救災資訊整合平臺
打造一站式的防救災資訊整合平臺打造一站式的防救災資訊整合平臺
打造一站式的防救災資訊整合平臺
 
開放政府聯絡人第11次協作會議簡報
開放政府聯絡人第11次協作會議簡報開放政府聯絡人第11次協作會議簡報
開放政府聯絡人第11次協作會議簡報
 
第7次協作會議會後會簡報v6.0
第7次協作會議會後會簡報v6.0第7次協作會議會後會簡報v6.0
第7次協作會議會後會簡報v6.0
 
臨時動議:社會企業連繫會議分組
臨時動議:社會企業連繫會議分組臨時動議:社會企業連繫會議分組
臨時動議:社會企業連繫會議分組
 
議程及歷次列管表
議程及歷次列管表議程及歷次列管表
議程及歷次列管表
 
討論案一:中、南、東部在地社企會談規劃情形
討論案一:中、南、東部在地社企會談規劃情形討論案一:中、南、東部在地社企會談規劃情形
討論案一:中、南、東部在地社企會談規劃情形
 
報告案四之一:創櫃板協助社會企業籌資之推動現況
報告案四之一:創櫃板協助社會企業籌資之推動現況報告案四之一:創櫃板協助社會企業籌資之推動現況
報告案四之一:創櫃板協助社會企業籌資之推動現況
 
報告案四之二:國發基金運用資金協助社會發展辦理方式
報告案四之二:國發基金運用資金協助社會發展辦理方式報告案四之二:國發基金運用資金協助社會發展辦理方式
報告案四之二:國發基金運用資金協助社會發展辦理方式
 
報告案二:組團參加2017年社會企業世界論壇辦理進度報告
報告案二:組團參加2017年社會企業世界論壇辦理進度報告報告案二:組團參加2017年社會企業世界論壇辦理進度報告
報告案二:組團參加2017年社會企業世界論壇辦理進度報告
 
報告案三 :SEWF申辦2019進度說明
報告案三 :SEWF申辦2019進度說明報告案三 :SEWF申辦2019進度說明
報告案三 :SEWF申辦2019進度說明
 
2017-06-17 臺灣網路治理論壇
2017-06-17 臺灣網路治理論壇2017-06-17 臺灣網路治理論壇
2017-06-17 臺灣網路治理論壇
 
行政院數位國家創新經濟推動小組設置要點
行政院數位國家創新經濟推動小組設置要點行政院數位國家創新經濟推動小組設置要點
行政院數位國家創新經濟推動小組設置要點
 
DIGI⁺ 數位政府
DIGI⁺ 數位政府DIGI⁺ 數位政府
DIGI⁺ 數位政府
 

Recently uploaded

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
panagenda
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Pugs: A Perl 6 Implementation