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
0
61
Boulder Startup Week: What is functional programming?
Brian McKenna
May 13, 2014
Tweet
Share
More Decks by Brian McKenna
See All by Brian McKenna
Production PureScript
puffnfresh
0
79
PureScript
puffnfresh
2
580
LambdaConf: Idris Workshop
puffnfresh
2
120
Other Decks in Programming
See All in Programming
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
200
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
180
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
快速入門可觀測性
blueswen
0
350
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
From Translations to Multi Dimension Entities
alexanderschranz
2
130
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
130
fs2-io を試してたらバグを見つけて直した話
chencmd
0
230
競技プログラミングへのお誘い@阪大BOOSTセミナー
kotamanegi
0
360
php-conference-japan-2024
tasuku43
0
260
선언형 UI에서의 상태관리
l2hyunwoo
0
160
PSR-15 はあなたのための ものではない? - phpcon2024
myamagishi
0
110
Featured
See All Featured
Code Reviewing Like a Champion
maltzj
520
39k
Bash Introduction
62gerente
608
210k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
5
450
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Embracing the Ebb and Flow
colly
84
4.5k
Side Projects
sachag
452
42k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
The Cost Of JavaScript in 2023
addyosmani
45
7k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
GitHub's CSS Performance
jonrohan
1030
460k
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!