Top Banner
The Evolution of Perl: Highlights of Perl 5.14 and what's new in the Perl world
24

Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Jan 15, 2015

Download

Technology

ActiveState

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

The Evolution of Perl:

Highlights of Perl 5.14 and what's new in the Perl world

Page 2: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

AgendaAgenda

• Perl, ActivePerl, and ActiveState• Version support – from the community and ActiveState• What's new in Perl 5.14• Re-factoring or maintaining existing code• Web frameworks and Plack/PSGI• Running Perl applications in the cloud

Page 3: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

PerlPerl

• Created by Larry Wall in 1987• Perl 5 released in 1995– language syntax stabilizes– first “extensible” version (use Some::Module)

• Continued improvements through the 5.x series

• Perl 6 – beyond the scope of this presentation– essentially a new language– a language specification, not an official compiler– Rakudo and other compilers available for early adopters

Page 4: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

ActivePerlActivePerl

• ActiveState contracted by Microsoft to improve Perl performance and features for Windows

• ActivePerl enhancements submitted back to core Perl• ActivePerl helps popularize Perl

– 2 million downloads per year• adds some useful things

– PPM (Perl Package Manager)– PerlCritic (from Perl Dev Kit)– PerlScript and Perl for ISAPI extensions

Page 5: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

• CPAN is a 'one stop shop' for user-created modules– standard toolchain for building, testing, and installing modules– searchable– standardized documentation format– bug tracking– HUGE: 23,000 modules (distributions)

• PPM is ActivePerl's client for installing these modules– command line and GUI interface– pre-compiled packages for specific platforms and Perl versions– dependencies handled automatically– provides most modules on CPAN (around 13,000 packages per

platform)

& PPMPPM

Page 6: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Perl ReleasesPerl Releases

• Perl releases used to be feature-based until 5.10– released “when it's done”

• time-based releases since Perl 5.12 (April 2010)– no feature milestones to define the release– only features ready by release-time will be included– predictable upgrade schedule

Page 7: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Perl Support PolicyPerl Support Policy

• Perl community supports the most recent two releases– new features– security patches– bug fixes

• ActiveState mirrors this policy for Community Edition• Older versions available through Business Edition,

Enterprise Edition and OEM– extended support– professional services

Page 8: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

What's new in Perl 5.14What's new in Perl 5.14

• Unicode improvements• Reliable exception handling• Non-destructive substitution• more...

Page 9: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Unicode Unicode

• Unicode 6.0 almost fully supported

• \N{NAME} and charnames enhancements

• use feature 'unicode_strings'

Page 10: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Regular Expressions Regular Expressions

• New character set modifiers:– /a ASCII– /d Default (or dodgy)– /l Locale– /u Unicode

• Caution: Modified stringification!for example: qr/foo/i– Old: (?i-xsm:foo)– New: (?^i:foo)

Page 11: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Non-destructive substitution Non-destructive substitution

(my $copy = $orig) =~ s/cat/dog/;(my $copy = $orig) =~ s/cat/dog/;my $copy = $orig =~ s/cat/dog/r;my $copy = $orig =~ s/cat/dog/r;

my @copy = map {my @copy = map { (my $copy = $_) =~ s/cat/dog/; $copy (my $copy = $_) =~ s/cat/dog/; $copy

} @orig;} @orig;

my @copy = map { s/cat/dog/r } @orig;my @copy = map { s/cat/dog/r } @orig;

Page 12: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Exception Handling Exception Handling

• Problems:– eval() in DESTROY methods– die() in DESTROY methods– local $@

• Solution:– Set $@ as late as possible before exiting the eval scope

• Exceptions are now a lot more reliable

Page 13: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Don’t use smart-matchDon’t use smart-match

• Smart match operator ~~ introduced in 5.10.0• “Fixed” in 5.10.1 because is wasn’t working

• Still considered “too smart for it’s own good”• Over 20 rules on how it works• Rules apply recursively for container types

• May be replaced by “dump match” in the future

• All this applies to the given/when statements too.

Page 14: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Maintaining or updating Perl codeMaintaining or updating Perl code

Try running it with with a newer interpreter – it may just work.The interpreter will warn about deprecated code

– incremental approach: 5.8 to 5.10 to 5.12 to 5.14• use warnings;• less likely to “break” existing code• setting up each environment takes time and effort

– direct approach: upgrading directly to 5.14• address all the incompatibilities at once• opportunity to re-factor and use new language features• great excuse to write automated tests!– write tests for the old version first, then run them against 5.12

Page 15: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Consult perldeltaConsult perldelta

• each Perl release has a list of differences and incompatibilities with the previous version– http://perldoc.perl.org/index-history.html– also in the ActivePerl documentation

• pay particular attention to the Incompatible Changes section

• don't skip a major version– the perldeltas are not cumulative - going from 5.10 to 5.14,

check the 5.12 delta – you can skip odd numbered development releases (5.9, 5.11,

etc.)

Page 16: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Check all modulesCheck all modules

• binary modules are NOT compatible between major Perl versions (e.g. 5.12 to 5.14)

• update to the latest modules where possible• using PPM helps (ppm profile ...)• Check the module's Changes file and documentation

Page 17: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Use Perl::CriticUse Perl::Critic

• Perl::Critic – for examining your source code– uses Conway's “Perl Best Practices”– points out bad or deprecated code and suggests alternatives

• ActivePerl has a helpful GUI interface– added in 5.12– formerly part of the Perl Dev Kit

Page 18: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

... or don't upgrade... or don't upgrade

• You may choose not to upgrade to 5.12 or 5.14 – there are commercial support options:

• ActivePerl Business Edition provides access to older builds of ActivePerl

• ActivePerl Enterprise Edition can provide access and support for specific versions and platform builds

• OEM licensing lets you distribute ActivePerl with your product

Page 19: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Web Frameworks and Plack/PSGIWeb Frameworks and Plack/PSGI

• Catalyst • Mojolicious• Dancer

... all work with Plack/PSGI• interface between Perl web applications and web servers• simplifies web application deployment

Page 20: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

CatalystCatalyst

• most popular framework in a recent ActiveState survey– relatively speaking, it's been around a long time (2005)– wide enterprise adoption

• a “heavyweight” framework– many dependencies– very “TMTOWTDO” design, lots of choices for sub-

components– very flexible

Page 21: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

MojoliciousMojolicious

• new web framework from author of Catalyst, Sebastian Riedel

• Mojo originally intended as a rewrite of Catalyst internals

• lighter weight– fewer dependencies– “optimized for user-friendliness”

Page 22: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

DancerDancer

• micro-framework• for smaller sites, web services, or people who just

prefer a very lightweight framework• similar to Ruby's Sinatra or Python's Flask

Page 23: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

Perl in the cloudPerl in the cloud

The Platform as a Service approach proved very popular in the Ruby on Rails community – has also caught on with other languages and frameworks

• a framework for frameworks... – not a PaaS... it's for creating your own PaaS

– supports multiple languages and frameworks

– Perl web apps via PSGI

– based on Cloud Foundry – more accessible for Perl and Python developers

– http://activestate.com/cloud

Page 24: Continuing Evolution of Perl: Highlights of ActivePerl 5.14

08/12/10

Thank YouThank You

Speak to a representative about ActivePerl Business Edition, Enterprise Edition

or OEM: [email protected]

www.activestate.com