103

Click here to load reader

Haskell is Not For Production and Other Tales

Embed Size (px)

Citation preview

Page 1: Haskell is Not For Production and Other Tales

Haskell is Not For Production

and Other Tales

by Katie Miller (@codemiller) Software Engineer at Facebook

Page 2: Haskell is Not For Production and Other Tales
Page 3: Haskell is Not For Production and Other Tales

So what do you code in?

Page 4: Haskell is Not For Production and Other Tales

Oh Pascal, cool

Page 5: Haskell is Not For Production and Other Tales

Wait...what? You have Haskell in prod?

Page 6: Haskell is Not For Production and Other Tales
Page 7: Haskell is Not For Production and Other Tales
Page 8: Haskell is Not For Production and Other Tales

more than 1 million requests/second

Page 9: Haskell is Not For Production and Other Tales

Haskell is

Page 10: Haskell is Not For Production and Other Tales

academicHaskell is

Page 11: Haskell is Not For Production and Other Tales

difficultHaskell is

Page 12: Haskell is Not For Production and Other Tales

panaceanHaskell is

Page 13: Haskell is Not For Production and Other Tales
Page 14: Haskell is Not For Production and Other Tales

Haxl

Page 15: Haskell is Not For Production and Other Tales
Page 16: Haskell is Not For Production and Other Tales
Page 17: Haskell is Not For Production and Other Tales
Page 18: Haskell is Not For Production and Other Tales
Page 19: Haskell is Not For Production and Other Tales
Page 20: Haskell is Not For Production and Other Tales
Page 21: Haskell is Not For Production and Other Tales

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)  

Page 22: Haskell is Not For Production and Other Tales

efficient data fetching

Page 23: Haskell is Not For Production and Other Tales

   {-­‐#  LANGUAGE  ApplicativeDo  #-­‐}  

   friendsLikePython  =  do          friends  <-­‐  getFriends          pyFriends  <-­‐  filterM  likesPython  friends          return  (length  pyFriends  >=              length  friends  `div`  2)

Page 24: Haskell is Not For Production and Other Tales

open source

Page 25: Haskell is Not For Production and Other Tales

Haskell is academic

Page 26: Haskell is Not For Production and Other Tales

Source: https://xkcd.com/1312

Page 29: Haskell is Not For Production and Other Tales

Haskell came from academia

Page 31: Haskell is Not For Production and Other Tales
Page 32: Haskell is Not For Production and Other Tales
Page 33: Haskell is Not For Production and Other Tales

Haskell is used in industry

Page 34: Haskell is Not For Production and Other Tales

AT&T

Barclays

Facebook

Google

Microsoft

New York Times

Standard Chartered

Page 37: Haskell is Not For Production and Other Tales

why Haskell

Page 38: Haskell is Not For Production and Other Tales

reasoning about code

Page 39: Haskell is Not For Production and Other Tales

purity

Page 40: Haskell is Not For Production and Other Tales

strong static typing

Page 41: Haskell is Not For Production and Other Tales

userHasAssoc  ::  Int  -­‐>  Int  -­‐>  Haxl  Bool  userHasAssoc  assoc  target  =  ...

Page 42: Haskell is Not For Production and Other Tales

userHasAssoc  ::  Int  -­‐>  Int  -­‐>  Haxl  Bool  userHasAssoc  assoc  target  =  ...

newtype  Id  =  Id  Int  newtype  AssocId  =  AssocId  Int

Page 43: Haskell is Not For Production and Other Tales

userHasAssoc  ::  Int  -­‐>  Int  -­‐>  Haxl  Bool  userHasAssoc  assoc  target  =  ...

newtype  Id  =  Id  Int  newtype  AssocId  =  AssocId  Int

userHasAssoc  ::  AssocId  -­‐>  Id  -­‐>  Haxl  Bool  userHasAssoc  assoc  target  =  ...

Page 45: Haskell is Not For Production and Other Tales

Haskell performs

Page 46: Haskell is Not For Production and Other Tales

Haskell is difficult

Page 47: Haskell is Not For Production and Other Tales

Haskell is difficult to learn

Page 48: Haskell is Not For Production and Other Tales

Haskell is difficult to debug

Page 49: Haskell is Not For Production and Other Tales

Haskellers are difficult to hire

Page 50: Haskell is Not For Production and Other Tales

Haskellers are difficult

Page 51: Haskell is Not For Production and Other Tales

Haskell is difficult to learn

Page 52: Haskell is Not For Production and Other Tales

Source: https://m.imgur.com/E7zzQ3z

Page 53: Haskell is Not For Production and Other Tales

Haskell is difficult

Page 54: Haskell is Not For Production and Other Tales

Haskell is different

Page 55: Haskell is Not For Production and Other Tales

expectations

Page 56: Haskell is Not For Production and Other Tales

abstraction

Page 57: Haskell is Not For Production and Other Tales

Source: http://i.imgur.com/TTBBeJs.jpg

Page 58: Haskell is Not For Production and Other Tales

"FP is simple. The core ideas are simple. Abstraction can be hard.

It doesn't mean it's not worth learning." - John Hughes

Page 59: Haskell is Not For Production and Other Tales
Page 60: Haskell is Not For Production and Other Tales
Page 61: Haskell is Not For Production and Other Tales

increases productivity

Page 62: Haskell is Not For Production and Other Tales

vim

Page 63: Haskell is Not For Production and Other Tales

dozens learnt Haxl in three days

Page 64: Haskell is Not For Production and Other Tales

we didn't mention monads

Page 65: Haskell is Not For Production and Other Tales
Page 66: Haskell is Not For Production and Other Tales
Page 67: Haskell is Not For Production and Other Tales
Page 68: Haskell is Not For Production and Other Tales

Haskell is difficult to debug

Page 69: Haskell is Not For Production and Other Tales

the cost of laziness

Page 70: Haskell is Not For Production and Other Tales

replayability

Page 71: Haskell is Not For Production and Other Tales

Haskellers are difficult to hire

Page 72: Haskell is Not For Production and Other Tales

embarrassment of riches

Page 73: Haskell is Not For Production and Other Tales

developers can learn Haskell

Page 74: Haskell is Not For Production and Other Tales

Haskellers are difficult

Page 75: Haskell is Not For Production and Other Tales

Source: https://xkcd.com/1270

Page 76: Haskell is Not For Production and Other Tales

elitism

Page 77: Haskell is Not For Production and Other Tales

intellectual territoriality

Page 78: Haskell is Not For Production and Other Tales

no respect

Page 79: Haskell is Not For Production and Other Tales

why

Page 80: Haskell is Not For Production and Other Tales

jargon

Page 81: Haskell is Not For Production and Other Tales

unthinking or pretentious

Page 82: Haskell is Not For Production and Other Tales
Page 83: Haskell is Not For Production and Other Tales

documentation

Page 84: Haskell is Not For Production and Other Tales

community

Page 85: Haskell is Not For Production and Other Tales

Haskell is panacean

Page 86: Haskell is Not For Production and Other Tales

Source: https://i.imgur.com/Sex1E8m.jpg

Page 87: Haskell is Not For Production and Other Tales

bad Haskell code

Page 88: Haskell is Not For Production and Other Tales

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"

Page 89: Haskell is Not For Production and Other Tales

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"

Page 91: Haskell is Not For Production and Other Tales

what programmers think in

Page 92: Haskell is Not For Production and Other Tales

half technology and half religion

Page 93: Haskell is Not For Production and Other Tales

legacy of influence

Page 94: Haskell is Not For Production and Other Tales

Haskell is academic and practical

Page 95: Haskell is Not For Production and Other Tales

Haskell is different; that brings benefits and challenges

Page 96: Haskell is Not For Production and Other Tales

Haskell is a tool, not utopia

Page 97: Haskell is Not For Production and Other Tales

open source = opportunity

Page 98: Haskell is Not For Production and Other Tales

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

Page 99: Haskell is Not For Production and Other Tales

Image credits

Story Time (Elliot Margolies, CC BY-NC-ND 2.0)

Page 102: Haskell is Not For Production and Other Tales

Haskell is for production

Page 103: Haskell is Not For Production and Other Tales

Haskell is for production

The End