0% found this document useful (0 votes)
33 views52 pages

It Was Finally Christmas: Perl 6 Is Here!: Wim Vanderbauwhede School of Compu6ng Science University of Glasgow

The document discusses the history and features of the Perl 6 programming language. It describes how Perl 6 was promised for Christmas in 2007 but faced delays, and provides timelines of its development. It also discusses the compiler, virtual machine, grammars, objects with roles and gradual typing, functional features, concurrency tools and more.

Uploaded by

hoang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views52 pages

It Was Finally Christmas: Perl 6 Is Here!: Wim Vanderbauwhede School of Compu6ng Science University of Glasgow

The document discusses the history and features of the Perl 6 programming language. It describes how Perl 6 was promised for Christmas in 2007 but faced delays, and provides timelines of its development. It also discusses the compiler, virtual machine, grammars, objects with roles and gradual typing, functional features, concurrency tools and more.

Uploaded by

hoang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 52

It

was finally Christmas:


Perl 6 is here!
Wim Vanderbauwhede
School of Compu6ng Science
University of Glasgow
“Language is
ideology”

Kress, Gunther, et al. "Language as ideology." (1982).


A trip down memory lane
2007
•  Perl6/Pugs invited talk at POPL 2007
•  Audrey Tang had created Pugs, a Perl 6
implementa6on in Haskell
•  Perl 6 was promised for "Christmas”
•  And there was some delay …
Perl 6meline

Dow Jones index, 1985-2015


Context

hZp://www.codeeval.com/
Context
Popularity of programming languages – TIOBE

TIOBE Index for February 2016, hZp://www.6obe.com/


Context
Popularity of programming languages – TIOBE

TIOBE Index for February 2016, hZp://www.6obe.com/


Perl

Neil Stephenson, “Cryptonomicon”, p480


Perl 5
•  Interpreted
•  Dynamically typed
•  Garbage collec6on
•  In that sense very similar to JavaScript,
Python, Ruby, …
Perl 5
•  Uses funny characters for typing:
$: scalar
@: array (list)
%: hash (dic6onary, map)
&: subrou6ne
•  Incorporates a separate language:
regular expressions (PCRE)
Perl 5
•  But also:
•  Lexical scoping
•  Higher-order func6ons
•  Anonymous func6ons
•  Closures
Perl 6
•  Is a new language, not backward
compa6ble with Perl 5.
•  S6ll mostly Perl
•  But a modern language
Compiler and VM
Compiler (Rakudo)

hZps://github.com/rakudo/rakudo
VM (MoarVM)
•  Meta-object protocol based
•  Precise, genera6onal, and parallel GC
•  First-class code objects, closures, …
•  Excep6ons
•  Con6nua6ons
•  Threads, mutexes, …
•  JIT compila6on
hZps://github.com/MoarVM/MoarVM
Grammars
Parsing
•  Perl 6 has Grammars, Rules, Tokens and Regexes as
part of the language
•  Similar to classes but used to organize parsers
•  Rules are lexeme parsers
•  Tokens are token parsers
•  Regexes are PCREs
•  Perl 6 is parsed and executed using a Perl 6-style
grammar.
Objects
Objects
JavaScript Python
Perl 6 Objects
Perl 6 Objects
Roles
Perl 6 Objects
•  Accessors for free
•  Default constructor
•  Inheritance
•  Roles (mixins)
•  Built on a Meta Object Protocol
•  Full introspec6on
•  So s6ll nothing special …
But wait …
Perl 6 Objects
Perl 6 Objects
Gradual typing!
Gradual typing
•  By default variables are dynamically typed.
•  Explicitly typed variables are sta6cally typed.
•  But type checks can be deferred to run 6me.
•  Underlying theory:
hZps://github.com/samth/gradual-typing-bib
Gradual typing: subsets
•  Type constraint checked at run 6me

Gradual typing: type capture
•  Defer the specifica6on of a type constraint to the
6me the func6on is called.
•  Allows to refer to a type both in the signature and
the func6on body.
Gradual typing: type capture
•  Defer the specifica6on of a type constraint to the
6me the func6on is called.
•  Allows to refer to a type both in the signature and
the func6on body.
Roles
Roles
•  Basis for the Perl 6 type system
•  Used for composi6on and mixins
•  In Perl 6, the “funny characters” are syntax for a set
of predefined roles:
@: Posi6onal (array)
%: Associa6ve (hash)
&: Callable (subrou6ne)
•  So …


No more funny characters!
•  Actually, the “funny characters” are now op6onal:

Polymorphic func6ons
•  Also known as mul6ple dispatch
Polymorphic func6ons
•  Also known as mul6ple dispatch
Polymorphic func6ons
•  Looks familiar?
Parametric roles
•  Roles that take one or more type variables
Possibly Maybe

FuncHonal
programming
Func6onal features
•  Higher-order func6ons
•  Anonymous func6ons (lambdas)
•  Currying
•  Immutable lists, lazy evalua6on
•  Tail call op6miza6on
•  Op6onal immutable variables
Type capture revisited
•  Type capture also works with closures and lambdas

Lazy lists
•  Perl 6 dis6nguishes between sequences, lists and
arrays.
•  Sequences are immutable, but are consumed
when iterated.
•  Lists are immutable
•  Arrays are mutable
•  By defaults Seq, List and Array are lazy, but can be
made eager.

Seq and List
Array
Promises
Concurrency
•  High-level
•  Promises (futures)
•  Channels
•  Supplies
•  Low-level
•  Threads
•  Schedulers
•  Locks
Promises
Conclusion
• 
Thank you!

You might also like