Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Boulder Startup Week: What is functional progra...
Search
Brian McKenna
May 13, 2014
Programming
70
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Boulder Startup Week: What is functional programming?
Brian McKenna
May 13, 2014
More Decks by Brian McKenna
See All by Brian McKenna
Production PureScript
puffnfresh
0
130
PureScript
puffnfresh
2
590
LambdaConf: Idris Workshop
puffnfresh
2
140
Other Decks in Programming
See All in Programming
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
1
220
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
190
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
380
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
2
280
自作OSでスライド発表する
uyuki234
1
3.9k
人間の目はかわらない、だからJPEGは30年もつ
yuzneri
1
590
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
16
3.6k
JAWS-UG横浜 #102 AWSサ終供養LT会 成仏できない AWS サービスたち 〜本日、三体供養します〜
maroon1st
0
230
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
160
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
110
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
180
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
390
Featured
See All Featured
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.2k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.5k
Leo the Paperboy
mayatellez
8
1.9k
Why Our Code Smells
bkeepers
PRO
340
58k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
190
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
660
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Abbi's Birthday
coloredviolet
3
8.8k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.1k
Transcript
FUNCTIONAL PROGRAMMING
WHAT ARE FUNCTIONS?
▸ A relation from a set to a set {(true,
false), (false, true), (false, false)} ▸ One output object for every input {(true, false), (false, true)}
ACTUAL FUNCTIONS
boolean not(boolean b) { return !b; } String hello(String s)
{ return "Hello " + s; }
NOT FUNCTIONS
System.out.println("Hello world"); System.getTimeMillis(); x = x + 1; boolean update(int
j) { i += j; return j + 1; }
... functional programming is a restriction on how we write
programs, but not on what programs we can express. — Rúnar Bjarnason and Paul Chiusano, Functional Programming in Scala, 2014
EQUATIONAL REASONING
main :: IO () main = print $ sum [1,
2, 3] sum :: [Int] -> Int sum = foldl (+) 0 foldl :: (Int -> Int -> Int) -> Int -> [Int] -> Int foldl f z xs = go z xs where go z [] = z go z (x:xs) = go (f z x) xs
main :: IO () main = print $ sum [1,
2, 3] sum :: [Int] -> Int sum xs = go 0 xs where go z [] = z go z (x:xs) = go (z + x) xs
main :: IO () main = print sum' sum' ::
Int sum' = go 0 [1, 2, 3] where go z [] = z go z (x:xs) = go (z + x) xs
main :: IO () main = print sum' sum' ::
Int sum' = go (((0 + 1) + 2) + 3) [] where go z [] = z
main :: IO () main = print sum' sum' ::
Int sum' = (((0 + 1) + 2) + 3)
main :: IO () main = print sum' sum' ::
Int sum' = 6
main :: IO () main = print 6
NOT EQUATIONAL REASONING
val x = { println("Hello"); 1 } x + x
// Hello // 2
{ println("Hello"); 1 } + { println("Hello"); 1 } //
Hello // Hello // 2
PRINCIPLE OF COMPOSITIONALITY
Meaning of a complex statement is the combination of the
meanings of its parts.
COMPROMISING
Can we write partially functional programs?
TOOLS
▸ Haskell ▸ ML ▸ Scala ▸ F#
GO WRITE FUNCTIONS!