Haskell is Not For Production and Other Tales

6,767 views

Published on

Some say it was written exclusively for Unix-bearded wizards with PhDs. Some say only 10x programmers and unicorns can decipher its many operators. Some say any coding problem it touches will be saved from callback hell and find everlasting peace. The Haskell programming language has long been the subject of myths and misconceptions. Nonetheless it has been adopted by a slew of companies big and small, including Facebook, which has a large Haskell deployment and dozens of engineers using the language.

In this keynote, Katie will explore some of the pervasive stereotypes about the poster child of statically typed functional programming and compare and contrast them with her experiences working as a Haskell developer on the open-source Haxl project, which is used to fight spam at Facebook. As the former journalist investigates which stories stack up, she’ll share insights on what functional programming and Haskell have to offer, the challenges that come with their use, and where the ecosystem could be improved.

Published in: Software

Haskell is Not For Production and Other Tales

  1. 1. Haskell is Not For Production and Other Tales by Katie Miller (@codemiller) Software Engineer at Facebook
  2. 2. So what do you code in?
  3. 3. Oh Pascal, cool
  4. 4. Wait...what? You have Haskell in prod?
  5. 5. more than 1 million requests/second
  6. 6. Haskell is
  7. 7. academic Haskell is
  8. 8. difficult Haskell is
  9. 9. panacean Haskell is
  10. 10. Haxl
  11. 11. fpSpammer  ::  Haxl  Bool   fpSpammer  =        talkingAboutMonads  .&&      numFriends  .>  100  .&&      friendsLikePython      where      talkingAboutMonads  =          strContains  "monad"  <$>  postContent      friendsLikePython  =  do          friends  <-­‐  getFriends          pyFriends  <-­‐  filterM  likesPython  friends          return  (length  pyFriends  >=              length  friends  `div`  2)  
  12. 12. efficient data fetching
  13. 13.    {-­‐#  LANGUAGE  ApplicativeDo  #-­‐}      friendsLikePython  =  do          friends  <-­‐  getFriends          pyFriends  <-­‐  filterM  likesPython  friends          return  (length  pyFriends  >=              length  friends  `div`  2)
  14. 14. open source
  15. 15. Haskell is academic
  16. 16. Source: https://xkcd.com/1312
  17. 17. Source: Bitcheese.net
  18. 18. Source: Bitcheese.net
  19. 19. Haskell came from academia
  20. 20. Source: A History of Haskell: Being Lazy With Class
  21. 21. Haskell is used in industry
  22. 22. AT&T Barclays Facebook Google Microsoft New York Times Standard Chartered
  23. 23. AT&T Barclays Facebook Google Microsoft New York Times Standard Chartered CircuitHub Fynder Hasura Helium Pusher Scrive Wagon
  24. 24. Source: Hacker News
  25. 25. why Haskell
  26. 26. reasoning about code
  27. 27. purity
  28. 28. strong static typing
  29. 29. userHasAssoc  ::  Int  -­‐>  Int  -­‐>  Haxl  Bool   userHasAssoc  assoc  target  =  ...
  30. 30. userHasAssoc  ::  Int  -­‐>  Int  -­‐>  Haxl  Bool   userHasAssoc  assoc  target  =  ... newtype  Id  =  Id  Int   newtype  AssocId  =  AssocId  Int
  31. 31. userHasAssoc  ::  Int  -­‐>  Int  -­‐>  Haxl  Bool   userHasAssoc  assoc  target  =  ... newtype  Id  =  Id  Int   newtype  AssocId  =  AssocId  Int userHasAssoc  ::  AssocId  -­‐>  Id  -­‐>  Haxl  Bool   userHasAssoc  assoc  target  =  ...
  32. 32. abstract away from concurrency
  33. 33. Haskell performs
  34. 34. Haskell is difficult
  35. 35. Haskell is difficult to learn
  36. 36. Haskell is difficult to debug
  37. 37. Haskellers are difficult to hire
  38. 38. Haskellers are difficult
  39. 39. Haskell is difficult to learn
  40. 40. Source: https://m.imgur.com/E7zzQ3z
  41. 41. Haskell is difficult
  42. 42. Haskell is different
  43. 43. expectations
  44. 44. abstraction
  45. 45. Source: http://i.imgur.com/TTBBeJs.jpg
  46. 46. "FP is simple. The core ideas are simple. Abstraction can be hard. It doesn't mean it's not worth learning." - John Hughes
  47. 47. increases productivity
  48. 48. vim
  49. 49. dozens learnt Haxl in three days
  50. 50. we didn't mention monads
  51. 51. Haskell is difficult to debug
  52. 52. the cost of laziness
  53. 53. replayability
  54. 54. Haskellers are difficult to hire
  55. 55. embarrassment of riches
  56. 56. developers can learn Haskell
  57. 57. Haskellers are difficult
  58. 58. Source: https://xkcd.com/1270
  59. 59. elitism
  60. 60. intellectual territoriality
  61. 61. no respect
  62. 62. why
  63. 63. jargon
  64. 64. unthinking or pretentious
  65. 65. documentation
  66. 66. community
  67. 67. Haskell is panacean
  68. 68. Source: https://i.imgur.com/Sex1E8m.jpg
  69. 69. bad Haskell code
  70. 70. blockAustralians  ::  Haxl  SyncResponses   blockAustralians  =  do      textMap  <-­‐  textArr      let  text  =  HashMap.lookupDefault  ""  "main_text"  textMap              numBadWords      =  length  $  filter  (`Text.isInfixOf`  text)  aussieTerms              numBadPhrases  =  length  $  filter  (`Text.isInfixOf`  text)  aussieSayings      if  numBadWords  <  2  &&  numBadPhrases  <=  0      then  return  noResponses      else              if  numBadWords  <  4  &&  numBadPhrases  <  2              then  return  requireCaptcha              else                      if  numBadWords  <  5  &&  numBadPhrases  <  3                      then  return  $  responses  [warnUser,  requireCaptcha]                      else                              if  numBadWords  <  7  &&  numBadPhrases  <  4                              then  return  warnUser                              else                                      if  numBadWords  <  8  &&  numBadPhrases  <  5                                      then  return  $  responses  [warnUser,  blockAccess]                                      else                                              if  numBadWords  <  10  &&  numBadPhrases  <  6                                              then  return  blockAccess                                              else                                                      if  numBadWords  <  13  &&  numBadPhrases  <  7                                                      then  return  $  responses                                                                        [  blockAccess                                                                        ,  enrollInFakeAccountCheckpoint                                                                        ]                                                      else  return  $  responses                                                                        [  blockAccess                                                                        ,  enrollInFakeAccountCheckpoint                                                                        ,  requireCaptcha                                                                        ]          where              aussieTerms  =                      [  "Acca  Dacca"                      ,  "ambo"                      ,  "arvo"                      ,  "Aussie"                      ,  "bangaroo"
  71. 71. blockAustralians  ::  Haxl  SyncResponses   blockAustralians  =  do      textMap  <-­‐  textArr      let  text  =  HashMap.lookupDefault  ""  "main_text"  textMap              numBadWords      =  length  $  filter  (`Text.isInfixOf`  text)  aussieTerms              numBadPhrases  =  length  $  filter  (`Text.isInfixOf`  text)  aussieSayings      if  numBadWords  <  2  &&  numBadPhrases  <=  0      then  return  noResponses      else              if  numBadWords  <  4  &&  numBadPhrases  <  2              then  return  requireCaptcha              else                      if  numBadWords  <  5  &&  numBadPhrases  <  3                      then  return  $  responses  [warnUser,  requireCaptcha]                      else                              if  numBadWords  <  7  &&  numBadPhrases  <  4                              then  return  warnUser                              else                                      if  numBadWords  <  8  &&  numBadPhrases  <  5                                      then  return  $  responses  [warnUser,  blockAccess]                                      else                                              if  numBadWords  <  10  &&  numBadPhrases  <  6                                              then  return  blockAccess                                              else                                                      if  numBadWords  <  13  &&  numBadPhrases  <  7                                                      then  return  $  responses                                                                        [  blockAccess                                                                        ,  enrollInFakeAccountCheckpoint                                                                        ]                                                      else  return  $  responses                                                                        [  blockAccess                                                                        ,  enrollInFakeAccountCheckpoint                                                                        ,  requireCaptcha                                                                        ]          where              aussieTerms  =                      [  "Acca  Dacca"                      ,  "ambo"                      ,  "arvo"                      ,  "Aussie"                      ,  "bangaroo"
  72. 72. Source: Twitter
  73. 73. what programmers think in
  74. 74. half technology and half religion
  75. 75. legacy of influence
  76. 76. Haskell is academic and practical
  77. 77. Haskell is different; that brings benefits and challenges
  78. 78. Haskell is a tool, not utopia
  79. 79. open source = opportunity
  80. 80. Haxl team past and present Katie Miller Bartosz Nitka Jon Purdy Aaron Roth Zejun Wu Noam Zilberstein š Louis Brandy Jonathan Coens Andrew Farmer Kubo Kovác Jake Lengyel Simon Marlow
  81. 81. Image credits Story Time (Elliot Margolies, CC BY-NC-ND 2.0)
  82. 82. References Ben Ford, Haskell at Fynder David Crystal, The Story of 100 English Words From Zero to HIPster (Haskell in Production) Haskell in Industry Hudak et al, A History of Haskell: Being Lazy With Class Paul Graham, Beating the Averages Philip Wadler, Propositions as Types Sarah Sharp, What Makes a Good Community? Simon Yang, My Journey into Haskell
  83. 83. More about Haxl Haxl on GitHub 'Fighting spam with Haskell' blog post 'There is no Fork' ICFP paper and presentation 'The Road to Running Haskell at Facebook Scale' presentation Wired article
  84. 84. Haskell is for production
  85. 85. Haskell is for production The End

×