3 <link rel=
"stylesheet" href=
"css/csshake.min.css">
4 <link rel=
"stylesheet" href=
"css/animate.css">
5 <link href=
"https://fonts.googleapis.com/css?family=Press+Start+2P&display=swap" rel=
"stylesheet">
7 href=
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/styles/atom-one-dark.min.css">
8 <script src=
"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.18.1/highlight.min.js"></script>
9 <script>hljs.initHighlightingOnLoad();
</script>
10 <title>Wide-Eyed Crazy Functional Programming
</title>
14 font-family: 'Press Start
2P', cursive;
18 background-color: #f98012;
19 background-image: url(
"img/tile.png");
20 background-repeat: repeat;
22 image-rendering: crisp-edges;
23 background-position-x: -
33px;
24 background-blend-mode: multiply;
34 letter-spacing: -
20px;
35 transform: rotate(
90deg) scale(
1,
1.5);
43 font-family: 'Press Start
2P', cursive;
44 text-shadow:
2px
2px
0 #
000;
50 text-shadow:
2px
2px
0 #
000;
56 text-shadow:
10px
10px
0 #
00000069;
62 box-shadow:
10px
10px
0 #
00000069;
65 background: #
6187a8e3;
70 justify-content: center;
75 #cloudguy, #cloudguy2 {
78 justify-content: center;
91 justify-content: space-around;
110 #cgquotes, #cloudguy2
> div
> div {
112 text-shadow:
2px
2px
0 #
000;
125 image-rendering: optimizeSpeed; /* STOP SMOOTHING, GIVE ME SPEED */
126 image-rendering: -moz-crisp-edges; /* Firefox */
127 image-rendering: -o-crisp-edges; /* Opera */
128 image-rendering: -webkit-optimize-contrast; /* Chrome (and eventually Safari) */
129 image-rendering: pixelated; /* Chrome */
130 image-rendering: optimize-contrast; /* CSS3 Proposed */
131 -ms-interpolation-mode: nearest-neighbor; /* IE8+ */
138 #rant .shake-constant, .crazy, .span {
139 display: inline-block;
142 #rant .shake-opacity {
154 box-shadow:
10px
10px
0 #
00000069;
155 border:
2px solid black;
156 background-color: #
3f6382;
161 box-shadow:
10px
10px
0 #
00000069;
162 border:
2px solid black;
169 span[class^=
"code-friends"].on, span[class^=
"code-friends"].on
> span, span[class^=
"code-friends"].on
> span
> span {
170 color: #f98012 !important;
173 span[class^=
"promise"].on, span[class^=
"promise"].on
> span, span[class^=
"promise"].on
> span
> span, span[class^=
"promise"].on
> span
> span
> span {
174 color: #f98012 !important;
194 <div style=
"height: 20%; text-align: center;">
195 <img style=
"height: 100%; display: block; margin-left: auto; margin-right: auto; margin-bottom: 10px;" src=
"img/cloudguy.gif" />
196 <div id=
"cgquotes" style=
"width: 80%; margin: auto;">Welcome to the talk!
</div>
201 <li>Thanks for the opporunity to talk about programming with you all
</li>
206 <div class=
"slide-title">=<< Welcome to the Talk Called
>>=
</div>
207 <div class=
"slide flexotron" style=
"flex-wrap: nowrap;">
208 <img class=
"cloudguypower" style=
"margin-left: 70px;" src=
"img/cloudguy-power.gif" />
209 <div style=
"text-align:center; font-size:60px; text-shadow: 4px 4px #000; padding:20px;">Wide-Eyed Crazy Functional Programming
</div>
210 <img class=
"cloudguypower" style=
"margin-right: 70px; transform: scaleX(-1);" src=
"img/cloudguy-power.gif" />
214 <div class=
"slide-title">=<< What's up with that Title?
>>=
</div>
219 <li>A few people asked me about the title, so I thought I'd clear up what it means
</li>
224 <div class=
"slide-title">=<< What's up with that Title?
>>=
</div>
225 <div class=
"slide flexotron idk">
226 <div style=
"justify-content: right;">
227 <img class=
"shake-constant shake" src=
"img/wide-eyed-crazy.png" style=
"width: 70%; margin-right: 10%;">
229 <div style=
"justify-content: left">
230 <div style=
"display: flex; align-items: center; width: 70%">
231 <div id=
"rant" class=
"textbox" style=
"display: block;height: auto; width:100%; margin-left:10%;">
232 <span class=
"crazy">It’s functions,
</span><span class=
"shake-constant shake-opacity">pure
</span><span class=
"crazy"> functions! Pure functions and their values, PURE FUNCTIONS FOREVER AND FOREVER AND FOREVER A HUNDRED YEARS
</span><span class=
"shake-constant shake-opacity">monad
</span><span class=
"crazy">... some... things... Me and
</span><span class=
"shake-constant shake-opacity">monads
</span><span class=
"crazy"> runnin' around and...
</span><span class=
"shake-constant shake-opacity">applicative functor
</span><span class=
"crazy"> time... a- all day long forever... All a - a hundred days
</span><span class=
"shake-constant shake-opacity">applicatives
</span><span class=
"crazy"> and
</span><span class=
"shake-constant shake-opacity">functors
</span><span class=
"crazy">! Forever a hundred times.... OVER and over
</span><span class=
"shake-constant shake-opacity">monad transformers
</span><span class=
"crazy">... adventures dot com... W W W dot at
</span><span class=
"shake-constant shake-opacity">lambda calculus
</span><span class=
"crazy"> and
</span><span class=
"shake-constant shake-opacity">category theory
</span><span class=
"crazy"> dot com w..w..w... function composition adventures... Ah- hundred years… Every minute
</span><span class=
"shake-constant shake-opacity">referential... transparency
</span><span class=
"crazy"> dot com.... w w w a hundred times...
</span><span class=
"shake-constant shake-opacity">composition
</span><span class=
"crazy"> dot com...
</span>
236 <div class=
"fig">Fig
1.1 What most people thing a typical functional programming advocate looks like
</div>
240 <li>Regarded as eccentric crazies with wild ideas
</li>
241 <li>Spout nonsense like
"monads" every
2 seconds
</li>
247 <div class=
"slide-title">=<< Obligatory Quote
>>=
</div>
252 <li>Before I get to far in to it, I want to add some framing to the talk
</li>
253 <li>My goal is not to teach you functional programming, my goal is to spark some curiosityt
</li>
258 <div class=
"slide-title">=<< Obligatory Quote
>>=
</div>
259 <div class=
"slide flexotron">
260 <div class=
"textbox" style=
"font-size:30px;">If you wish to build a ship, do not divide the men into teams and send them to the forest to cut wood. Instead, teach them to long for the vast and endless sea.
</div>
264 <li>Before I get to far in to it, I want to add some framing to the talk
</li>
265 <li>My goal is not to teach you functional programming, my goal is to spark some curiosityt
</li>
266 <li>And I think this obligatory quote (every good talk has a quote) conveys the framework I used when writing these slides
</li>
267 <li>Also we like boats and ships and stuff like that here, so make sense I guess.
</li>
272 <div class=
"slide-title">=<< Obligatory Quote
>>=
</div>
273 <div class=
"slide flexotron">
274 <div class=
"textbox" style=
"font-size:30px;">If you wish to build a ship, do not divide the men into teams and send them to the forest to cut wood. Instead, teach them to long for the vast and endless sea.
<br /><br /> - Some French Guy. Idk. I'm not cultured. I'm Australian.
</div>
278 <li>Before I get to far in to it, I want to add some framing to the talk
</li>
279 <li>My goal is not to teach you functional programming, my goal is to spark some curiosityt
</li>
280 <li>And I think this obligatory quote (every good talk has a quote) conveys the framework I used when writing these slides
</li>
281 <li>Also we like boats and ships and stuff like that here, so make sense I guess.
</li>
282 <li>And of course, don't forget attribution. So that everyone knows you're cultured and read important things
</li>
283 <li>With that in mind, don't take any code examples too seriously, they are to demonstrate the big picture idea.
</li>
288 <div class=
"slide-title">=<< What is this Talk About?
>>=
</div>
293 <li>So what is this talk about?
</li>
294 <li>Let me start by telling you some things it is not about
</li>
295 <li>Which is something you're not supposed to do as an educator but whatever
</li>
300 <div class=
"slide-title">=<< What is this Talk About?
>>=
</div>
302 <h1>This talk is
<span class=
"highlight">not
</span> about:
</h1>
303 <div class=
"textbox" style=
"width: 60%; margin: auto; text-align: left;">
306 <li>Convincing you to stop using whichever language you like
</li>
313 <li>So what is it about?
</li>
314 <li>When trying to explain to someone why they should learn functional programming, there are many perspectives to try explain it from.
</li>
315 <li>For this discussion, I've settled on a very meta one. Perspective itself.
</li>
320 <div class=
"slide-title">=<< What is this Talk About?
>>=
</div>
321 <div class=
"slide flexotron">
322 <div style=
"text-align:center; font-size:60px; text-shadow: 4px 4px #000; padding:20px;" >Perspective
</div>
326 <li>As said, this is not a talk about haskell, it's about viewing programming through different perspectives
"</li>
327 <li>Please ask questions as we go!</li>
328 <li>Let's start the talk!</li>
333 <div class="slide-title
">=<< What is Functional Programming? >>=</div>
338 <div class="slide-title
">=<< What is Functional Programming? >>=</div>
339 <div class="slide flexotron
">
340 <div style="text-align:center; font-size:
60px; text-shadow:
4px
4px #
000; padding:
20px;
" >Programming with functions.</div>
344 <div class="slide-title
">=<< What is Functional Programming? >>=</div>
345 <div class="slide flexotron
">
346 <div style="text-align:center; font-size:
60px; text-shadow:
4px
4px #
000; padding:
20px;
" >Programming with functions.<br /><br />No, really. Everything is a function.</div>
350 <div class="slide-title
">=<< What is a Function? >>=</div>
351 <div class="slide
"></div>
354 <div class="slide-title
">=<< What is a Function? >>=</div>
355 <div class="slide flexotron
">
356 <div style="text-align:center; font-size:
60px; text-shadow:
4px
4px #
000; padding:
20px;
" >A mapping between sets that associates every element of the first set to exactly one element of the second set.</div>
360 <li>It's important to understand that that's it.</li>
361 <li>This is different to functions in procedural languages - actually the name "function
" is a misnomer in that context. Really they should be called prodedures or subroutines (hence the name procedural)</li>
362 <li>A function is a mapping. It's equivalent to something like an array in PHP. It associates one value to another one</li>
363 <li>In the same way that a PHP array cannot mutate state, a function cannot</li>
364 <li>What I'm describing are actually pure functions, but for the rest of the talk I'll just be saying "functions
"</li>
365 <li>This has some interesting consequences...</li>
370 <div class="slide-title
">=<< What is a Function? >>=</div>
372 <h1>No equivalent constructs for:</h1>
373 <div class="textbox
" style="width:
60%; margin: auto; text-align: left;
">
379 <li>Probably a bunch of other constructs I forgot</li>
382 <div class="textbox
" style="width:
60%; margin: auto; margin-top:
10px;
">*In pure functional programming, there are true variables. That is, once you declare the value of a variable, you cannot change it. Contrast this with procedural languages where you can reassign a variable whenever you like.</div>
386 <div class="slide-title
">=<< Huh? >>=</div>
387 <div class="slide
"></div>
390 <li>And of course this all begs the question....</li>
396 <div class="slide-title
">=<< Huh? >>=</div>
397 <div class="slide flexotron
">
398 <div class="textbox
" style="text-align:center; font-size:
40px; text-shadow:
4px
4px #
000; padding:
20px;
" >Who in their right mind would wanna do that?!</div>
402 <li>You're trying to tell me FP is awesome be because it has ... less features?</li>
403 <li>This is true, but it makes no difference. You can accomplish anything in FP that you can accomplish in a procedural language</li>
408 <div class="slide-title
">=<< Huh? >>=</div>
411 <div class="textbox
" style="width:
60%; margin: auto; text-align: left;
">
413 <li>Learning is good</li>
414 <li>Brain plasticity</li>
415 <li>Greater perspective</li>
421 <li>The best answer I can give is, "learning is good
". I think that's something everyone at moodle can agree on</li>
422 <li>Learning FP is gonna require you to wrestle your brain in to shapes it's never taken before. Which will leave it with the plasticity to learn a greater variety of things you encounter.</li>
423 <li>It will also make the math/logic part of your brain very buff</li>
424 <li>As we know, the brain has 3 main cortexes. The passion cortex, the power cortext, and the logic cortex</li>
425 <li>As programmers we need to engorge mostly the logic cortext, but also the passion cortex - as this is a profession that involves other people.</li>
426 <li>Communicating about programs written in the functional style is actually easier than the programs written in the procedural style. More on that later</li>
427 <li>And lets not forget that our very own MoodleNet is written in Elixir. A functional language.</li>
432 <div class="slide-title
">=<< Paradigms >>=</div>
433 <div class="slide flexotron
">
434 <div style="text-align:center; font-size:
60px; text-shadow:
4px
4px #
000; padding:
20px;
" >Paradigms</div>
438 <li>Let's talk about paradigms for a bit</li>
439 <li>In particular, let's talk about the two most widely used paradigms. Which also happen to be the most at odds</li>
444 <div class="slide-title
">=<< Paradigms >>=</div>
445 <div class="slide flexotron
">
446 <div class="textbox flexotron
" style="position: relative; width:
30%; height:
50%; margin-right:
20px;
">
447 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Declarative</span>
448 <div class="textbox
" style="position: relative; width:
80%; height:
60%;
">
449 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Functional</span>
450 <ul style="text-align: left; margin-top:
65px;margin-left:
40px;
">
458 <div class="textbox flexotron
" style="position: relative; width:
30%; height:
50%; margin-right:
20px;
">
459 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Imperative</span>
460 <div class="textbox
" style="position: relative; width:
80%; height:
60%;
">
461 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Procedural</span>
462 <ul style="text-align: left; margin-top:
65px;margin-left:
40px;
">
473 <li>So here they are. Declaritive and imperative, and inside those we see sub-paradigms (there are more, for example SQL is declaritive but not functional, and Assembly is imperative but not procedural - although the vast majority of imperative languages are indeed procedural):</li>
474 <li>And then inside the boxes we see some examples of language that embody that paradigm</li>
475 <li>For the purposes of this talk it's probably OK to just think of declaritive and functional as interchangeable, and some for imperative and procedural. I'll probably mix them up</li>
476 <li>So why am I showing this? Well, let's look at this through a different perspective... Some of you might have realised that imperative and declaritive are both words used to describe human language, and that's relevant</li>
477 <li>Learning a new paradigm is beneficial the same way learning a new human language is</li>
482 <div class="slide-title
">=<< Gramatical Mood >>=</div>
483 <div class="slide flexotron
">
484 <div class="textbox
" style="position: relative; width:
30%; height:
50%; margin-right:
20px; padding-top:
40px;
">
485 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Declarative</span>
486 A sentence which expresses a statement of fact.
487 <ul style="text-align: left; margin-top:
65px;margin-left:
40px;
">
489 <li>I like climbing.</li>
490 <li>Ice is cold.</li>
491 <li>Mathieu is shredded.</li>
494 <div class="textbox
" style="position: relative; width:
30%; height:
50%; margin-right:
20px; padding-top:
40px;
">
495 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Imperative</span>
496 <span>A sentence which expresses instructions, or requests.</span>
497 <ul style="text-align: left; margin-top:
65px;margin-left:
40px;
">
498 <li>Shut the door.</li>
499 <li>Don't eat my burger.</li>
500 <li>Let's go to the pub.</li>
501 <li>Don't make eye contact with Craig.</li>
507 <li>We can see here that in the declaritive mood you express statements of fact. They aren't instrcutions</li>
508 <li>Contrast this with the imperative style of expression where there is a very clear instruction to carry out</li>
513 <div class="slide-title
">=<< Gramatical Mood >>=</div>
514 <div class="slide flexotron
">
515 <div class="textbox flexotron
" style="position: relative; width:
30%; height:
50%; margin-right:
20px; padding-top:
40px;
">
516 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Declarative</span>
519 <div class="textbox flexotron
" style="position: relative; width:
30%; height:
50%; margin-right:
20px; padding-top:
40px;
">
520 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Imperative</span>
526 <li>To make it more concise... here's the smallest definition I can think of</li>
527 <li>And this applies to programs too. In the functional paradigm we no longer have the "instruction words
" - things like, for, while, goto, variable reassignment</li>
532 <div class="slide-title
">=<< Big Brain Moment >>=</div>
533 <div class="slide
"></div>
536 <li>And that brings us to the first of hopefully many "Big Brain Moments
"</li>
541 <div class="slide-title
">=<< Big Brain Moment >>=</div>
542 <div class="slide flexotron
">
543 <div class="textbox
" style="text-align:center; font-size:
40px; text-shadow:
4px
4px #
000; padding:
20px;
" >Programming languages <span class="highlight
">ARE</span> human languages.</div>
547 <li>We don't write programs for computers - we write programs for other humans.</li>
552 <div class="slide-title
">=<< Why is declaritive mood good? >>=</div>
557 <li>But in both cases, it seems like we lose something useful in the declaritive mode. What do we get by giving up these things?</li>
558 <li>Surely giving instructions is useful, otherwise how do you do anything?!</li>
563 <div class="slide-title
">=<< Why is declaritive mood good? >>=</div>
564 <div class="slide flexotron
">
565 <div style="text-align:center; font-size:
60px; text-shadow:
4px
4px #
000; padding:
20px;
" >Atemporality</div>
569 <div class="slide-title
">=<< Why is declaritive mood good? >>=</div>
570 <div class="slide flexotron
">
571 <div style="text-align:center; font-size:
60px; text-shadow:
4px
4px #
000; padding:
20px;
" >Independant of or unaffected by time.</div>
575 <div class="slide-title
">=<< Why is declaritive mood good? >>=</div>
576 <div class="slide flexotron
">
577 <div style="text-align:center; font-size:
50px; text-shadow:
4px
4px #
000; padding:
20px;
" >Declarative programs express what <span class="highlight
" style="display: block;
">they actually do</span> leaving more "brain space
" to focus on solving the problem.</div>
581 <li>A declaritive program expresses its operation in terms of relationships.</li>
582 <li>In an imperative paradigm, thinking about the program means thinking about changes over time => keeping track of changes</li>
583 <li>In a declaritive one, thinking about the program means thinking about relationships => look at what the thing is, how it relates to the other thing, and move on</li>
588 <div class="slide-title
">=<< To Recap >>=</div>
591 <div class="textbox
" style="width:
60%; margin: auto; text-align: left;
">
593 <li>Because sometimes there is such a thing as too much freedom</li>
594 <li>Functional programming is awesome because it stops you shooting yourself in the foot</li>
595 <li>"Constraints liberate, liberties constrain
"</li>
596 <li>There are also classes of problems where the declaritive style is a more elegant way of expressing the solution</li>
601 <li>Some problems are simply very difficult to solve in an imperative way.</li>
602 <li>Especially when we are talking about events that are happening in parallel and may run at different speed/times</li>
603 <li>In the imperative paradigm, you quite easily come up against data races by virtue of the way the program is expressed</li>
609 <div class="slide-title
">=<< Some Code (Finally) >>=</div>
614 <li>At this point I imagine a lot of you are thinking....</li>
619 <div class="slide-title
">=<< Some Code (Finally) >>=</div>
620 <div class="slide flexotron
">
621 <div style="text-align:center; font-size:
50px; text-shadow:
4px
4px #
000; padding:
20px;
" >Enough of this philosophy and linguistics mumbo jumbo, already!</div>
625 <div class="slide-title
">=<< Some Code (Finally) >>=</div>
627 <h1>My favourite example</h1>
629 <div style="display: flex;
">
630 <pre style="margin: auto;
"><code style="font-size:
20px;
"><span class="code-friends1 code-friends4
">x = x + 1;</span></code></pre>
632 <div style="display: flex; margin-top:
20px; margin-bottom:
20px;
">
633 <span style="margin: auto;
">and:</span>
635 <div style="display: flex; margin-bottom:
50px;
">
636 <pre style="margin: auto;
"><code style="font-size:
20px;
"><span class="code-friends2 code-friends3
">function repeat(x) {
637 return x + repeat(x);
638 }</span></code></pre>
640 <h2>OK, so what?</h2>
641 <div style="display: flex;
">
642 <div class="textbox
" style="margin: auto; width:
60%; font-size:
20px;
">In the declaritive paradigm, <span class="code-friends1
" onmouseenter="activateFriends(
1, true);
" onmouseleave="deactivateFriends(
1);
" style="display: inline-block;
">this</span> code hangs while <span class="code-friends2
" onmouseenter="activateFriends(
2, true);
" onmouseleave="deactivateFriends(
2);
" style="display: inline-block;
">this</span> code runs. In the imperative paradigm <span class="code-friends3
" onmouseenter="activateFriends(
3, true);
" onmouseleave="deactivateFriends(
3);
" style="display: inline-block;
">this</span> code hangs, while <span class="code-friends4
" onmouseenter="activateFriends(
4, true);
" onmouseleave="deactivateFriends(
4);
" style="display: inline-block;
">this</span> code runs.</div>
647 <div class="slide-title
">=<< Some Code (Finally) >>=</div>
649 <div style="display: flex; margin-top:
50px;
">
650 <pre style="margin: auto;
"><code style="font-size:
20px;
">x = x + 1;</code></pre>
652 <div class="flexotron
" style="height:
80%;
">
653 <div class="textbox
" style="position: relative; width:
30%; height:
50%; margin-right:
20px; padding-top:
40px;
">
654 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Declarative</span>
655 "x is the same as itself plus one.
"<br /><br /><br /><br /><br />
658 <div class="textbox
" style="position: relative; width:
30%; height:
50%; margin-right:
20px; padding-top:
40px;
">
659 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Imperative</span>
660 "Evaluate the thing on the right of `=` then store it in the thing on the left of `=`.
"<br /><br /><br />
661 A list of instructions that can be followed.
667 <div class="slide-title
">=<< Some Code (Finally) >>=</div>
669 <div style="display: flex; margin-top:
50px;
">
670 <pre style="margin: auto;
"><code style="font-size:
20px;
">function repeat(x) {
671 return x + repeat(x);
674 <div class="flexotron
" style="height:
80%;
">
675 <div class="textbox
" style="position: relative; width:
30%; height:
50%; margin-right:
20px; padding-top:
30px;
">
676 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Declarative</span>
677 "The repeat of `x` is `x` appended to the repeat of `x`
"<br /><br /><br />
678 An infinite list of `x`!
680 <div class="textbox
" style="position: relative; width:
30%; height:
50%; margin-right:
20px; padding-top:
40px;
">
681 <span class="textbox
" style="box-shadow: none; position: absolute; top: -
20px; left:
30px;
">Imperative</span>
682 "To evaluate the repeate of `x`, first evaluate the repeat of `x`
"<br /><br /><br />
683 ...Yeah, you see the problem?
689 <div class="slide-title
">=<< Big Brain Moment >>=</div>
690 <div class="slide flexotron
">
691 <div class="textbox
" style="text-align:center; font-size:
40px; text-shadow:
4px
4px #
000; padding:
20px;
" >Programming languages <span class="highlight
">ARE</span> human languages.</div>
695 <li>Let's take this time to reflect...</li>
696 <li>Imperative tells you what to do</li>
697 <li>Declaritive tells you what things are</li>
702 <div class="slide-title
">=<< Some Code (Finally) >>=</div>
704 <h1>Real Haskell code that runs</h1>
705 <pre><code class="haskell
">repeat x = x ++ repeat x
706 threeFs = take 3 (repeat "f
")
713 <li>Let's think about the way this is understood</li>
714 <li>threeFs is the first three elements in an infinite list of fs - totally fine, makes complete sense</li>
715 <li>Shame that the function name is "take
" but whatever</li>
720 <div class="slide-title
">=<< Some Code (Finally) >>=</div>
722 <h1>Real JavaScript code that hangs</h1>
723 <pre><code class="javascript
">function repeat(x) {
724 return x + repeat(x);
727 threeFs = repeat("f
").substr(0,3);
729 > InternalError: too much recursion
734 <li>By contrast, this reads as "First compute an infinite list of fs
" - which as we saw before was a problem. And even that human sentence clearly has a problem.</li>
739 <div class="slide-title
">=<< Big Brain Moment >>=</div>
741 <h1>What did declaritive mode give us?</h1>
742 <div class="textbox
" style="width:
60%; margin: auto; text-align: left;
">
744 <li>Atemporality</li>
745 <li>The ability to wield infinity!</li>
751 <li>How cool is that? Because we can express what things are, we can express an infininte list!</li>
752 <li>None of the declaritive version of the program relies on us traking changes anywhere. We just need to know what a thing is and how it relates to another thing</li>
757 <div class="slide-title
">=<< Promises >>=</div>
758 <div class="slide flexotron
">
759 <div style="text-align:center; font-size:
60px; text-shadow:
4px
4px #
000; padding:
20px;
" >Promises</div>
763 <li>Let's think about promises...</li>
764 <li>Seems like an odd tangent but let's go with it</li>
765 <li>And just as before, I'm gonna break one of the carinal rules of teaching by telling you what promises are not...</li>
770 <div class="slide-title
">=<< Promises >>=</div>
771 <div class="slide flexotron
">
772 <div style="position: relative; text-align:center; font-size:
40px; text-shadow:
4px
4px #
000;
" >
773 <div class="angereyWrap
"><div class="angerey
">>:(</div></div>
774 <div class="angereyWrap
"><div class="angerey
">>:(</div></div>
775 <div class="angereyWrap
"><div class="angerey
">>:(</div></div>
776 <div class="angereyWrap
"><div class="angerey
">>:(</div></div>
777 <div class="angereyWrap
"><div class="angerey
">>:(</div></div>
778 <div class="angereyWrap
"><div class="angerey
">>:(</div></div>
779 <div class="angereyWrap
"><div class="angerey
">>:(</div></div>
780 <div class="angereyWrap
"><div class="angerey
">>:(</div></div>
781 <div class="angereyWrap
"><div class="angerey
">>:(</div></div>
782 <div class="angereyWrap
"><div class="angerey
">>:(</div></div>
783 Promises <span class="shake-slow shake-constant
" style="display: inline-block; color: #f98012
">do not</span> make things asynchronous!</div>
787 <li>So there's a lot of misleading information out there about promises</li>
788 <li>Some people believe that promises "make
" things asynchronous, but this isn't true</li>
789 <li>You can have perfectly synchronous promises, the thing you pass as a callbackto a promise does not get "run in the background
" or anything like that</li>
794 <div class="slide-title
">=<< Promises >>=</div>
796 <h1>The real promises</h1>
797 <h2>What problems do promises solve?</h2>
798 <div class="textbox
" style="width:
60%; margin: auto; text-align: left;
">
800 <li>Asynchronous request management</li>
801 <li>Error handling for computations which may fail</li>
802 <li>Probably more too</li>
805 <h2 style="margin-top:
50px;
">What are promises then?</h2>
806 <div class="textbox
" style="width:
60%; margin: auto; text-align: left;
">
808 <li>A value (which may or may not be available yet) wrapped in some additional context</li>
809 <li>Functions to instantiate the wrapper (`Promise.resolve`, `Promise.reject`)</li>
810 <li>A rule for composing these wrapped values (`then`)</li>
816 <div class="slide-title
">=<< Promises >>=</div>
818 <h1>Terminology/syntax recap</h1>
819 <h2>JavaScript arrow functions</h2>
820 <div style="display: flex;
">
821 <pre style="margin: auto;
"><code style="font-size:
20px;
">x => x + 1;</code></pre>
823 <div style="display: flex; margin-top:
20px; margin-bottom:
20px;
">
824 <span style="margin: auto;
">is equivalent to:</span>
826 <div style="display: flex; margin-bottom:
50px;
">
827 <pre style="margin: auto;
"><code style="font-size:
20px;
">function(x) {
832 <div style="display: flex;
">
833 <div class="textbox
" style="margin: auto; width:
60%; font-size:
20px;
">A method of combining two things of the same type in to another thing that is also of the same type</div>
838 <li>Shoutout Mat about arrow functions</li>
839 <li>A quick note on composition: So far you may have come across function composition. There's lots of different kinds of composition, but function composition is incredibly common, especially in programming. However in the example we are talking the composition of promises. In the sense that we combine to promises, and get another promise.</li>
844 <div class="slide-title
">=<< Promises >>=</div>
846 <h1>Promise composition</h1>
847 <div style="display: flex;
">
848 <div class="textbox
" style="margin: auto; width:
60%; font-size:
20px;
">The `then` method of a promise accepts a function as an argument. This function takes a value and returns a new promise. The new promise "combines
" the previous two using the "composition rule
" given to `then`.</div>
850 <div style="display: flex; margin-top:
100px
">
851 <pre style="margin: auto;
"><code style="font-size:
12px;
"><span class="promise3
"><span class="promise2
"><span class="promise1
">Promise.resolve("Some value
")</span>.then(x => Promise.resolve(x + " and another value
"))</span>.then(x => Promise.resolve(x + " and another one!
"))</span>;</code></pre>
853 <div style="display: flex;
">
854 <div class="textbox
" style="margin: auto; width:
60%; font-size:
20px; margin-top:
50px;
">There are three promises in the above snippet. <span onmouseenter="activatePromise(
1)
" onmouseleave="deactivatePromise(
1)
" class="promise1
">One</span>, <span onmouseenter="activatePromise(
2)
" onmouseleave="deactivatePromise(
2)
" class="promise2
">two</span>, <span onmouseenter="activatePromise(
3)
" onmouseleave="deactivatePromise(
3)
" class="promise3
">three</span>.</div>
856 <div style="display: flex; margin-top:
100px
">
857 <pre style="margin: auto;
"><code style="font-size:
12px;
">Promise.resolve("Some value
").then(x => Promise.reject("It's all gone wrong
")).then(x => Promise.resolve(x + " and another one!
"));</code></pre>
859 <div style="display: flex;
">
860 <div class="textbox
" style="margin: auto; width:
60%; font-size:
20px; margin-top:
50px;
">The above snippet still results in a promise, but it is a "failed
" one. Any subsequent `then` after the `reject` has no effect.</div>
865 <li>Depending on how we go for time, I hope to discuss composition after this section.</li>
870 <div class="slide-title
">=<< Promises >>=</div>
872 <h1>OK great but who cares?</h1>
873 <div class="textbox
" style="width:
60%; margin: auto; text-align: left;
">
875 <li>We are <span class="highlight
" style="display: inline-block;
">declaring</span> how we want promises to compose</li>
877 The order that the promises actually resolve their values in is not important
878 <ul><li>In other words, we don't have to worry about <span class="highlight
" style="display: inline-block;
">timing</span> anymore</li></ul>
880 <li>We can <span class="highlight
" style="display: inline-block;
">declare</span> a failure anywhere in the chain</li>
886 <div class="slide-title
">=<< Promises >>=</div>
887 <div class="slide flexotron
">
888 <div style="position: relative;
">
889 <img src="img/thonking.gif
" />
890 <div class="thonkingWrap
"><div class="thonk
">atemporality?</div></div>
891 <div class="thonkingWrap
"><div class="thonk
">declaritive?</div></div>
892 <div class="thonkingWrap
"><div class="thonk
">functions?</div></div>
893 <div class="thonkingWrap
"><div class="thonk
">composition?</div></div>
898 <li>This sure is starting to sound familiar.</li>
903 <div class="slide-title
">=<< Promises >>=</div>
907 <pre style="margin-bottom:
50px;
"><code class="javascript
"><span class="code-friends1
" onmouseenter="activateFriends(
1);
" onmouseleave="deactivateFriends(
1);
" style="display: inline-block
">Promise.resolve</span>(<span class="code-friends2
" onmouseenter="activateFriends(
2);
" onmouseleave="deactivateFriends(
2);
" style="display: inline-block
">"We start here
"</span>)
908 <span class="code-friends3
" onmouseenter="activateFriends(
3);
" onmouseleave="deactivateFriends(
3);
" style="display: inline-block
">.then</span>(<span class="code-friends4
" onmouseenter="activateFriends(
4);
" onmouseleave="deactivateFriends(
4);
" style="display: inline-block
">x =></span> <span class="code-friends5
" onmouseenter="activateFriends(
5);
" onmouseleave="deactivateFriends(
5);
" style="display: inline-block
">Promise.resolve</span>(<span class="code-friends6
" onmouseenter="activateFriends(
6);
" onmouseleave="deactivateFriends(
6);
" style="display: inline-block
">x + " then get here
"</span>))
909 <span class="code-friends7
" onmouseenter="activateFriends(
7);
" onmouseleave="deactivateFriends(
7);
" style="display: inline-block
">.then</span>(<span class="code-friends8
" onmouseenter="activateFriends(
8);
" onmouseleave="deactivateFriends(
8);
" style="display: inline-block
">x =></span> <span class="code-friends9
" onmouseenter="activateFriends(
9);
" onmouseleave="deactivateFriends(
9);
" style="display: inline-block
">Promise.resolve</span>(<span class="code-friends10
" onmouseenter="activateFriends(
10);
" onmouseleave="deactivateFriends(
10);
" style="display: inline-block
">x + " and finally here!
"</span>))</code></pre>
911 <pre><code class="haskell
"><span class="code-friends1
" onmouseenter="activateFriends(
1);
" onmouseleave="deactivateFriends(
1);
" style="display: inline-block
">Right</span>(<span class="code-friends2
" onmouseenter="activateFriends(
2);
" onmouseleave="deactivateFriends(
2);
" style="display: inline-block
">"We start here
"</span>)
912 <span class="code-friends3
" onmouseenter="activateFriends(
3);
" onmouseleave="deactivateFriends(
3);
" style="display: inline-block
">>>=</span> (<span class="code-friends4
" onmouseenter="activateFriends(
4);
" onmouseleave="deactivateFriends(
4);
" style="display: inline-block
">\x -> </span><span class="code-friends5
" onmouseenter="activateFriends(
5);
" onmouseleave="deactivateFriends(
5);
" style="display: inline-block
">Right</span> (<span class="code-friends6
" onmouseenter="activateFriends(
6);
" onmouseleave="deactivateFriends(
6);
" style="display: inline-block
">x ++ " then get here
"</span>))
913 <span class="code-friends7
" onmouseenter="activateFriends(
7);
" onmouseleave="deactivateFriends(
7);
" style="display: inline-block
">>>=</span> (<span class="code-friends8
" onmouseenter="activateFriends(
8);
" onmouseleave="deactivateFriends(
8);
" style="display: inline-block
">\x -></span> <span class="code-friends9
" onmouseenter="activateFriends(
9);
" onmouseleave="deactivateFriends(
9);
" style="display: inline-block
">Right</span> (<span class="code-friends10
" onmouseenter="activateFriends(
10);
" onmouseleave="deactivateFriends(
10);
" style="display: inline-block
">x ++ " and finally here!
"</span>))</code></pre>
917 <li>It does not matter what order the promises resolve in, the final promise will always be resolved with "We start here...
"</li>
918 <li>In this specific example, there is nothing asynchronous happening, but it's not much work to adapt it so there is. I just wanted to really highlight the similarities with haskell</li>
923 <div class="slide-title
">=<< Promises >>=</div>
927 <pre style="margin-bottom:
50px;
"><code class="javascript
"><span class="code-friends1
" onmouseenter="activateFriends(
1);
" onmouseleave="deactivateFriends(
1);
" style="display: inline-block
">Promise.resolve</span>(<span class="code-friends2
" onmouseenter="activateFriends(
2);
" onmouseleave="deactivateFriends(
2);
" style="display: inline-block
">"We start here
"</span>)
928 <span class="code-friends3
" onmouseenter="activateFriends(
3);
" onmouseleave="deactivateFriends(
3);
" style="display: inline-block
">.then</span>(<span class="code-friends4
" onmouseenter="activateFriends(
4);
" onmouseleave="deactivateFriends(
4);
" style="display: inline-block
">x =></span> <span class="code-friends5
" onmouseenter="activateFriends(
5);
" onmouseleave="deactivateFriends(
5);
" style="display: inline-block
">Promise.resolve</span>(<span class="code-friends6
" onmouseenter="activateFriends(
6);
" onmouseleave="deactivateFriends(
6);
" style="display: inline-block
">x + " then get here
"</span>))
929 <span class="code-friends11
" onmouseenter="activateFriends(
11);
" onmouseleave="deactivateFriends(
11);
" style="display: inline-block
">.then</span>(<span class="code-friends12
" onmouseenter="activateFriends(
12);
" onmouseleave="deactivateFriends(
12);
" style="display: inline-block
">x =></span> <span class="code-friends13
" onmouseenter="activateFriends(
13);
" onmouseleave="deactivateFriends(
13);
" style="display: inline-block
">Promise.reject</span>(<span class="code-friends14
" onmouseenter="activateFriends(
14);
" onmouseleave="deactivateFriends(
14);
" style="display: inline-block
">"Oh noes!
"</span>))
930 <span class="code-friends7
" onmouseenter="activateFriends(
7);
" onmouseleave="deactivateFriends(
7);
" style="display: inline-block
">.then</span>(<span class="code-friends8
" onmouseenter="activateFriends(
8);
" onmouseleave="deactivateFriends(
8);
" style="display: inline-block
">x =></span> <span class="code-friends9
" onmouseenter="activateFriends(
9);
" onmouseleave="deactivateFriends(
9);
" style="display: inline-block
">Promise.resolve</span>(<span class="code-friends10
" onmouseenter="activateFriends(
10);
" onmouseleave="deactivateFriends(
10);
" style="display: inline-block
">x + " and finally here!
"</span>))</code></pre>
932 <pre><code class="haskell
"><span class="code-friends1
" onmouseenter="activateFriends(
1);
" onmouseleave="deactivateFriends(
1);
" style="display: inline-block
">Right</span>(<span class="code-friends2
" onmouseenter="activateFriends(
2);
" onmouseleave="deactivateFriends(
2);
" style="display: inline-block
">"We start here
"</span>)
933 <span class="code-friends3
" onmouseenter="activateFriends(
3);
" onmouseleave="deactivateFriends(
3);
" style="display: inline-block
">>>=</span> (<span class="code-friends4
" onmouseenter="activateFriends(
4);
" onmouseleave="deactivateFriends(
4);
" style="display: inline-block
">\x -> </span><span class="code-friends5
" onmouseenter="activateFriends(
5);
" onmouseleave="deactivateFriends(
5);
" style="display: inline-block
">Right</span> (<span class="code-friends6
" onmouseenter="activateFriends(
6);
" onmouseleave="deactivateFriends(
6);
" style="display: inline-block
">x ++ " then get here
"</span>))
934 <span class="code-friends11
" onmouseenter="activateFriends(
11);
" onmouseleave="deactivateFriends(
11);
" style="display: inline-block
">>>=</span> (<span class="code-friends12
" onmouseenter="activateFriends(
12);
" onmouseleave="deactivateFriends(
12);
" style="display: inline-block
">\x -></span> <span class="code-friends13
" onmouseenter="activateFriends(
13);
" onmouseleave="deactivateFriends(
13);
" style="display: inline-block
">Left </span>(<span class="code-friends14
" onmouseenter="activateFriends(
14);
" onmouseleave="deactivateFriends(
14);
" style="display: inline-block
">"Oh noes!
"</span>))
935 <span class="code-friends7
" onmouseenter="activateFriends(
7);
" onmouseleave="deactivateFriends(
7);
" style="display: inline-block
">>>=</span> (<span class="code-friends8
" onmouseenter="activateFriends(
8);
" onmouseleave="deactivateFriends(
8);
" style="display: inline-block
">\x -></span> <span class="code-friends9
" onmouseenter="activateFriends(
9);
" onmouseleave="deactivateFriends(
9);
" style="display: inline-block
">Right</span> (<span class="code-friends10
" onmouseenter="activateFriends(
10);
" onmouseleave="deactivateFriends(
10);
" style="display: inline-block
">x ++ " and finally here!
"</span>))</code></pre>
939 <li>Likewise, we can put a failure anywhere in the chain. It doesn't matter if the failure happens first, last, or anywhere in between. The result is always a failed promise of "Oh noes!
"</li>
940 <li>So, if you've ever used promises, you've been doing declaritive style programming without even realising it!</li>
941 <li>They give us some new powers, we can now write atemporal code, which explains why they emerged in JS, a place where people are constantly dealing with requests that can finish in any order</li>
942 <li>So it's super cool that people using a language very far removed from haskell ended up solving the problem in the same way</li>
943 <li>Although both are independed discoveries, I don't think it's a coincidence promises appeared given the nature of the JS world.</li>
948 <div class="slide-title
">=<< Composition >>=</div>
949 <div class="slide flexotron
">
950 <div style="text-align:center; font-size:
60px; text-shadow:
4px
4px #
000; padding:
20px;
" >Composition</div>
954 <li>Let's think about composition...</li>
955 <li>Mat touched on function composition briefly in his talk</li>
956 <li>I wantto talk about it in a more abstract sence. I think the idea of composition is so important that it deserves its own little bit</li>
961 <div class="slide-title
">=<< Composition >>=</div>
962 <div class="slide flexotron
">
963 <img src="img/composition0.png
" style="height:
700px;
" />
967 <div class="slide-title
">=<< Composition >>=</div>
968 <div class="slide flexotron
">
969 <div style="position: relative;
">
970 <div style="position: absolute; top: -
40px; left: -
106px
">If we can go from here to here</div>
971 <img src="img/composition1.png
" style="height:
700px;
" />
976 <div class="slide-title
">=<< Composition >>=</div>
977 <div class="slide flexotron
">
978 <div style="position: relative;
">
979 <div style="position: absolute; top: -
40px; left: -
106px
">If we can go from here to here</div>
980 <div style="position: absolute; max-width:
425px; text-align: center; bottom:
149px; left:
220px
">And we can go from here to here</div>
981 <img src="img/composition2.png
" style="height:
700px;
" />
986 <div class="slide-title
">=<< Composition >>=</div>
987 <div class="slide flexotron
">
988 <div style="position: relative;
">
989 <div style="position: absolute; top: -
40px; left: -
106px
">If we can go from here to here</div>
990 <div style="position: absolute; max-width:
425px; text-align: center; bottom:
149px; left:
220px
">And we can go from here to here</div>
991 <div style="position: absolute; text-align: center; bottom: -
70px; left:
82px
">Then the composition (if it exists) goes from here to here</div>
992 <img src="img/composition3.png
" style="height:
700px;
" />
997 <li>RETURN LATER: Come back to this slide after looking at the next one</li>
998 <li>We want to go from A to C - but maybe that's really hard</li>
999 <li>Perhaps someone worked out how to go from A to B, and someone else worked out how to go from B to C</li>
1000 <li>Well, if we're in a system where composition is possible, then we just solved the problem!</li>
1001 <li>This is the natural way people solve problems</li>
1002 <li>RETURN EVEN LATER: After returning from the end slide: explain how side effects break composition</li>
1004 <li>Maybe A->B has a side effect, this means when we call B->C with the result from A->B, it may not be the same as calling A->C. The point of composition is that the outcome should be the same.</li>
1005 <li>Don't talk about it unless needed: Referential transparency. f(a, b) => return print(a + b) + print(a + b); is not the same program as f(a,b) => c = print(a + b); return c + c;</li>
1007 <li>Procedures in imperative languages are a short sighted attempt at composition</li>
1008 <li>In the functional paradigm, composition is gauranteed because functions cannot have side effects</li>
1013 <div class="slide-title
">=<< Composition >>=</div>
1015 <h1>OK great but who cares?</h1>
1019 <li>Go back to the full composition diagram</li>
1024 <div class="slide-title
">=<< Composition >>=</div>
1026 <h1>OK great but who cares?</h1>
1027 <div class="textbox
" style="width:
60%; margin: auto;
">Big problems can often be chopped up in to smaller, easier to solve problems. If we can be clever about how we chop them up, such that the solutions to the individual problems can <span class="highlight
">compose</span> together to form a full solution, then we can infinitely speed up the process by adding more workers!</div>
1031 <div class="slide-title
">=<< Composition >>=</div>
1034 <div class="textbox
" style="width:
60%; margin: auto; text-align: left;
">
1036 <li>The pyramids</li>
1045 <li>The pyramids were build by having loads of peope work in parallel</li>
1046 <li>Same with the LHC. I don't believe there is a single person in the world who fully understands it</li>
1047 <li>Instead of having one chef "make a burger
" - staff make individual parts of the burger and compose it together - I think McDonald's was the first place to do this</li>
1048 <li>And Moodle does it too! Let's think about how we tackle projects...</li>
1053 <div class="slide-title
">=<< Composition >>=</div>
1054 <div class="slide
"></div>
1057 <li>So... do we get one mega awesome dev to bash out features?</li>
1062 <div class="slide-title
">=<< Composition >>=</div>
1063 <div class="slide flexotron
">
1064 <div style="height:
80%;
" >
1065 <img src="img/
10xdev.png
" class="textbox
" style="margin-bottom:
20px;
40px; height:
60%; display: block; margin: auto; padding-bottom:
0px;
" />
1066 <div class="textbox
" style="margin-top:
20px !important; width:
50%; margin: auto; font-style: italic;
">"With these biceps I can solve
<span class=
"highlight shake shake-constant" style=
"display: inline-block">ANYTHING
</span>"</div>
1071 <li>idk about you, but I wouldn't be keen to work with this person</li>
1072 <li>There's a thing in dev called the 10x developer, and it is something that simply does not exist</li>
1073 <li>The correct way to work on software is of course...</li>
1078 <div class="slide-title
">=<< Composition >>=</div>
1079 <div class="slide flexotron
">
1080 <div class="textbox
"><h1>No, you get friends to take a piece and help!</h1></div>
1081 <div id="cloudguys
">
1084 <img src="img/cloudguy.gif
" />
1088 <img src="img/cloudguy.gif
" />
1091 <img src="img/cloudguy.gif
" />
1095 <img src="img/cloudguy.gif
" />
1099 <img src="img/cloudguy.gif
" />
1103 <img src="img/cloudguy.gif
" />
1110 <li>This is why it's worth spending the time to plan things and figure out how to "chop up
" the work</li>
1111 <li>We need to make sure we are chopping the problem up in to pieces that can be composed together later</li>
1116 <div class="slide-title
">=<< Composition >>=</div>
1117 <div class="slide flexotron
">
1118 <div class="textbox
" style="text-align:center; font-size:
40px; text-shadow:
4px
4px #
000; padding:
20px;
" >Composition is nature's greatest hack</div>
1122 <li>My goal here was to try and convince you that composition really is important and is fundamental to the way we think</li>
1123 <li>Humans are amazing for our ability to break down problems in to manageable chunks and then compose them together.</li>
1124 <li>At its core, composition is about relationships, and building complexity by combining them. Hey, wasn't the whole declaritive thing about relationships?</li>
1125 <li>And that brings me to my final point</li>
1130 <div class="slide-title
">=<< Composition >>=</div>
1132 <h1>What's this got to do with FP?</h1>
1133 <div class="textbox
" style="width:
60%; margin: auto;
">When writing programs (as an individual in this case, not as a group) we naturally want to break the solution up in to "building blocks
" that we put together to solve the problem (it's composition again).</div>
1134 <div class="textbox
" style="width:
60%; margin: auto; margin-top:
20px;
">The building blocks you use matter. Some compose better than others. Because of all the restrictions the functional paradigm places on the programmer (lack of mutation, lack of control flow), functions in a pure language are naturally well-suited to composition.</div>
1135 <div class="textbox
" style="width:
60%; margin: auto; margin-top:
20px;
">This is becoming more relevant than ever in the age of parallel computing</div>
1139 <li>Go back to the composition slide and explain that in FP the composition is gauranteed to exist, while in other paradigms it is not</li>
1144 <div class="slide-title
">=<< Closing Notes >>=</div>
1145 <div class="slide
"></div>
1148 <li>I'd like to finish this talk with some food for thought...</li>
1153 <div class="slide-title
">=<< Closing Notes >>=</div>
1155 <h1>Applications to life:</h1>
1156 <div class="textbox
" style="width:
60%; margin: auto; text-align: left;
">
1158 <li>We work across multiple timezones, so being able to solve problems in a time-independant way seems appealing, doesn't it?</li>
1159 <li>Moore's law is coming to an end, now the focus is shifting to parallel computing</li>
1161 <li>Imperative paradigms will not be the right tool for this</li>
1162 <li>Either we'll see a shift to declaritive style programming</li>
1163 <li>Or we'll make life hard for ourselves real fast</li>
1165 <li>Maybe quantum mechanics is so damn confusing because at a certain point we can't decompose things anymore?</li>
1166 <ul><li>After all... why should the universe conform to the way our brains want it to be...</li></ul>
1172 <li>In regards to Moore's law, I personally hope we start seeing a paradigm shift soon. Because that's the definition of madness really. Doing the same thing over and over but expecting different results.</li>
1173 <li>Other analogies like the frog in slowly boiling water come to mind</li>
1174 <li>And that's about it really!</li>
1179 <div id="cloudguy2
">
1180 <div style="height:
20%; text-align: center;
">
1181 <img style="height:
100%; display: block; margin-left: auto; margin-right: auto; margin-bottom:
10px;
" src="img/cloudguy.gif
" />
1182 <div style="width:
80%; margin: auto;
">Thanks for participating!!</div>
1188 var div, i, j, span, duration = "";
1189 var crazyTexts = [];
1190 var opacyTexts = [];
1191 div = document.querySelectorAll("#rant
> span.crazy
");
1192 for (j = 0; j < div.length; j++) {
1194 for (i = 0; i < div[j].innerText.length; i++) {
1195 duration = Math.floor(Math.random() * 5) + 100
1196 span += "<span class=
\"letter shake-constant shake-little
\" style=
\"animation-duration:
" + duration + "ms
\">";
1197 span += div[j].innerText[i] == " " ? " " : div[j].innerText[i];
1200 crazyTexts.push(span);
1203 opacities = document.querySelectorAll("#rant
> span.shake-opacity
");
1204 for (k = 0; k < opacities.length; k++) {
1205 shrek=Math.random();
1206 opacities[k].style.animationDuration = shrek + 's';
1207 opacyTexts.push(opacities[k].outerHTML);
1211 for (l = 0; l< crazyTexts.length; l++) {
1212 allText+=crazyTexts[l] + (opacyTexts[l] ? opacyTexts[l] : "");
1215 document.getElementById('rant').innerHTML = allText;
1219 var b = document.querySelectorAll('body')[0];
1220 setInterval(function(){
1223 b.style.backgroundPosition = x + 'px ' + y + 'px';
1226 urlParts = document.URL.split('#');
1227 window.console.log(urlParts);
1228 var currentSlide = urlParts.length > 1 ? urlParts[1] : 0;
1229 var bc = new BroadcastChannel('test_channel');
1230 document.getElementById('slide-' + currentSlide).style.display = 'block';
1231 document.onkeydown = checkKey;
1233 notes = document.querySelectorAll('#slide-' + currentSlide + ' .notes');
1235 bc.postMessage(notes[0].innerHTML);
1238 function checkKey(e) {
1240 e = e || window.event;
1241 if (e.keyCode == '37') {
1242 if (document.getElementById('slide-' + currentSlide)) {
1243 document.getElementById('slide-' + currentSlide).style.display = 'none';
1246 document.getElementById('slide-' + currentSlide).style.display = 'block';
1248 notes = document.querySelectorAll('#slide-' + currentSlide + ' .notes');
1250 bc.postMessage(notes[0].innerHTML);
1255 else if (e.keyCode == '39') {
1256 if (document.getElementById('slide-' + currentSlide)) {
1257 document.getElementById('slide-' + currentSlide).style.display = 'none';
1260 document.getElementById('slide-' + currentSlide).style.display = 'block';
1262 notes = document.querySelectorAll('#slide-' + currentSlide + ' .notes');
1264 bc.postMessage(notes[0].innerHTML);
1273 function activateFriends(n, noshake) {
1274 f = document.querySelectorAll('.code-friends' + n);
1276 for (fr = 0; fr< f.length; fr++) {
1278 f[fr].classList.add("shake-constant
");
1279 f[fr].classList.add("shake-slow
");
1281 f[fr].classList.add("on
");
1285 function deactivateFriends(n) {
1286 f = document.querySelectorAll('.code-friends' + n);
1287 for (fr = 0; fr< f.length; fr++) {
1288 f[fr].classList.remove("shake-constant
");
1289 f[fr].classList.remove("shake-slow
");
1290 f[fr].classList.remove("on
");
1294 function activatePromise(n) {
1295 p = document.querySelectorAll('.promise' + n);
1296 for (fr = 0; fr< p.length; fr++) {
1297 p[fr].classList.add('on');
1301 function deactivatePromise(n) {
1302 p = document.querySelectorAll('.promise' + n);
1303 for (fr = 0; fr< p.length; fr++) {
1304 p[fr].classList.remove('on');
1309 "Welcome to the talk!
",
1310 "I hope we'll have fun exploring functional programming together!
",
1311 "But while we wait let's share interesting facts and anectodes :)
",
1312 "If you can be disgruntled, can you also be gruntled?
",
1313 "0.9 recurring is exactly equal to one if you think about it.
",
1314 "In English, the word
\"ghoti
\" can be pronounced as
\"fish
\".
",
1315 "Your credit card details are somewhere in Pi.
",
1316 "It takes
366 people to make sure two of them share a birthday, but only
23 people to ensure a
50% chance.
",
1317 "1729 is the best number (I checked them all).
",
1318 "The secret to strengh is to eat only a banana for breakfast.
",
1319 "All of Back to the Future happened in the past.
",
1320 "Everything is in the future.
",
1321 "We owe functional and procedural programming to the pre-Socratics, Heraclitus and Anaximander respectively.
",
1322 "Preservative has a very different meaning in many European languages
",
1323 "There are more stars in our galaxy than there are atoms in The Universe
"
1326 cgq = document.getElementById("cgquotes
");
1327 numQuotes = cloudGuyQuotes.length;
1329 setInterval(function(){
1330 if (currentQuote == 0 || currentQuote == 1) {
1333 currentQuote = Math.floor(Math.random()*(cloudGuyQuotes.length - 3)) + 3;
1334 console.log(currentQuote);
1337 cgq.innerText = cloudGuyQuotes[currentQuote];
1349 function animateCSS(element, animationName, callback) {
1350 const node = element;
1351 node.classList.add('animated', animationName)
1353 function handleAnimationEnd() {
1354 node.classList.remove('animated', animationName)
1355 node.removeEventListener('animationend', handleAnimationEnd)
1356 node.style.opacity = '0';
1357 if (typeof callback === 'function') callback()
1360 node.addEventListener('animationend', handleAnimationEnd)
1363 helpers = document.querySelectorAll("#cloudguys span
");
1364 setInterval(function(){
1365 quote = Math.floor(Math.random()*(helperQuotes.length));
1366 helper = Math.floor(Math.random()*(helpers.length));
1367 helpers[helper].innerText = helperQuotes[quote];
1368 animateCSS(helpers[helper], 'fadeOutUp');
1372 angeries = document.querySelectorAll(".angereyWrap
");
1374 shakes = ["shake
", "shake-hard
", "shake-slow
", "shake-little
", "shake-horizontal
", "shake-vertical
", "shake-rotate
", "shake-opacity
", "shake-crazy
", "shake-chunk
"];
1375 for (a = 0; a < angeries.length; a++) {
1376 randomness = (Math.round(Math.random() * 10) + 1) * -10;
1377 angeries[a].style.top = ((a > 4) ? (-180-randomness) : (180 + randomness)) + "%
" ;
1378 thing = ((Math.floor(Math.random() * 10) + 1) * 9) + "%
";
1380 while (usedPositions.includes(thing)) {
1381 thing = ((Math.floor(Math.random() * 10) + 1) * 9) + "%
";
1384 angeries[a].style.left = thing;
1385 angeries[a].classList.add("shake-constant
");
1386 angeries[a].classList.add(shakes[Math.floor(Math.random()*shakes.length)]);
1387 usedPositions.push(thing);
1390 thonkings = document.querySelectorAll(".thonkingWrap
");
1391 shakes = ["shake-slow
", "shake-little
", "shake-opacity
"];
1393 for (a = 0; a < thonkings.length; a++) {
1394 thing = Math.floor(Math.random() * 4) + 1;
1395 randomnessX = -(Math.round(Math.random() * 100) + 1);
1396 randomnessY = -(Math.round(Math.random() * 50) + 1);
1398 while (usedPositions.includes(thing)) {
1399 thing = Math.floor(Math.random() * 4) + 1;
1404 thonkings[a].style.left = randomnessX + 'px';
1405 thonkings[a].style.top = randomnessY + 'px';
1406 thonkings[a].children[0].style.transform = 'rotate(-40deg) scale(1, 1.5)'
1407 thonkings[a].classList.add("shake-constant
");
1408 thonkings[a].classList.add(shakes[Math.floor(Math.random()*shakes.length)]);
1411 thonkings[a].style.right = randomnessX + 'px';
1412 thonkings[a].style.top = randomnessY + 'px';
1413 thonkings[a].classList.add("shake-constant
");
1414 thonkings[a].children[0].style.transform = 'rotate(40deg) scale(1, 1.5)'
1415 thonkings[a].classList.add(shakes[Math.floor(Math.random()*shakes.length)]);
1418 thonkings[a].style.right = randomnessX + 'px';
1419 thonkings[a].style.bottom = randomnessY + 'px';
1420 thonkings[a].classList.add("shake-constant
");
1421 thonkings[a].children[0].style.transform = 'rotate(-215deg) scale(1, 1.5)'
1422 thonkings[a].classList.add(shakes[Math.floor(Math.random()*shakes.length)]);
1425 thonkings[a].style.left = randomnessX + 'px';
1426 thonkings[a].style.bottom = randomnessY + 'px';
1427 thonkings[a].classList.add("shake-constant
");
1428 thonkings[a].children[0].style.transform = 'rotate(215deg) scale(1, 1.5)'
1429 thonkings[a].classList.add(shakes[Math.floor(Math.random()*shakes.length)]);
1434 usedPositions.push(thing);