SlideShare ist ein Scribd-Unternehmen logo
1 von 56
Reviewing CPAN modules

       Neil Bowers




                         1
• Apparently there are 1,900+ Torch/Flashlight apps…

                                                       2
3
What is CPAN?
• Something like a university library?
  • Lots of useful items, nicely catalogued, easily found

        Atoolchest full of precision instruments that good programmers
        can wield to make great things
                                                              - chromatic


• I think more like Rube Goldberg's workshop:
  • A bunch of useful things, some half-finished ideas, practical jokes, stuff
    that no longer works, items that shouldn't be there, forgotten things in
    the corner
        Holy crap, I forgot about [that module that I wrote].
                                                                - Andy Lester

                                                                                 4
Review #1
Generating passwords
Modules that can be used to automatically generate passwords,
either random sequences of characters or pronounceable pseudo words




                                                                      5
Modules for generating passwords




                                   6
Generating random char strings
                  • 100,000 passwords




                                        7
Structure of reviews




                       8
After doing the review
• I'm now using Crypt::YAPassGen
  • v0.02 released 2004-05-30

• App::Genpass is good
  • I've submitted changes to add features I liked in other modules

• I've ended up using Data::Random elsewhere
  • Because I was aware of it having done this review

• Hoping to finally release fix for Crypt::RandPasswd
  • I was granted co-maint yesterday (23rd Nov 2012)




                                                                      9
Review #2
Looking up location of an IP address
Modules that can map an IP address to ISO country code,
and possibly return additional info like language, county/state, etc




                                                                       10
Modules for getting IP location
             co-maint to release fixes and doc updates




                                                         11
Notes
• A number of these are 'commercial'
  • Pay for full data set, or to get unthrottled access to backend service

• Performance & coverage tests took the most time
  • In particular it's hard to test for correctness

• A number of good options
  • Competition keeps them on their toes?
  • Which one you use might depend on what other info you want for an IP

• Ended up not having the need, so not using any
  • But have used them occasionally, now I know about them



                                                                             12
Review #3
Spelling out a number in English
Modules for converting 327 to "three hundred and twenty-seven",
-3.25 to "minus three point two five", etc




                                                                  13
Modules for spelling out numbers




                                   14
Notes on review #3
• Fewer modules meant more time to 'play'
  • I had fun writing a script to automatically compare results between
    modules for 1 .. N

• First time I hit a module that just doesn't work
• Lingua::EN::Numbers
  • The first module where I remember looking at the code and thinking
    "hey, nice"
  • I took over maintenance from Sean Burke to release fixes
  • And have a todo-list, adding ideas that came up during the review




                                                                          15
My rules of engagement
• Treat authors and their code with respect
  • This might be someone's first tentative steps at code sharing

• Report all bugs I find
  • If I can see how to fix them, then submit a fix

• Fix and improve documentation
  • Especially if I had to look at the code to work out how to use it

• If appropriate, try and get co-maint to release fixes
  • Because CPAN is forever
  • This can be to just mark a module as deprecated & update SEE ALSO

• If there are four or more modules for something
  • It goes onto my backlog of potential reviews
                                                                        16
Observations based on the rules
• What encourages me to submit fixes?
  • Github
  • Makefile.PL (or more accurately: not dist.ini)

• Getting co-maint is relatively costly
  • People disagreed when I said this at LPW 2011 ("You're doing it wrong")
  • I still think this (getting co-maint to fix doc is relatively costly)

• I'm toying with writing a tool to manage this
  • I might submit bugs or send email on 10 different modules in a review




                                                                            17
Review #4
Parsing User-Agent strings
Modules for extracting and inferring information from HTTP User-Agent
strings.

Eg to tell how many of your site's users are using IE vs Chrome vs Firefox




                                                                             18
Modules for parsing User-Agent




                                 19
Review structure: module section




                                   20
Comparison
                         Coverage (test corpus)




Speed


             Review-driven development!




                                             21
Curation
• Requirements for these modules
  • Continuing good coverage of (versions of) browsers, bots, libraries, etc
  • Good enough performance (processing large log files)
  • Identifying other things (is it a mobile? what's the screen size?)

• Working with Olaf Alders on "complete solution"
  • Currently at the R&D stage 




                                                                               22
Review #5
Defining constants
Modules for defining constants and immutable variables




                                                         23
Modules for defining constants




                                 24
Some firsts with this review
• I was prompted to look at the Perl source
  • To make sure I understood SvREADONLY

• Emailed an author for help understanding his code
• Enough modules to prompt me to map them out




                                                      25
Observations
• I had been using Readonly
  • But I clearly hadn't read all the documentation before

• Now I use Const::Fast
  • Latency: all those modules using Readonly …

• Surprising variety of designs / approaches
  • I learned a lot looking at the code for all these modules

• But quite a few experiments
  • "I wonder if you can …"




                                                                26
Review #6
Getting module dependency info
Finding out what modules (and dists) are used by a module or modules




                                                                       27
Tried a new approach
• Previously I only published after a lot of work
  • But I still missed plenty of modules

• Decided to experiment with a more lean approach
  • Found 6 modules, none did what I wanted, so wrote my own
  • Wrote a quick sketch review and published it
  • More modules came out of the woodwork every time I updated

• I was looking at dependencies for my next review
  • But ended up pushing this one out sooner




                                                                 28
Modules for getting dependencies




                                   29
Module Author
• I had a "bug" reported – author is listed as:



• But META.json says:



• End result was PAUSE::Permissions


                                                  30
Notes
• The 23rd module nearly matched mine!
• Very much still in progress
• Curation needed:
  • There are 5 or so distinct module types (out of 26 so far)
  • But lots of different variations on each theme




                                                                 31
Why so many modules?
• Whipupitude
• Low barrier to entry for CPAN
• Hard to find (all) appropriate modules
• Easier to upload than contribute or take over
• Playing with Perl is fun (eg constants, dependencies)




                                                          32
Review #7
Making HTTP requests
Modules for making HTTP requests (GET, POST, PUT, DELETE, etc)
Excluding higher-level modules like WWW::Mechanize




                                                                 33
Modules for making HTTP requests




 The only module I've given up on   34
Performance on GET requests




                              35
Runtime dependencies



                 Require a C library




                 Requires a C library and Moose!


                                                   36
What module to use?




                      37
Review #8
LUHN check
Modules for checking credit card numbers




                                           38
Modules for checking CC numbers




                                  39
Performance of LUHN modules




                  Moose?




                              40
Review #9
Getting a module's path
Modules for finding where a module has been installed locally,
preferably without having to load the module




                                                                 41
Modules for getting a module's path




                                 42
Comparison




Nearly three orders of magnitude


                                   43
Feature matrix




                 44
Features vs Dependencies




                           45
Appropriate # of dependencies




                                46
Observations

And some mild venting




                        47
What do people use CPAN for?
• Sharing code with others!
• Configuration management
• A cloud-based store for configuration (Task::BeLike::*)
• A transport mechanism
• A todo list (egBusiness::BankCard)
• A blog / dumping ground for ideas
• None of the above (ACME::*)



                                                            48
Version numbers
• Version numbers should be designed for humans
  • PAUSE just wants them to be monotonically increasing

• All modules in a dist should have                                0.01
  • A version number                                             0.004
  • The same version number                                  1.121660
                                                                0.0.20
• Don't be afraid of 1.x                                          0.6.1
                                                                      5
  • 73% of dists on CPAN are version 0.*                         0.000
                                                             0.001005
• our $VERSION = '0.01';                                        v0.0.3
                                                                    2.4
                                                                  6632
                                                           2011121001



                                                                49
How can you tell a good module?
•   Version number
    •   But see Net::HTTP::Tiny v0.01

•   Recently updated
    •   Some modules are 'finished'

•   Volume and/or quality of documentation
    •   See Crypt::RandPasswd

•   Number of bugs
    •   Some big hitters have a long list though…

•   Number of dependent modules
    •   from different authors

•   Ratings / +1's
•   Perl::Critic
•   Author
•   All of the above, and more


                                                    51
How have I changed as a result?
• I've learned new things, & new ways to do things, & …
• I do developer releases & pay a lot more attention to CPAN Testers
• I'm more paranoid
• I benchmark and profile
• I use IRC, and have had only positive experiences
• How I export functions (thank-you Zefram)
• How I think about dependencies
• Moose / Mouse / Moo
• I'm a lot more circumspect about releasing code to CPAN
• Beginner's mind

                                                                       52
My review process
• Quickly skim and find initial set of modules
• Start writing sections for each module
  • Write generic SYNOPSIS style example, and evolve it as I go along

• Report bugs and documentation issues as I go
• First sketch at benchmarking & comparing
• More thorough search for modules to include
• Email the authors, give them a chance to comment
• Publish first version
  • Iterate as people point out modules that I've missed

                                                                        54
It's easy – why not give it a go?
 % mkdir json
 % cd json

 % cat > module-list.txt
 JSON
 JSON::DWIW
 JSON::JOM
 JSON::Parse
 JSON::Syck
 JSON::Tiny
 JSON::Util
 JSON::XS
 JSON::YAJL
 JSON::Streaming::Reader
 JSON::Streaming::Writer
 Mojo::JSON
 Pegex::JSON
 Test::JSON
 ^D

 % cpan-review


                                    55
What do I want you to do?
• Stop and search CPAN before writing code
  • Ok, I accept it's hard to find (all of the) relevant modules for a task

• Just because you wrote it, you don't have to upload it
  • Only release if it's needed for another module, or another user
  • Put it on github
  • Write an article about it on blogs.perl.org

• Add links to similar modules in SEE ALSO
  • MetaCPAN will include those in search results
  • It's helpful for users
  • You'll make my life easier

• Write a helpful ABSTRACT in your NAME section
  • "a perl interface to foolib"
  • "the hardest working two letters in Perl"

                                                                              56
Review-related todo list
• Related to existing reviews
  •   Fix Crypt::RandPasswd
  •   Configurability for Lingua::EN::Numbers
  •   User-Agent module with Olaf
  •   New constant module: Exporter::Constants
  •   Dependencies: +5 modules to review, my module, curation
  •   HTTP requests: Mojo::UserAgent, async request modules
  •   Changes to Business::CCCheck

• New reviews in progress
  • Hash objects
  • JSON
  • Module loading


                                                                57
Finding modules is hard
• Thinking about trying automatic clustering
• Help identify groups of modules for review
• Possible contribution to MetaCPAN
• Automatic tagging of modules
  • Use keywords field in metadata




                                               58

Weitere ähnliche Inhalte

Was ist angesagt?

Symony2 A Next Generation PHP Framework
Symony2 A Next Generation PHP FrameworkSymony2 A Next Generation PHP Framework
Symony2 A Next Generation PHP FrameworkRyan Weaver
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tigerElizabeth Smith
 
Advanced Reflection in Pharo
Advanced Reflection in PharoAdvanced Reflection in Pharo
Advanced Reflection in PharoMarcus Denker
 
Functional programming principles and Java 8
Functional programming principles and Java 8Functional programming principles and Java 8
Functional programming principles and Java 8Dragos Balan
 
CNIT 126 13: Data Encoding
CNIT 126 13: Data EncodingCNIT 126 13: Data Encoding
CNIT 126 13: Data EncodingSam Bowne
 
Ancient To Modern: Upgrading nearly a decade of Plone in public radio
Ancient To Modern: Upgrading nearly a decade of Plone in public radioAncient To Modern: Upgrading nearly a decade of Plone in public radio
Ancient To Modern: Upgrading nearly a decade of Plone in public radioCristopher Ewing
 
Dependency Injection: Make your enemies fear you
Dependency Injection: Make your enemies fear youDependency Injection: Make your enemies fear you
Dependency Injection: Make your enemies fear youRyan Weaver
 
Laravel Webcon 2015
Laravel Webcon 2015Laravel Webcon 2015
Laravel Webcon 2015Tim Bracken
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machineLaxman Puri
 
Speed geeking-lotusscript
Speed geeking-lotusscriptSpeed geeking-lotusscript
Speed geeking-lotusscriptBill Buchan
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for seleniumapoorvams
 
Burp Plugin Development for Java n00bs - 44CON 2012
Burp Plugin Development for Java n00bs - 44CON 2012Burp Plugin Development for Java n00bs - 44CON 2012
Burp Plugin Development for Java n00bs - 44CON 201244CON
 
java8-patterns
java8-patternsjava8-patterns
java8-patternsJustin Lin
 
Creating Perl modules with Dist::Zilla
Creating Perl modules with Dist::ZillaCreating Perl modules with Dist::Zilla
Creating Perl modules with Dist::ZillaMark Gardner
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakMarcus Denker
 
Functional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersFunctional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersDiego Freniche Brito
 
PharoDAYS 2015: Pharo Status - by Markus Denker
PharoDAYS 2015: Pharo Status - by Markus DenkerPharoDAYS 2015: Pharo Status - by Markus Denker
PharoDAYS 2015: Pharo Status - by Markus DenkerPharo
 

Was ist angesagt? (20)

Variables in Pharo5
Variables in Pharo5Variables in Pharo5
Variables in Pharo5
 
Symony2 A Next Generation PHP Framework
Symony2 A Next Generation PHP FrameworkSymony2 A Next Generation PHP Framework
Symony2 A Next Generation PHP Framework
 
Taming the resource tiger
Taming the resource tigerTaming the resource tiger
Taming the resource tiger
 
Advanced Reflection in Pharo
Advanced Reflection in PharoAdvanced Reflection in Pharo
Advanced Reflection in Pharo
 
Functional programming principles and Java 8
Functional programming principles and Java 8Functional programming principles and Java 8
Functional programming principles and Java 8
 
Php extensions
Php extensionsPhp extensions
Php extensions
 
CNIT 126 13: Data Encoding
CNIT 126 13: Data EncodingCNIT 126 13: Data Encoding
CNIT 126 13: Data Encoding
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
 
Ancient To Modern: Upgrading nearly a decade of Plone in public radio
Ancient To Modern: Upgrading nearly a decade of Plone in public radioAncient To Modern: Upgrading nearly a decade of Plone in public radio
Ancient To Modern: Upgrading nearly a decade of Plone in public radio
 
Dependency Injection: Make your enemies fear you
Dependency Injection: Make your enemies fear youDependency Injection: Make your enemies fear you
Dependency Injection: Make your enemies fear you
 
Laravel Webcon 2015
Laravel Webcon 2015Laravel Webcon 2015
Laravel Webcon 2015
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
Speed geeking-lotusscript
Speed geeking-lotusscriptSpeed geeking-lotusscript
Speed geeking-lotusscript
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
 
Burp Plugin Development for Java n00bs - 44CON 2012
Burp Plugin Development for Java n00bs - 44CON 2012Burp Plugin Development for Java n00bs - 44CON 2012
Burp Plugin Development for Java n00bs - 44CON 2012
 
java8-patterns
java8-patternsjava8-patterns
java8-patterns
 
Creating Perl modules with Dist::Zilla
Creating Perl modules with Dist::ZillaCreating Perl modules with Dist::Zilla
Creating Perl modules with Dist::Zilla
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
Functional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented ProgrammersFunctional Programming for Busy Object Oriented Programmers
Functional Programming for Busy Object Oriented Programmers
 
PharoDAYS 2015: Pharo Status - by Markus Denker
PharoDAYS 2015: Pharo Status - by Markus DenkerPharoDAYS 2015: Pharo Status - by Markus Denker
PharoDAYS 2015: Pharo Status - by Markus Denker
 

Andere mochten auch

الاختبار
الاختبارالاختبار
الاختبارMai Khaled
 
Mason’s autobiography
Mason’s autobiographyMason’s autobiography
Mason’s autobiographymason11226
 
Future Internet testbeds in Latin America
Future Internet testbeds in Latin AmericaFuture Internet testbeds in Latin America
Future Internet testbeds in Latin Americafuture-internet
 
Inrotduction of Testing
Inrotduction of TestingInrotduction of Testing
Inrotduction of TestingPalash Ghosh
 
الاختبار
الاختبارالاختبار
الاختبارMai Khaled
 
Have more fun with Perl via Questhub
Have more fun with Perl via QuesthubHave more fun with Perl via Questhub
Have more fun with Perl via Questhubneilbowers
 

Andere mochten auch (6)

الاختبار
الاختبارالاختبار
الاختبار
 
Mason’s autobiography
Mason’s autobiographyMason’s autobiography
Mason’s autobiography
 
Future Internet testbeds in Latin America
Future Internet testbeds in Latin AmericaFuture Internet testbeds in Latin America
Future Internet testbeds in Latin America
 
Inrotduction of Testing
Inrotduction of TestingInrotduction of Testing
Inrotduction of Testing
 
الاختبار
الاختبارالاختبار
الاختبار
 
Have more fun with Perl via Questhub
Have more fun with Perl via QuesthubHave more fun with Perl via Questhub
Have more fun with Perl via Questhub
 

Ähnlich wie Reviewing CPAN modules

Tooling for the JavaScript Era
Tooling for the JavaScript EraTooling for the JavaScript Era
Tooling for the JavaScript Eramartinlippert
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentationBhavin Gandhi
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Hannes Lowette
 
The New Frontend Toolchain
The New Frontend ToolchainThe New Frontend Toolchain
The New Frontend ToolchainBruno Abrantes
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Andrei KUCHARAVY
 
Modern Module Development
Modern Module DevelopmentModern Module Development
Modern Module Development_morgan
 
CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45Bilal Ahmed
 
Why We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub ContributorsWhy We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub ContributorsNikolaos Tsantalis
 
PuppetConf 2016: How Not to Freak Out When You Start Writing Puppet Modules f...
PuppetConf 2016: How Not to Freak Out When You Start Writing Puppet Modules f...PuppetConf 2016: How Not to Freak Out When You Start Writing Puppet Modules f...
PuppetConf 2016: How Not to Freak Out When You Start Writing Puppet Modules f...Puppet
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven developmentEinar Ingebrigtsen
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code ReviewMilan Vukoje
 
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Controlindiver
 
Vulnerability, exploit to metasploit
Vulnerability, exploit to metasploitVulnerability, exploit to metasploit
Vulnerability, exploit to metasploitTiago Henriques
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)Peter Kofler
 
EuroMPI 2013 presentation: McMPI
EuroMPI 2013 presentation: McMPIEuroMPI 2013 presentation: McMPI
EuroMPI 2013 presentation: McMPIDan Holmes
 
MPI Requirements of the Network Layer
MPI Requirements of the Network LayerMPI Requirements of the Network Layer
MPI Requirements of the Network Layerinside-BigData.com
 
Introducing systems analysis, design & development Concepts
Introducing systems analysis, design & development ConceptsIntroducing systems analysis, design & development Concepts
Introducing systems analysis, design & development ConceptsShafiul Azam Chowdhury
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET Dmytro Mindra
 

Ähnlich wie Reviewing CPAN modules (20)

Tooling for the JavaScript Era
Tooling for the JavaScript EraTooling for the JavaScript Era
Tooling for the JavaScript Era
 
Clean code presentation
Clean code presentationClean code presentation
Clean code presentation
 
Rails tools
Rails toolsRails tools
Rails tools
 
Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®Build software like a bag of marbles, not a castle of LEGO®
Build software like a bag of marbles, not a castle of LEGO®
 
The New Frontend Toolchain
The New Frontend ToolchainThe New Frontend Toolchain
The New Frontend Toolchain
 
Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1Introduction to the intermediate Python - v1.1
Introduction to the intermediate Python - v1.1
 
Modern Module Development
Modern Module DevelopmentModern Module Development
Modern Module Development
 
CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45CS101- Introduction to Computing- Lecture 45
CS101- Introduction to Computing- Lecture 45
 
Why We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub ContributorsWhy We Refactor? Confessions of GitHub Contributors
Why We Refactor? Confessions of GitHub Contributors
 
PuppetConf 2016: How Not to Freak Out When You Start Writing Puppet Modules f...
PuppetConf 2016: How Not to Freak Out When You Start Writing Puppet Modules f...PuppetConf 2016: How Not to Freak Out When You Start Writing Puppet Modules f...
PuppetConf 2016: How Not to Freak Out When You Start Writing Puppet Modules f...
 
Driving application development through behavior driven development
Driving application development through behavior driven developmentDriving application development through behavior driven development
Driving application development through behavior driven development
 
Coding Standard And Code Review
Coding Standard And Code ReviewCoding Standard And Code Review
Coding Standard And Code Review
 
Make It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version ControlMake It Cooler: Using Decentralized Version Control
Make It Cooler: Using Decentralized Version Control
 
Vulnerability, exploit to metasploit
Vulnerability, exploit to metasploitVulnerability, exploit to metasploit
Vulnerability, exploit to metasploit
 
TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)TDD and Related Techniques for Non Developers (2012)
TDD and Related Techniques for Non Developers (2012)
 
EuroMPI 2013 presentation: McMPI
EuroMPI 2013 presentation: McMPIEuroMPI 2013 presentation: McMPI
EuroMPI 2013 presentation: McMPI
 
MPI Requirements of the Network Layer
MPI Requirements of the Network LayerMPI Requirements of the Network Layer
MPI Requirements of the Network Layer
 
Introducing systems analysis, design & development Concepts
Introducing systems analysis, design & development ConceptsIntroducing systems analysis, design & development Concepts
Introducing systems analysis, design & development Concepts
 
Module development
Module developmentModule development
Module development
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET
 

Reviewing CPAN modules

  • 1. Reviewing CPAN modules Neil Bowers 1
  • 2. • Apparently there are 1,900+ Torch/Flashlight apps… 2
  • 3. 3
  • 4. What is CPAN? • Something like a university library? • Lots of useful items, nicely catalogued, easily found Atoolchest full of precision instruments that good programmers can wield to make great things - chromatic • I think more like Rube Goldberg's workshop: • A bunch of useful things, some half-finished ideas, practical jokes, stuff that no longer works, items that shouldn't be there, forgotten things in the corner Holy crap, I forgot about [that module that I wrote]. - Andy Lester 4
  • 5. Review #1 Generating passwords Modules that can be used to automatically generate passwords, either random sequences of characters or pronounceable pseudo words 5
  • 7. Generating random char strings • 100,000 passwords 7
  • 9. After doing the review • I'm now using Crypt::YAPassGen • v0.02 released 2004-05-30 • App::Genpass is good • I've submitted changes to add features I liked in other modules • I've ended up using Data::Random elsewhere • Because I was aware of it having done this review • Hoping to finally release fix for Crypt::RandPasswd • I was granted co-maint yesterday (23rd Nov 2012) 9
  • 10. Review #2 Looking up location of an IP address Modules that can map an IP address to ISO country code, and possibly return additional info like language, county/state, etc 10
  • 11. Modules for getting IP location co-maint to release fixes and doc updates 11
  • 12. Notes • A number of these are 'commercial' • Pay for full data set, or to get unthrottled access to backend service • Performance & coverage tests took the most time • In particular it's hard to test for correctness • A number of good options • Competition keeps them on their toes? • Which one you use might depend on what other info you want for an IP • Ended up not having the need, so not using any • But have used them occasionally, now I know about them 12
  • 13. Review #3 Spelling out a number in English Modules for converting 327 to "three hundred and twenty-seven", -3.25 to "minus three point two five", etc 13
  • 14. Modules for spelling out numbers 14
  • 15. Notes on review #3 • Fewer modules meant more time to 'play' • I had fun writing a script to automatically compare results between modules for 1 .. N • First time I hit a module that just doesn't work • Lingua::EN::Numbers • The first module where I remember looking at the code and thinking "hey, nice" • I took over maintenance from Sean Burke to release fixes • And have a todo-list, adding ideas that came up during the review 15
  • 16. My rules of engagement • Treat authors and their code with respect • This might be someone's first tentative steps at code sharing • Report all bugs I find • If I can see how to fix them, then submit a fix • Fix and improve documentation • Especially if I had to look at the code to work out how to use it • If appropriate, try and get co-maint to release fixes • Because CPAN is forever • This can be to just mark a module as deprecated & update SEE ALSO • If there are four or more modules for something • It goes onto my backlog of potential reviews 16
  • 17. Observations based on the rules • What encourages me to submit fixes? • Github • Makefile.PL (or more accurately: not dist.ini) • Getting co-maint is relatively costly • People disagreed when I said this at LPW 2011 ("You're doing it wrong") • I still think this (getting co-maint to fix doc is relatively costly) • I'm toying with writing a tool to manage this • I might submit bugs or send email on 10 different modules in a review 17
  • 18. Review #4 Parsing User-Agent strings Modules for extracting and inferring information from HTTP User-Agent strings. Eg to tell how many of your site's users are using IE vs Chrome vs Firefox 18
  • 19. Modules for parsing User-Agent 19
  • 21. Comparison Coverage (test corpus) Speed Review-driven development! 21
  • 22. Curation • Requirements for these modules • Continuing good coverage of (versions of) browsers, bots, libraries, etc • Good enough performance (processing large log files) • Identifying other things (is it a mobile? what's the screen size?) • Working with Olaf Alders on "complete solution" • Currently at the R&D stage  22
  • 23. Review #5 Defining constants Modules for defining constants and immutable variables 23
  • 24. Modules for defining constants 24
  • 25. Some firsts with this review • I was prompted to look at the Perl source • To make sure I understood SvREADONLY • Emailed an author for help understanding his code • Enough modules to prompt me to map them out 25
  • 26. Observations • I had been using Readonly • But I clearly hadn't read all the documentation before • Now I use Const::Fast • Latency: all those modules using Readonly … • Surprising variety of designs / approaches • I learned a lot looking at the code for all these modules • But quite a few experiments • "I wonder if you can …" 26
  • 27. Review #6 Getting module dependency info Finding out what modules (and dists) are used by a module or modules 27
  • 28. Tried a new approach • Previously I only published after a lot of work • But I still missed plenty of modules • Decided to experiment with a more lean approach • Found 6 modules, none did what I wanted, so wrote my own • Wrote a quick sketch review and published it • More modules came out of the woodwork every time I updated • I was looking at dependencies for my next review • But ended up pushing this one out sooner 28
  • 29. Modules for getting dependencies 29
  • 30. Module Author • I had a "bug" reported – author is listed as: • But META.json says: • End result was PAUSE::Permissions 30
  • 31. Notes • The 23rd module nearly matched mine! • Very much still in progress • Curation needed: • There are 5 or so distinct module types (out of 26 so far) • But lots of different variations on each theme 31
  • 32. Why so many modules? • Whipupitude • Low barrier to entry for CPAN • Hard to find (all) appropriate modules • Easier to upload than contribute or take over • Playing with Perl is fun (eg constants, dependencies) 32
  • 33. Review #7 Making HTTP requests Modules for making HTTP requests (GET, POST, PUT, DELETE, etc) Excluding higher-level modules like WWW::Mechanize 33
  • 34. Modules for making HTTP requests The only module I've given up on 34
  • 35. Performance on GET requests 35
  • 36. Runtime dependencies Require a C library Requires a C library and Moose! 36
  • 37. What module to use? 37
  • 38. Review #8 LUHN check Modules for checking credit card numbers 38
  • 39. Modules for checking CC numbers 39
  • 40. Performance of LUHN modules Moose? 40
  • 41. Review #9 Getting a module's path Modules for finding where a module has been installed locally, preferably without having to load the module 41
  • 42. Modules for getting a module's path 42
  • 46. Appropriate # of dependencies 46
  • 48. What do people use CPAN for? • Sharing code with others! • Configuration management • A cloud-based store for configuration (Task::BeLike::*) • A transport mechanism • A todo list (egBusiness::BankCard) • A blog / dumping ground for ideas • None of the above (ACME::*) 48
  • 49. Version numbers • Version numbers should be designed for humans • PAUSE just wants them to be monotonically increasing • All modules in a dist should have 0.01 • A version number 0.004 • The same version number 1.121660 0.0.20 • Don't be afraid of 1.x 0.6.1 5 • 73% of dists on CPAN are version 0.* 0.000 0.001005 • our $VERSION = '0.01'; v0.0.3 2.4 6632 2011121001 49
  • 50. How can you tell a good module? • Version number • But see Net::HTTP::Tiny v0.01 • Recently updated • Some modules are 'finished' • Volume and/or quality of documentation • See Crypt::RandPasswd • Number of bugs • Some big hitters have a long list though… • Number of dependent modules • from different authors • Ratings / +1's • Perl::Critic • Author • All of the above, and more 51
  • 51. How have I changed as a result? • I've learned new things, & new ways to do things, & … • I do developer releases & pay a lot more attention to CPAN Testers • I'm more paranoid • I benchmark and profile • I use IRC, and have had only positive experiences • How I export functions (thank-you Zefram) • How I think about dependencies • Moose / Mouse / Moo • I'm a lot more circumspect about releasing code to CPAN • Beginner's mind 52
  • 52. My review process • Quickly skim and find initial set of modules • Start writing sections for each module • Write generic SYNOPSIS style example, and evolve it as I go along • Report bugs and documentation issues as I go • First sketch at benchmarking & comparing • More thorough search for modules to include • Email the authors, give them a chance to comment • Publish first version • Iterate as people point out modules that I've missed 54
  • 53. It's easy – why not give it a go? % mkdir json % cd json % cat > module-list.txt JSON JSON::DWIW JSON::JOM JSON::Parse JSON::Syck JSON::Tiny JSON::Util JSON::XS JSON::YAJL JSON::Streaming::Reader JSON::Streaming::Writer Mojo::JSON Pegex::JSON Test::JSON ^D % cpan-review 55
  • 54. What do I want you to do? • Stop and search CPAN before writing code • Ok, I accept it's hard to find (all of the) relevant modules for a task • Just because you wrote it, you don't have to upload it • Only release if it's needed for another module, or another user • Put it on github • Write an article about it on blogs.perl.org • Add links to similar modules in SEE ALSO • MetaCPAN will include those in search results • It's helpful for users • You'll make my life easier • Write a helpful ABSTRACT in your NAME section • "a perl interface to foolib" • "the hardest working two letters in Perl" 56
  • 55. Review-related todo list • Related to existing reviews • Fix Crypt::RandPasswd • Configurability for Lingua::EN::Numbers • User-Agent module with Olaf • New constant module: Exporter::Constants • Dependencies: +5 modules to review, my module, curation • HTTP requests: Mojo::UserAgent, async request modules • Changes to Business::CCCheck • New reviews in progress • Hash objects • JSON • Module loading 57
  • 56. Finding modules is hard • Thinking about trying automatic clustering • Help identify groups of modules for review • Possible contribution to MetaCPAN • Automatic tagging of modules • Use keywords field in metadata 58