Telephone +44(0)1524 64544
Email: info@shadowcat.co.uk

deutschebank-2011 - perl-in-2011

Sat Dec 22 00:30:00 2012

Slides for the talk perl-in-2011 at deutschebank-2011

-

Perl
in
2011

-

Me?

-

Matt S. Trout
cpan:MSTROUT
irc:mst
@shadowcat_mst

-

Consultant
Cat herder
Contributor

-

Shadowcat

-

Shadowcat
"Supporting
CPAN"

-

git.shadowcat.co.uk
lists.scsys.co.uk
irc.perl.org

-

Anyway.

-

-

Perl for
infrastructure

-

Lightning
tour

-

Examples?

-

http://metacpan.org/module/Some::Name

-

-

Databases

-

DBIx::Class

-

Not exactly
an ORM

-

Relational
to Object
Mapper

-

SQL meta
programming
toolkit

-

"If you can't
get exactly
the SQL you'd
have written
yourself ..."

-

GROUP BY
HAVING

-

FROM (SELECT ...)

-

Fork safe
Thread safe

-

DBIx::Connector

-

Same logic
standalone

-

SQL::Abstract

-

Query building
standalone

-

DBIx::Class

-

Substantial
extension
ecosystem

-

Over 130
CPAN dists

-

Replication

-

Write master
Read slave

-

Read master
w/in txn

-

Multiple
server
pools

-

DDL

-

SQL::Translator

-

CREATE 

-

CREATE
ALTER
DROP

-

DBIx::Class::DeploymentHandler

-

Database
schema
versioning

-

Pluggable
with
defaults

-

Migration SQL

-

Migration SQL
Migration Perl

-

Usable
without
the 'O'

-

KiokuDB uses
DBIx::Class
for RDBMS
deployment

-

KiokuDB

-

Object
database

-

Advantages
Limitations

-

Multiple
backends

-

Pluggable
search
system

-

Moose
object
graph

-

Rapid
prototyping

-

Low to
moderate
concurrency

-

-

Object
Orientation

-

Moose

-

Moose!

-

Full OO
system

-

Based on metamodel
research done by
the perl6 project

-

Substantially
improved through
production use

-

Roles

-

Roles
>
Mixins

-

Roles
>
Interfaces

-

Attribute
system

-

Optional
type
checking

-

Full meta
protocol

-

Metacircularity
(Moose-in-Moose)

-

Introspectability
Extensibility

-

  $meta->get_all_attributes
  $meta->get_all_methods

-

Reflection

-

Documentation
Facades
Class-as-API

-

Extension

-

Meta*
Roles

-

  @{$obj->actors}
  $obj->all_actors

-

Attribute
Accessor
Constructor
...

-

Extensions
compose and
co-operate

-

220+
CPAN
dists

-

Stability

-

3 month
"feature
release"
cycle

-

Bugfix
releases
between

-

Compatibility

-

moose-outdated

-

  cpan $(moose-outdated)

-

Startup
overhead

-

Irrelevant
outside of
sub-0.5s
processes

-

Moo

-

80% surface
syntax

-

0% MOP

-

Pure perl
dependency
chain

-

Usually?

-

Just use
Moose.

-

-

Interlude

-

Humour

-

Humour?

-

Know Thy
Audience

-

Greg
McCarroll

-

YAPC::EU

-

I made
a bet

-

Ranting
presentation
style

-

No swearing

-

Book
dedication

-

Auction

-

"For those of
you watching
this on youtube"

-

"... I'm
Dave Cross"

-

-

Web

-

Catalyst

-

MVC

-

Longest
standing
framework

-

Designed for
large scale
projects

-

Designed for
long term
projects

-

No 5 minute
screencast
wow moment

-

Maintainable
Scalable
Stable

-

5 year
"development
velocity
maintained"
wow moment

-

Controllers
self contained
(include their
URL route info)

-

Superclasses
roles

-

Catalyst::Plugin::AutoCRUD

-

Catalyst::Plugin::AutoCRUD
web UI reflected from
DBIx::Class schema

-

Catalyst::Controller::REST

-

Catalyst::Controller::REST
  sub thing_GET {}
  sub thing_POST {}

-

Catalyst::Controller::DBIC::API

-

Catalyst::Controller::DBIC::API
REST or RPC style JSON API

-

Catalyst::Controller::DBIC::API
REST or RPC style JSON API
Expose tables/columns via config

-

HTML::FormHandler

-

OO form
system

-

Moose style
extensibility
patterns

-

DBIx::Class
auto-update
support

-

Form class
scaffolding

-

Possibly
actually
better than
by hand

-

Other
frameworks?

-

Dancer
Mojolicious

-

Smaller
projects

-

Smaller
ecosystem

-

CPAN
dists

-

Dancer - 83
Mojolicious - 93
Catalyst - 599

-

Catalyst
5.80

-

Ground up
Moose

-

Catalyst
5.90

-

Pure PSGI
framework

-

PSGI

-

Python (WSGI)
Ruby (Rack)

-

PSGI

-

Perl Server
Gateway
Interface

-

Common
Gateway
Interface

-

  $env

-

  \%env

-

  \%ENV

-

  $app->($env)

-

  $res = $app->($env)

-

Server
independent

-

mod_perl
FastCGI
HTTP

-

starman
fastpass

-

  $app->($env)

-

Composable

-

Middleware

-

  $wrapped = $mw->wrap($app);
  $wrapped->($env);

-

Session
Static
SendFile

-

Debug panels

-

Stack traces
Query logs
Timing data

-

Support from
all major
frameworks

-

Dancer and
Catalyst both
now "native"

-

Over 175
middlewares
on CPAN

-

Testing
infrastructure

-

Pre-built
apps

-

Also

-

SPORE

-

REST
client

-

Moose
+ MOP

-

Rapid web API
client building

-

-

CLI

-

MooseX::Getopt

-

  has 'foo' => (...

-

  mycli --foo

-

MooseX::SimpleConfig

-

  mycli --configfile=./this.conf

-

MooseX::App::Cmd

-

App::Cmd

-

App::Cmd
+
MooseX::Getopt

-

  mycli subcommand --option

-

Path::Dispatcher

-

  mycli user Bob update --option

-

Deep/nested
commands

-

bash completion
support available

-

For quick
scripts

-

Opt::Imistic

-

  use Opt::Imistic;

  my $verbose = $ARGV{v}||$ARGV{verbose};

-

-

Deployment

-

local::lib

-

~/perl5

-

/path/to/app/deps

-

cpanmin.us

-

cpanm

-

cpan--

-

80%
solution

-

much
less
noise

-

always
writes
build.log

-

local::lib
integration

-

  cpanm -l$HOME/perl5
    --installdeps .

-

carton

-

runs a
cpanm
install

-

remembers
dist order
+ versions

-

replay on
build server

-

carton exec

-

uses only
core dirs
plus carton
installs

-

vendor
packaging?

-

CPANPLUS

-

CPANPLUS
cpan2dist

-

deb
rpm
tgz
...

-

App::FatPacker

-

"like PAR,
but only for
pure perl"

-

builds a self
contained
perl script

-

(used to
package cpanm)

-

-

Minor
addenda

-

IO::All

-

  my $data = io($file)->all;

-

  io($file)->print($data);

-

  print $_->getline
    for io($dir)->all_files;

-

Eval::WithLexicals

-

tinyrepl

-

  $ my $x = 3;
  3
  $ $x + 4;
  7

-

Devel::NYTProf

-

per-subroutine
and per-line
profiling

-

nytprofhtml

-

jquery
sortable
tables

-

Devel::Dwarn

-

  return $x.$y;

-

  my $res = $x.$y;
  warn Dumper($res);
  return $res;

-

  return Dwarn $res;

-

  return $obj->something;

-

  my $res = $obj->something;
  warn Dumper($res);
  return $res;

-

  return $obj->$Dwarn->something;

-

Try::Tiny

-

  try {
    ...
  } catch {
    warn "Error: $_";
  };

-

Saves messing
up eval {}

-

-

And finally:

-

Task::Kensho

-

An SDK for
new perl
development

-

Including
at least some
of the things
I've missed

-

Questions?

-

Thank You
IRC:mst
mst@shadowcat.co.uk
@shadowcat_mst