From c7afce68ec87b2f1b220996bcc8b92bee6f86996 Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Mon, 16 Mar 2020 23:12:25 +0800 Subject: [PATCH] Add slides about gramatical mood and junk --- index.html | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 179 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index f98421d..7aac56e 100644 --- a/index.html +++ b/index.html @@ -138,7 +138,7 @@ display: none; } - span[class^="code-friends"].on, span[class^="code-friends"].on > span { + span[class^="code-friends"].on, span[class^="code-friends"].on > span, span[class^="code-friends"].on > span > span { color: #f98012 !important; } @@ -153,6 +153,7 @@ li { margin-top: 10px; } + @@ -192,6 +193,174 @@
+
=<< Paradigms >>=
+
+
+ Declarative +
+ Functional +
    +
  • Haskell
  • +
  • Elm
  • +
  • Elixir
  • +
  • Clojure
  • +
+
+
+
+ Imperative +
+ Procedural +
    +
  • PHP
  • +
  • C
  • +
  • Java
  • +
  • DamoScript
  • +
+
+
+
+
+
+
=<< Gramatical Mood >>=
+
+
+ Declarative + A sentence which expresses a statement of fact. +
    +
  • He runs.
  • +
  • I like climbing.
  • +
  • Ice is cold.
  • +
  • Mathieu is shredded.
  • +
+
+
+ Imperative + A sentence which expresses instructions, or requests. +
    +
  • Shut the door.
  • +
  • Don't eat my burger.
  • +
  • Let's go to the pub.
  • +
  • Don't make eye contact with Mathieu.
  • +
+
+
+
+
+
=<< Gramatical Mood >>=
+
+
+ Declarative + This is this. +
+
+ Imperative + Do this. +
+
+
+
+
=<< Big Brain Moment >>=
+
+
Programming languages ARE human languages.
+
+
+
+
=<< Some Code (Finally) >>=
+
+

The Great Dividers

+

Consider:

+
+
x = x + 1;
+
+
+ and: +
+
+
function repeat(x) {
+    return x + repeat(x);
+}
+
+

OK, so what?

+
+
In the declaritive paradigm, this code hangs while this code runs. In the imperative paradigm this code hangs, while this code runs.
+
+
+
+
+
=<< Some Code (Finally) >>=
+
+
+
x = x + 1;
+
+
+
+ Declarative + "x is the same as itself plus one."




+ Complete nonsense! +
+
+ Imperative + "Evaluate the thing on the right of `=` then store it in the thing on the left of `=`."


+ A list of instructions that can be followed. +
+
+
+
+
+
=<< Some Code (Finally) >>=
+
+
+
function repeat(x) {
+    return x + repeat(x);
+}
+
+
+
+ Declarative + "The repeat of `x` is `x` appended to the repeat of `x`"


+ An infinite list of `x`! +
+
+ Imperative + "To evaluate the repeate of `x`, first evaluate the repeat of `x`""


+ ...Yeah, you see the problem? +
+
+
+
+
+
=<< Big Brain Moment >>=
+
+
Programming languages ARE human languages.
+
+
+
+
=<< Some Code (Finally) >>=
+
+

Real Haskell Code That Runs

+
repeat x = x ++ repeat x
+threeFs = take 3 (repeat "f")
+
+> "fff"
+
+
+
+
+
=<< Some Code (Finally) >>=
+
+

Real JavaScript Code That Hangs

+
function repeat(x) {
+    return x + repeat(x);
+}
+
+threeFs = repeat("f").substr(0,3);
+
+> InternalError: too much recursion
+
+
+
+
=<< Promises >>=
@@ -208,10 +377,10 @@ Promises do not make things asynchronous!
-
+
=<< Promises >>=
-

What problems do promises solve?

+

What problems do promises solve?

  • Asynchronous request management
  • @@ -219,7 +388,7 @@
  • Probably more too
-

What are promises then?

+

What are promises then?

  • A value (which may or may not be available yet) wrapped in some additional context
  • @@ -229,7 +398,7 @@
-
+
=<< Promises >>=

Terminology/syntax recap

@@ -251,7 +420,7 @@
-
+
=<< Promises >>=

Promise composition

@@ -272,7 +441,7 @@
-
+
=<< Promises >>=

OK great but who cares?

@@ -288,7 +457,7 @@
-
+
=<< Promises >>=
@@ -300,7 +469,7 @@
-
+
=<< Promises >>=

Woah!

@@ -314,7 +483,7 @@ >>= (\x -> Right (x ++ " and finally here!"))
-
+
=<< Promises >>=

Woah!

-- 2.11.0