Giving LWP its well deserved golden watch

Giving LWP its well deserved golden watch

Examine the history of LWP, consider 4 alternatives and discuss some features of the various alternatives.

7330b65ea54e1b90a987a552e5c5cf32?s=128

Mark Allen

July 24, 2013
Tweet

Transcript

  1. Giving LWP::UserAgent ! Its Well Deserved ! Golden Watch! !

    ! Mark Allen! mrallen1@yahoo.com! @bytemeorg! http://byte-me.org! https://github.com/mrallen1! https://speakerdeck.com/mrallen1!
  2. Talk Goals! •  HTTP client history! •  Compare alternatives! • 

    Choose a client with a good fit for your problem space!
  3. HTTP client history! Pop quiz:! ! Who wrote and maintained

    libwww-perl for Perl 4?!
  4. HTTP client history! Anyone?! !

  5. HTTP client history! Anyone?! ! Bueller?! !

  6. HTTP client history!

  7. HTTP client history! Roy Fielding!

  8. HTTP client history! Roy Fielding! Invented REST ! Apache Foundation

    Chair!
  9. HTTP client history! Perl  5  released  (Oct  1994)   LWP

     (for  Perl  5)  0.01  (Jul  '95)   CPAN  introduced  (Oct  '95)   LWP::UserAgent  sugar  (May  2001)   Handlers   (Sep  2008)  
  10. HTTP client history! We owe LWP a debt because Gisle

    and others pioneered scripted user agents...!
  11. HTTP client history! ...and a lot has changed.!

  12. LWP alternatives! •  Why?! •  Alternatives:! •  Mojo::UserAgent! •  HTTP::Tiny!

    •  Furl! •  LWP::Curl!
  13. LWP alternatives! 1.  Performance / Speed!

  14. LWP alternatives! 1.  Performance / Speed! 2.  Improved SSL support!

  15. LWP alternatives! 1.  Performance / Speed! 2.  Improved SSL support!

    3.  Features!
  16. LWP alternatives! 1.  Performance / Speed! 2.  Improved SSL support!

    3.  Features! 4.  Syntactic sugar!
  17. None
  18. Pop quiz:! ! What does Rutherford B. Hayes have to

    do with HTTP client libraries?!
  19. Requests per second! 0   2000   4000   6000

      8000   10000   12000   14000   16000   18000   Simple  GET   100k  GET   POST   hQps://github.com/mrallen1/perl-­‐UA-­‐Bench  
  20. LWP alternatives! •  Mojo::UserAgent! •  HTTP::Tiny! •  Furl! •  LWP::Curl!

  21. Mojo::UserAgent! •  Built in DOM, XML, JSON parsing! •  Pure

    perl - 5.8 and later! •  Mind blowing one-liners!
  22. Mojo::UserAgent! •  SSL, cookies and! •  Thin object layer (Mojo::Base)!

    •  Maybe don't want the rest of the Mojolicious stack!
  23. None
  24. Mojo::UserAgent! perl -C -S -MTime::Piece -Mojo -E '$i=1; mkdir $dir=$ENV{HOME}!

    ."/tunes.io/".localtime->ymd; ! say $_->text and g($_->attrs("href"))! ->max_message_size(25600000)! ->content->asset->move_to! ("$dir/${\$i++} ${\$_->text}.mp3") for g("tunes.io")->dom("ul a")->each'!
  25. Mojo::UserAgent! perl -C -S -MTime::Piece -Mojo -E '$i=1; mkdir $dir=$ENV{HOME}!

    ."/tunes.io/".localtime->ymd; ! say $_->text and g($_->attrs("href"))! ->max_message_size(25600000)! ->content->asset->move_to! ("$dir/${\$i++} ${\$_->text}.mp3") for g("tunes.io")->dom("ul a")->each'!
  26. Mojo::UserAgent! perl -C -S -MTime::Piece -Mojo -E '$i=1; mkdir $dir=$ENV{HOME}!

    ."/tunes.io/".localtime->ymd; ! say $_->text and g($_->attrs("href"))! ->max_message_size(25600000)! ->content->asset->move_to! ("$dir/${\$i++} ${\$_->text}.mp3") for g("tunes.io")->dom("ul a")->each'!
  27. Mojo::UserAgent! perl -C -S -MTime::Piece -Mojo -E '$i=1; mkdir $dir=$ENV{HOME}!

    ."/tunes.io/".localtime->ymd; ! say $_->text and g($_->attrs("href"))! ->max_message_size(25600000)! ->content->asset->move_to! ("$dir/${\$i++} ${\$_->text}.mp3") for g("tunes.io")->dom("ul a")->each'!
  28. Mojo::UserAgent! perl -C -S -MTime::Piece -Mojo -E '$i=1; mkdir $dir=$ENV{HOME}!

    ."/tunes.io/".localtime->ymd; ! say $_->text and g($_->attrs("href"))! ->max_message_size(25600000)! ->content->asset->move_to! ("$dir/${\$i++} ${\$_->text}.mp3") for g("tunes.io")->dom("ul a")->each'!
  29. Mojo::UserAgent! perl -C -S -MTime::Piece -Mojo -E '$i=1; mkdir $dir=$ENV{HOME}!

    ."/tunes.io/".localtime->ymd; ! say $_->text and g($_->attrs("href"))! ->max_message_size(25600000)! ->content->asset->move_to! ("$dir/${\$i++} ${\$_->text}.mp3") for g("tunes.io")->dom("ul a")->each'!
  30. LWP alternatives! •  Mojo::UserAgent! •  HTTP::Tiny! •  Furl! •  LWP::Curl!

  31. HTTP::Tiny! •  Comes with core perl (5.14)! •  Fulfills "::Tiny"

    promise! •  Easy SSL configuration! •  No request / response objects (see HTTP::Thin)! •  Pure perl!
  32. HTTP::Tiny! •  No request / response objects (see HTTP::Thin)! • 

    Pure perl! •  I use this one 90% of the time!
  33. LWP alternatives! •  Mojo::UserAgent! •  HTTP::Tiny! •  Furl! •  LWP::Curl!

  34. Furl! •  Japanese Perl community! •  Request / response objects!

    •  HTTP response parser uses XS (if possible)!
  35. Furl! •  Easy SSL configuration! •  Cookie support! •  Low

    level HTTP access if desired!
  36. LWP alternatives! •  Mojo::UserAgent! •  HTTP::Tiny! •  Furl! •  LWP::Curl!

  37. LWP::Curl! •  Curl is a great HTTP client library, but

    terrible interface.! •  LWPish interface on top of Net::Curl!
  38. LWP::Curl! •  Super fast! •  2000% faster than LWP! • 

    100% faster than Furl! •  No request/response objects! •  No cookie support! •  LWP::Protocol::Net::Curl!
  39. Fit your problem space!

  40. None
  41. Can you deploy XS?!

  42. Do you { want | need } ! built in

    JSON support?!
  43. Do you { want | need } ! built in

    JSON support?!
  44. Does your other code expect HTTP::Response objects?!

  45. Summary! •  LWP has been around as long as Perl

    itself.! •  There are a lot of great HTTP client choices, so compare alternatives.! •  Choose a client with a good fit for your problem space!
  46. Thank you!!