Click here to load reader
Upload
katie-ots
View
6.747
Download
2
Embed Size (px)
Citation preview
Haskell is Not For Production
and Other Tales
by Katie Miller (@codemiller) Software Engineer at Facebook
So what do you code in?
Oh Pascal, cool
Wait...what? You have Haskell in prod?
more than 1 million requests/second
Haskell is
academicHaskell is
difficultHaskell is
panaceanHaskell is
Haxl
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)
efficient data fetching
{-‐# LANGUAGE ApplicativeDo #-‐}
friendsLikePython = do friends <-‐ getFriends pyFriends <-‐ filterM likesPython friends return (length pyFriends >= length friends `div` 2)
open source
Haskell is academic
Source: https://xkcd.com/1312
Source: Bitcheese.net
Source: Bitcheese.net
Haskell came from academia
Source: A History of Haskell: Being Lazy With Class
Haskell is used in industry
AT&T
Barclays
Microsoft
New York Times
Standard Chartered
AT&T
Barclays
Microsoft
New York Times
Standard Chartered
CircuitHub
Fynder
Hasura
Helium
Pusher
Scrive
Wagon
Source: Hacker News
why Haskell
reasoning about code
purity
strong static typing
userHasAssoc :: Int -‐> Int -‐> Haxl Bool userHasAssoc assoc target = ...
userHasAssoc :: Int -‐> Int -‐> Haxl Bool userHasAssoc assoc target = ...
newtype Id = Id Int newtype AssocId = AssocId Int
userHasAssoc :: Int -‐> Int -‐> Haxl Bool userHasAssoc assoc target = ...
newtype Id = Id Int newtype AssocId = AssocId Int
userHasAssoc :: AssocId -‐> Id -‐> Haxl Bool userHasAssoc assoc target = ...
abstract away from concurrency
Haskell performs
Haskell is difficult
Haskell is difficult to learn
Haskell is difficult to debug
Haskellers are difficult to hire
Haskellers are difficult
Haskell is difficult to learn
Source: https://m.imgur.com/E7zzQ3z
Haskell is difficult
Haskell is different
expectations
abstraction
Source: http://i.imgur.com/TTBBeJs.jpg
"FP is simple. The core ideas are simple. Abstraction can be hard.
It doesn't mean it's not worth learning." - John Hughes
increases productivity
vim
dozens learnt Haxl in three days
we didn't mention monads
Haskell is difficult to debug
the cost of laziness
replayability
Haskellers are difficult to hire
embarrassment of riches
developers can learn Haskell
Haskellers are difficult
Source: https://xkcd.com/1270
elitism
intellectual territoriality
no respect
why
jargon
unthinking or pretentious
documentation
community
Haskell is panacean
Source: https://i.imgur.com/Sex1E8m.jpg
bad Haskell code
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"
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"
Source: Twitter
what programmers think in
half technology and half religion
legacy of influence
Haskell is academic and practical
Haskell is different; that brings benefits and challenges
Haskell is a tool, not utopia
open source = opportunity
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
Image credits
Story Time (Elliot Margolies, CC BY-NC-ND 2.0)
ReferencesBen 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
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
Haskell is for production
Haskell is for production
The End