This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
420 lines (368 loc) · 11.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Why Functional Programming Matters</title>
<meta name="description" content="Our Definition of Functional Programming">
<meta name="author" content="Adam Wall and Andy Czerwonka">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match(/print-pdf/gi) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName('head')[0].appendChild(link);
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>Welcome to Functional Programmers YYC!</h1>
<h3>What is Functional Programming & Why Does It Matter?</h3>
</section>
<section data-background="#2B3E63">
<section>
<h2>Andy Czerwonka</h2>
<h2>Adam Wall</h2>
</section>
<section>
<h2>Why this Meetup?</h2>
<blockquote>
“If you want everything to be familiar you will never learn anything new.”
</blockquote>
- <b>Rich Hickey (Author of Clojure)</b>
</section>
<section>
<h2>Who's With Us?</h2>
<ul>
<li>Meetup.com, LinkedIn, Twitter, Gilt, Ticketfly, Foursquare</li>
<li>AT&T, Bank of America, Jane Street, Intel, NVIDIA, IGN</li>
<li>SAP, Xerox, Novell, Sony, Siemens, Netflix, Tumblr, eBay</li>
<li>Facebook, Bloomberg, Citrix, Walmart, Coursera, White Pages, The Huffington Post</li>
</ul>
</section>
<section>
<h2>Why Are They With Us?</h2>
<ul>
<li>Amdahl's Law</li>
<li>Brevity</li>
<li>Language Proliferation</li>
</ul>
</section>
</section>
<section data-background="#004200">
<section>
<h2>What is functional programming?</h2>
<p>
We construct our programs using only pure functions—in other words, functions that have no side effects or functions that are referentially transparent.
</p>
<p>
Same Input. Same Output. Every time.
</p>
</section>
<section>
<h2>We're Not Going to Talk About</h2>
<ul>
<li>Morphisms</li>
<li>Functors</li>
<li>Monads</li>
<li>Co-monads</li>
<li>Zippers</li>
<li>Applicatives</li>
<li>Lenses</li>
<li>Typeclasses</li>
</ul>
</section>
<section>
<h2>Let's Talk About</h2>
<ul>
<li>declarative</li>
<li>immutability</li>
<li>higher-order functions</li>
<li>algebraic data types</li>
<li>laziness</li>
</ul>
</section>
<section>
<h2>Let's Talk About</h2>
<ul>
<li>what, not how</li>
<li>reasoning</li>
<li>reusability</li>
<li>correctness</li>
<li>performance</li>
</ul>
</section>
<section>
<h2>Languages</h2>
<blockquote>
“The language that does not affect the way you think about programming, is not worth knowing.”
</blockquote>
- <b>Alan Perlis</b>
</section>
<section>
<h2>Languages</h2>
<ul>
<li>Haskell</li>
<li>Scala</li>
<li>OCaml</li>
<li>Clojure</li>
<li>F#</li>
</ul>
</section>
<section>
<h2>Languages</h2>
<blockquote>
“No matter what language you work in, programming in a functional style provides benefits. You should do it whenever it is convenient, and you should think hard about the decision when it isn't convenient.”
</blockquote>
- <b>John Carmack, ID Software</b>
</section>
<section>
<h2>and recently...</h2>
<ul>
<li>Java</li>
<li>Javascript</li>
<li>C#</li>
<li>C++</li>
</ul>
</section>
</section>
<section data-background="#400000">
<section>
<h2>Immutabilty</h2>
<ul>
<li>Avoiding Temporal Coupling</li>
<li>Failure Atomicity</li>
<li>Thread Safety</li>
</ul>
</section>
<section>
<h2>Persistent Data Structures</h2>
<p>
Immutable data structures facilitate sharing data amongst otherwise isolated tasks in an efficient zero-copy manner. No synchronization necessary. This is the real payoff.
</p>
<ul>
<li>Fat Node</li>
<li>Path Copying</li>
<li>etc</li>
</ul>
<p>
Don't be scared of using them.
</p>
</section>
<section>
<h2>Immutable Looping</h2>
<img src="https://s3.amazonaws.com/media-p.slid.es/uploads/rajeevbharshetty/images/490584/download__1_.jpg">
</section>
<section>
<h2>Immutable Looping</h2>
<pre><code data-trim>
def reverse(s: String): String = { // (1)
if (s == null) return null // (2)
if (s.tail.isEmpty) return s // (3)
reverse(s.tail) + s.head // (4)
}
</code></pre>
<ol>
<li>String => String</li>
<li>Error case -> null is starting value</li>
<li>Base case -> no more characters</li>
<li>Recursion case -> everything else</li>
</ol>
</section>
</section>
<section data-background="#2B0047">
<section>
<h2>High-Order Functions</h2>
<p>
A function that has a value with a function type as an input parameter or return value.
</p>
</section>
<section>
<h2>You've Used It</h2>
Given the following function definitions
<pre><code data-trim>
def map[B](f: A => B): List[B]
def filter(f: A => Boolean): List[A]
</code></pre>
We've probably all written something like this
<pre><code data-trim>
xs.filter(i => i > 5).map(i => i * 2)
</code></pre>
Which is the same as
<pre><code data-trim>
xs.filter(_ > 5).map(_ * 2)
</code></pre>
Which is the same as
<pre><code data-trim>
def double(i: Int) = i * 2
xs.filter(_ > 5).map(double)
</code></pre>
</section>
<section>
<h2>Better Abstraction</h2>
<pre><code data-trim>
def safeStringOp(s: String, f: String => String) = {
if (s != null) f(s) else s
}
def reverser(s: String) = s.reverse
def capitalizer(s: String) = s.capitalize
</code></pre>
Now I can reuse both methods in a safe way
<pre><code data-trim>
safeStringOp("money", capitalizer) // Money
safeStringOp("money", reverser) // yenom
safeStringOp(null, reverser) // null
</code></pre>
</section>
<section>
<h2>Defining Control Structures</h2>
<pre><code data-trim>
def using[A <: { def close(): Unit }, B](param: A)(f: A => B): B =
try {
f(param)
} finally {
param.close()
}
}
</code></pre>
<pre><code data-trim>
using(Database.getConnection) { conn =>
DaoFactory(conn).save(data)
}
</code></pre>
Connection has a close() method so it's legal to use here.
</section>
</section>
<section>
<section>
<h2>Algebraic Data Types</h2>
<ul>
<li>not strictly "functional"</li>
<li>best use of pattern matching</li>
<li>no more NullPointerExceptions!</li>
</ul>
</section>
<section>
<h2>The Algebra in Algebraic Data Types</h2>
<ul>
<li>sums vs products</li>
<li>most languages have product types, but not sum types</li>
<p>A struct in C is a product type:
<pre><code data-trim>struct Point { int x; int y; };</code></pre>
Maybe (Haskell) is a sum type:
<pre><code data-trim>data Maybe a = Nothing | Just a</code></pre>
</section>
<section>
<h2>Why sums matter</h2>
<ul>
<li>
<q>Make the bad state <i>unrepresentable</i>
</q>
</li>
<li>eliminate entire classes of errors</li>
<li>better refactoring</li>
<pre><code data-trim>Person p = findPerson(name);
if (p != null) {
deductTaxes(p);
} else {
notifyHrNonExistant(name);
}</code></pre>
vs
<pre><code data-trim>case findPerson name of
Just p -> deductTaxes p
Nothing -> notifyHrNonExistant name</code></pre>
<li>Jane Street: <a href="https://www.youtube.com/watch?v=DM2hEBwEWPc">Effective ML</a>
</li>
</ul>
</section>
<section>
<h2>Simulating Algebraic Data Types</h2>
<ul>
<li>convention: null, -1, exceptions</li>
<li>tagged unions</li>
<li>subclassing: the visitor pattern</li>
</ul>
</section>
</section>
<section>
<h2>Laziness</h2>
<ul>
<li>Haskell is special, lazy by default</li>
<li><a href="https://www.youtube.com/watch?v=vos_D8bdoUE">Erik Meijer intro to lazy</a>
<li>infinite lists, generators (fibonacci)</li>
<li>control structures</li>
<li>related: currying</li>
<li>hidden efficiency?</li>
<li>lazy by default = declarative by default (FRP)</li>
<li>drawback: non-local speed and space analysis</li>
</ul>
</section>
<section data-background="#663D15">
<h2>Thanks Everyone for Coming</h2>
<ul>
<li>Door Prize</li>
<li>Discuss Next Meeting Topics</li>
</ul>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [{
src: 'lib/js/classList.js',
condition: function() {
return !document.body.classList;
}
}, {
src: 'plugin/markdown/marked.js',
condition: function() {
return !!document.querySelector('[data-markdown]');
}
}, {
src: 'plugin/markdown/markdown.js',
condition: function() {
return !!document.querySelector('[data-markdown]');
}
}, {
src: 'plugin/highlight/highlight.js',
async: true,
condition: function() {
return !!document.querySelector('pre code');
},
callback: function() {
hljs.initHighlightingOnLoad();
}
}, {
src: 'plugin/zoom-js/zoom.js',
async: true
}, {
src: 'plugin/notes/notes.js',
async: true
}]
});
</script>
</body>
</html>