Upgrade to Pro — share decks privately, control downloads, hide ads and more …

DC-Baltimore Perl Workshop - Keynote

DC-Baltimore Perl Workshop - Keynote

This was a keynote given at the first DC-Baltimore Perl workshop. The topic was "Future Perl" and it laid out a number of features I would like to see come about in Perl (some of which actually have).

Stevan Little

April 14, 2012
Tweet

More Decks by Stevan Little

Other Decks in Programming

Transcript

  1. Future Perl Stevan Little DCBPW 2012 This talk will explore

    the recent comeback of Perl core development, review some of the mistakes made, and talk about how bright the future can be for Perl.
  2. The whole intent of Perl 5's module system was to

    encourage the growth of Perl culture rather than the Perl core. – Larry Wall Larry said this about Perl 5, sometimes around when he originally released it. The CPAN, and the community that created, is the embodiment of that idea. Recently (the former) Pumpking, Jesse Vincent, proposed that we actually take this idea one step further. He proposed that we actually start removing things from the Perl core and putting them into modules. While this might seem insane at first, there are a number of changes which have happened in the Perl core that actually make this idea quite sane.
  3. 2000 Perl 5.6 is released Jon Orwant smashed a cup

    and said "We're fucked!" ... a little while later, Perl 6 was announced. Perl 5.6 was 2 years in the making, but actually had a lot going on.
  4. 2000 Perl 5.6 is released Unicode Lexical warnings Weak references

    our variables 3-arg open 64-bit support Large file support
  5. 2000 Perl 5.6 is released Unicode Lexical warnings Weak references

    our variables 3-arg open 64-bit support Large file support lvalue subroutines Subroutine attributes Pseudo hash improvements
  6. 6 much of the Perl core work was focused on

    Perl 6 which was not showing any signs of release.
  7. Parrot too was in trouble. The Perl 6 language itself

    was still in flux. Meanwhile, other languages were on the rise, Ruby, Python, etc. The fun of a new toy was driving lots of work in them.
  8. 2005 Perl 6 spec tests Moose & Class::MOP Devel::Declare Pugs

    gave birth to a bunch of modules used today and inspired by perl 6
  9. 2005 Perl 6 spec tests Moose & Class::MOP Devel::Declare Module::Compile

    Data::Bind Moose::Autobox and more And a couple others which ended up not getting as much use, but still inspired work.
  10. Perl 5 was my rewrite of Perl. I want Perl

    6 to be the community's rewrite of Perl and of the community. – Larry Wall But Pugs did more then contribute code, here is a quote from larry when the Perl 6 project really got started. Pugs really got more people involved, it was a good thing.
  11. –Ofun And lastly, Pugs brought us the idea of Optimized

    for Fun. This is an important component of what it is to be perlish.
  12. 2007 Perl 5.10 is released Perl 5.10 clawed its way

    to the surface. It had been over 4 years since the last major release.
  13. 2007 Perl 5.10 is released feature pragma // (defined-or) named

    captures state variables say() mro pragma UNIVERSAL::DOES Bunch of okay features, some better then others
  14. 2007 Perl 5.10 is released feature pragma // (defined-or) named

    captures state variables say() mro pragma UNIVERSAL::DOES given/when smartmatch But also some which were not so successful. Taken from Perl 6 the given/when construct and smart matching was implemented, but the results were problematic. But then in 2009 ...
  15. 2009 A New (Hope) Pumpking Jesse Vincent stepped in to

    be Pumpking. Traditionally pumpkings were the developer/ releasemanager/etc/etc/etc, Jesse tried a different approach, being basically the project manager.
  16. 2010 Perl 5.12 is released And it worked, just 1

    year after taking over, he ushered perl 5.12 into existence
  17. 2010 strict is on by default ... (yadda-yadda-yadda) each,keys,values for

    ARRAYs Y2038 compliance delete local $hash{$entry} package NAME VERSION; overloading qr// Pluggable keywords when as statement modifier Perl 5.12 is released But it wasnt just about features, Jesse also instituted a regular release schedule so that ...
  18. 2011 strict is on by default ... (yadda-yadda-yadda) each,keys,values for

    ARRAYs Y2038 compliance delete local $hash{$entry} package NAME VERSION; overloading qr// Pluggable keywords when as statement modifier Perl 5.14 is released ARRAY and HASH built-ins on refs ${^GLOBAL_PHASE} package NAME VERSION {} Lots of internals work! Perl 5.12 is released in 2011 Perl 5.14 was released,
  19. Perl 5.16 and Beyond but perhaps jesse’s biggest contribution to

    Perl was actually a talk he gave last summer in which he laid out the future direction. See, ever since 2000 no one had really done this, Perl 5 was old, Perl 6 was new, that was the direction. But 11 years later, no Perl 6, so Perl 5 needed to be resuccitated.
  20. But then, this past winter Jesse retired as pumpking, and

    I think this is one of his next most important thing he did, he handed the reigns to RJBS, who then ...
  21. 2012 Perl 5.16 is released brought perl 5.16 into existence

    (well not yet, actually it wont be officially out until the 16th (5/16 to be exact))
  22. 2012 Perl 5.16 is released use 5.016; __SUB__ improved eval

    CORE::* references new OOP docs notice that the feature count is low, this is on purpose.
  23. 2012 Perl 5.16 is released use 5.016; __SUB__ improved eval

    CORE::* references new OOP docs Devel::CallParser smartmatch.pm p5-MOP List::Gather ... Additionally in the last few years some work outside the core has been going on. This is in keeping with Jesse’s idea that the core should be slimmer and we should put stuff into modules.
  24. 2012 Perl 5.16 is released use 5.016; before we go

    further, I want to discuss this one feature ...
  25. 2012 Perl 5.16 is released use 5.016; # only 5.16

    features enabled here use 5.014; # only 5.14 features enabled here (not 5.16) before we go further, I want to discuss this one feature ...
  26. So, this is present day, but this talk is called

    Future Perl, so lets take a trip. Disclaimer: nothing from here on out is sanctioned. When I floated some of this to RJBS, he said “sounds good, just get someone to implement them” :)
  27. Perl 5.18 is released 2013 use 5.018; try { ...

    SomeException->throw; } catch { when ( $_->isa(‘SomeException’) ) { warn “Got Some Exception: “ . $_->message; } default { die $_; } } Okay, so just a year ahead. Wouldn’t it be nice to have proper exceptions? This code is actually already possible using Try::Tiny and one of the many exception modules, but wouldn’t it be nice to have some level of standardization. Now I know this is Perl, so TIMTOWTDI, but that has a bad side too. Error handling is a mess in Perl, lets fix it.
  28. Perl 5.18 is released 2013 use 5.018; fun fib (

    $num ) { return 0 if $num == 1; return 1 if $num == 2; return fib( $num - 1 ) + fib( $num - 2 ); } fun ok ( $test, $message=’...’ ) { $test ? “ok $message” : “not ok $message” } fun log ( $level, ?$message ) { $message ? print( “[$level] : $message” ) : print( “[$level]” ); } What about function parameters? They don’t have to be fancy, they shouldn’t introduce types, there is (for now) no need for them to be introspectable either. Just simple parameters, that can be required, have a default, and be optional. I ran this by Jesse Luehrs and he said that doing this with Devel::CallParser “might actually just work”
  29. Perl 5.18 is released 2013 package Foo { use 5.018;

    sub bar { baz() } my sub baz { ... } } Foo::baz() # BOOM! And what about privacy. I know, again, this is perl, stay out cause I asked you, not cause I have a shotgun. But have you meet some of the people in the perl community (present company included).
  30. Perl 5.20 is released 2014 use 5.020; class Point {

    has $x = 0; has $y = 0; method clear { ($x, $y) = (0, 0) } } class Point3D (extends => Point) { has $z = 0; method clear { super(); $z = 0; } } So, just 2 years ahead now. This is actually my proposal, to add a new MOP based object system to perl. If you want to know more about this, come see me after the talk. And if you want to contribute, definitely come see me.
  31. Perl 5.20 is released 2014 use 5.020; foreach my $elem

    ($foo{bar}{baz}[2]->@) { ... } while ( my ($k, $v) = each $foo{bar}{baz}->% ) { .... } Now, this is something RJBS talked to me about and at first I was like WTF. Then I really gave it some thought and I was like “Hmmm”. This is the idea of a post-fix dereference operator, pretty fancy actually!
  32. Perl 5.22 is released 2015 use 5.022; if ( $id

    == any( 1, 2, 3 ) ) { ... } if ( $value eq none( ‘y’, ‘n’ ) ) { ... } if ( all( $foo, $bar ) >= 10 ) { ... } if ( one( 0 .. 10 ) == $baz ) { ... } So one of the features in Perl 6 that I really feel in love with was junctions. There are a couple of good CPAN modules out there, but really this should be something simpler, just a plain pragma. Also, it really should be in C so that it can be fast.
  33. Perl 5.22 is released 2015 use 5.022; fun reduce (

    $acc, @list ) { match ( @list ) { case ($head, @tail) { reduce( $head + $acc, @tail ) } case ($head, ()) { $head + $acc } } } How many of you have written OCaml? Haskell? Pattern matching is great, and with destructuring bind, it is even more awesome.
  34. Perl 5.22 is released 2015 use 5.022; fun reduce (

    $acc, $head ) { $head + $acc } fun reduce ( $acc, $head, @tail ) { reduce( $head + $acc, @tail ) } It also can be desugared into a style of multi-methods (see also Standard ML)
  35. Perl 5.22 is released 2015 use 5.022; fun control (

    $connection, $message ) { match ( @$message ) { case ( 'start', $name, @args ) { $connection->get($name)->start( @args ); } case ( 'stop', $name ) { $connection->get($name)->stop; } case ( 'error', $message ) { $connection->all->stop; warn $message; exit; } } } and it is not just for recursive esoteria, it can be very useful, think of it as a more awesome- er switch.
  36. Perl 5.32 is released 2025 % perlc -Ofun --target LLVM

    my_app.pl % perl -MO=JVM foo.pl % gcc -Wall bar.pl -o bar Part of what drives trendiness in programming languages is actually the level of CS sexy, and the idea that they can be pushed forward in new and exicting ways. Of course, this leads to disasters too, but until now (the future) it hasn't even really been possible, but thanks now to the reduced core, .... I have faith that Perl as a language can survive 13 years, it is flexible and has proven to be useful in many contexts. But where it needs to innovate is the compiler infrastructure. IronPython and JRuby are out there, they might not be the best or fastest, but they are platforms for innovation. Languages are consolidating around central VMs and cross language integration and Perl is behind on this.