Notes from Damian Conway's sessions at OSCON 2011
Here are my notes on two sessions from Damian Conway: The Conway Channel, and (Re)Developing in Perl 6. My notes are scattershot because it's awfully hard to watch and listen and take notes in a Damian. I wish he'd post his slides, but I understand why he doesn't/can't.
(These notes are extracted from my notes from OSCON 2011. Other topics include API design, PostgreSQL, Jenkins and Cornac.
The Conway Channel
The Conway Channel is Damian Conway's annual discussion of new tools that he's created in the past year.
Regexp::Grammars is all sorts of parsing stuff for Perl 5.10 regexes, and it went entirely over my head.
IO::Prompter is an updated version of IO::Prompt which is pretty cool already. It only works Perl with 5.10+. IO::Prompt makes it easy to prompt the user for input, and the new IO::Prompter adds more options and data validation.
# Get a number my $n = prompt -num 'Enter a number'; # Get a password with asterisks my $passwd = prompt 'Enter your password', -echo=>'*'; # Menu with nested options my $selection = prompt 'Choose wisely...', -menu => { wealth => [ 'moderate', 'vast', 'incalculable' ], health => [ 'hale', 'hearty', 'rude' ], wisdom => [ 'cosmic', 'folk' ], }, '>';
Data::Show is like Data::Dumper but also shows helpful debug tips like variable names and origin of the statement. It doesn't try to serialize your output like Data::Dumper does, which is a good thing. Data::Show is now my default data debug tool.
my $person = { name => 'Quinn', preferred_games => { wii => 'Mario Party 8', board => 'Life: Spongebob Squarepants Edition', }, aliases => [ 'Shmoo', 'Monkeybutt' ], greeter => sub { my $name = shift; say "Hello $name" }, }; show $person; ======( $person )====================[ 'data-show.pl', line 20 ]====== { aliases => ["Shmoo", "Monkeybutt"], greeter => sub { ... }, name => "Quinn", preferred_games => { board => "Life: Spongebob Squarepants Edition", wii => "Mario Party 8", }, }Acme::Crap is a joke module that adds a crap function that also lets you use exclamation points to show severity of the error.
use Acme::Crap; crap 'This broke'; crap! 'This other thing broke'; crap!! 'A third thing broke'; crap!!! 'A four thing broke'; This broke at acme-crap.pl line 10 This other thing broke! at acme-crap.pl line 11 A Third Thing Broke!! at acme-crap.pl line 12 A FOUR THING BROKE!!! at acme-crap.pl line 13
As with most of Damian's joke modules, you're not likely to use this in a real program, but to learn from how it works internally. In Acme::Crap's case, the lesson is in overloading the ! operator.
(Re)Developing Perl 5 Modules in Perl 6
Perl isn't a programming language. It's a life support system for CPAN.
Damian ported some of his Perl 5 modules to Perl 6 as a learning exercise.
Acme::Don't
Makes a block of code not get executed, so it gets syntax checked but not run.
# Usage example use Acme::Don't; don't { blah(); blah(); blah();
Perl 6 implementation
module Acme::Don't; use v6; sub don't (&) is export {}
Lessons:
- No homonyms in Perl 6
- No cargo-cult vestigials
- Fewer implicit behaviours
- A little more typing required
- Still obviously Perlish
IO::Insitu
Modifies files in place.
- Parameter lists really help
- Smarter open() helps too
- Roles let you mix in behviours
- A lot less typing required
- Mainly because of better builtins
Smart::Comments
- Perl 6's macros kick source filters' butt
- Mutate grammar, not source
- Still room for cleverness
- No Perl 6 implementation yet has full macro support
- No Perl 6 implementation yet has STD grammar
Perl 6 is solid enough now. Start thinking about porting modules.