This talk is about
Perl 6 is the next version of the Perl programming language.
The internals of the version 5 interpreter are so tangled that they hinder maintenance, thwart some new feature efforts, and scare off potential internals hackers.
The language as of version 5 has some misfeatures that are a hassle to ongoing maintenance of the interpreter and of programs written in Perl.
The Perl 6 design process is about keeping what works in Perl 5, fixing what doesn't, and adding what's missing.
The vision for Perl 6 is more than simply a rewrite of Perl 5. By separating the parsing from the compilation and the runtime, we're opening the doors for multiple languages to cooperate.
You'll be able to write your program in Perl 6, Perl 5, TCL, Python, or any other language that there's a parser written for.
Interchangable runtime engines let you interpret your bytecode or convert it to something else.
Perl 5 was my rewrite of Perl. I want Perl 6 to be the community's rewrite of Perl and of the community.
In the beginning, there were RFCs.
The initial design phase of perl6 was to produce suggestions for Larry to evaluate.
Every idea that someone wants in Perl should have had an RFC produced for it.
The community brainstorming process finished
August 1, 2000,
resulting in 361 RFCs.
If you ask for RFCs from the general public, you get a lot of interesting but contradictory ideas, because people tend to stake out polar positions, and none of the ideas can build on each other.
Apocalypses are initial design document written over time by Larry. Nowadays they are largely replaced with Synopses.
Exegeses were written by Damian Conway and were explaining Apocalypses in more detail and with more examples. Nowadays they are also largely replaced with Synopses.
Synopses are short, up to the point Perl6 design documents. They are kept current, so if an Apocalypse or an Exegesis disagrees with a Synopsis, the Synopsis wins.
Perl6 is supposed to be good for
Perl6 will be able to execute Perl5
code. In fact, the interpreter will
assume that it is being fed Perl 5
code unless specified otherwise.
This gives us the access to the wealth of CPAN.
10+ years
2800+ authors
10000+ modules
Perl5's $o->method
becomes $o.method
Since "." is occupied, "~" becomes string concatenation operator.
Perl5's $d = $a ? $b : $c
becomes
$d = $a ?? $b :: $c
Which frees up "?" and ":".
Larry's First Law of
Everyone wants the colon.
If you want to treat everything as
Perl6-Attributes Perl6-Bible Perl6-Binding Perl6-Builtins Perl6-Classes Perl6-Contexts Perl6-Currying Perl6-Export Perl6-Export-Attrs Perl6-Form Perl6-Gather Perl6-Interpolators Perl6-Junction Perl6-Parameters Perl6-Placeholders Perl6-Roles Perl6-Rules Perl6-Say Perl6-Slurp Perl6-Subs Perl6-Tokener Perl6-Variables
Parrot is a virtual machine designed to
Amber for parrot BASIC/compiler
Degree of completeness vary. To say the least.
Parrot has several different
"runcores",
including JIT
for some platforms.
Some of the runcores are fast.
The results of those benchmarks should
But there is a hope for Parrot.
Started in February 2005.
GHC is a state-of-the-art compiler and interactive environment, available under a BSD-style license. Itself written in Haskell, GHC can compile Haskell to bytecode, C code, and machine code on some platforms.
However, the Pugs evaluator is currently
not optimized at all: dispatching is around
1000 operators per second on a typical PC, which is nearly 100 times
slower than Perl 5. Still, it is fast enough for prototyping language features.
Anarchistic development model
~9000 commits
120+ committers
use perl5:DBI;
use jsan:DOM;
say "Hello, world".reverse;
say 3.as("%03d");
say <a b c>.elems;
$len = scalar(@a);
$str = "@a";
Perl6:
$len = +@a;
$str = ~@a;
>> and << are used to denote "list operations", which operate on each element of two lists (or arrays) and return a list (or array) of the results.
(1,1,2,3,5) >>+<< (1,2,3,5,8); # (2,3,5,8,13)
Also unary:
@negatives = -<< @positives;
Any binary operator can be surrounded by square brackets to create a list operator that reduces using that operation:
[+] 1, 2, 3; # 1 + 2 + 3 = 6
~~ replaces =~, but is much more general. A few examples:
$s ~~ /re/ just like Perl5's $s =~ /re/
%h1 ~~ %h2 match if %h1.keys.sort eq %h2.keys.sort
%h ~~ @a match if %h{any(@a)}
@a ~~ "str" match if any(@a) eq "str";
given EXPR {
when EXPR { ... }
when EXPR { ... }
default { ... }
}
"given" is just one of the ways to set topic ($_).
Exceptions are ignored:
try {
...
}
Exceptions are handled by CATCH:
try {
...
CATCH {
when ... {...}
...
}
}
{
...
CATCH {
when ... {...}
...
}
}
The following elements are the same
if / <ident> = <ident> / {
$left_side = $<ident>[0];
$right_side = $<ident>[1];
}
This allows one to write things like:
my $a = 4;
if $a < 3|4|5 { say "less" }
if $a > 3|4|5 { say "greater" }
Junctions thread through operations,
(1|2|3) + 4; # 5|6|7
(1|2) + (3&4); # (4|5) & (5|6)
One can now write:
if $x1 <= $x <= $x2 { say "in range" }
Perl5:
$x = "Hello";
*y = *x;
$y = "Bye!";
print "$x\n";
Perl6:
our $x = "Hello";
our $y := $x;
$y = "Bye!";
say $x;
Proper parameter lists:
sub fact ($n)
{
return 1 if $n < 2;
return $n*fact($n - 1);
}
say fact(5);
Also named:
sub my_substr ($str, $from?, $len?)
{
substr($str, $from||0, $len||Inf)
}
say my_substr("hello", len => 4);
Also with default values:
sub my_substr ($str, $from = 0, $len = Inf)
{
substr($str, $from, $len)
}
say my_substr("hello", from => 2);
Almost a synonym for the anonymous sub
$sq = -> $val { $val**2 };
# Same as: $sq = sub ($val) { $val**2 };
for @list -> $elem {
print "$elem\n";
}
# Same as: for @list, sub ($elem) {
# print "$elem\n";
# }
But behaves like a block:
for @list -> $elem {
print "$elem\n";
return if $elem ~~ /done/;
}
# for @list, sub ($elem) {
# print "$elem\n";
# return if $elem ~~ /done/; # OOPS
# }
for zip(@names; @codes) -> [$name, $zip]
{
print "Name: $name; Zip code: $zip\n";
}
for each(@names; @codes) -> $name, $zip
{
print "Name: $name; Zip code: $zip\n";
}
$func = sub ($a, $b) { print if $a eq $b };
A "pointy" sub:
$func = -> $a, $b { print if $a eq $b };
Placeholder arguments:
$func = { print if $^a eq $^b }
Sorted!
grep { $_ % 2 } @data;
grep { $_ % 2 } <== @data;
@data ==> grep { $_ % 2 };
@oddsquares = map { $_**2 },
sort grep { $_ % 2 }, @nums;
# more clearly written as...
@oddsquares = map { $_**2 } <==
sort <==
grep { $_ % 2 } <== @nums;
@oddsquares = (@nums ==> grep { $_ % 2 } ==>
sort ==> map { $_**2 });
# push semantics
my @foo;
0..2 ==> @foo;
'a'..'c' ==> @foo;
say @foo; # 0,1,2,'a','b','c'
Every class object has a .meta
http://dev.perl.org/
Thank you!