Grokking Simplicity

Grokking Simplicity

May 9, 2022

The notes are for the book [1]



“Side effects are anything a function does other than returning a value, like sending an email or modifying global state” See [1, p. 2], but real-world cases require side effects from FP.See [1, p. 3]

The book categorize codes into three types: See [1, pp. 7–8]

  • Actions. Depend on when and how many times they run. Suggesting they are not idempotent.
  • Calculations. Executable codes that produce outputs from inputs. Idempotent.
    • Depend on inputs only, no other implicities.
    • Have explicit outputs (returns), no implicities (printing/popup/etc.) See [1, p. 68]
    • Don’t change anything outside their own
    • accessing/changing shared, mutable variables is an Action. See [1, p. 57]
    • Creating variables that depend on implicities is an Action. See [1, p. 57]
    • Printing to console and showing popups are Actions. See [1, p. 57]
  • Data. Not executable and is recorded facts about events.

the preference of them should be Data > Calculations > Actions. For even a single business logic, its codes can be separated into these three types.See [1, p. 9]

Functions that contain action(s) are also actions.See [1, pp. 54–55]

On distributed systesms: See [1, p. 11]

  • messages arrive out of order
  • messages may arrive any times
  • no feedback = no idea what happened

One way to resolve the issue is called cutting: systems working independently but wait for each other to finish when they’re done See [1, pp. 25–26]

Principles of FP:

Minimize implicit inputs and outputs See [1, p. 91]

  • Implicit inputs are all of the inputs that aren’t arguments
  • Implicit outputs are all of the outputs that aren’t the return value

Design is to pulling things apart (低耦合) for easier: See [1, p. 98]

  • resuse
  • maintain
  • test

Staying with immutable variables by:

  • Converting a write to a read with copy-on-write See [1, p. 113]
<style>.csl-left-margin{float: left; padding-right: 0em;}
 .csl-right-inline{margin: 0 0 0 1em;}</style><div class="csl-bib-body">
  <div class="csl-entry"><a id="citeproc_bib_item_1"></a>
    <div class="csl-left-margin">[1]</div><div class="csl-right-inline">E. Normand, <i>Grokking simplicity: Taming complex software with functional thinking</i>. Shelter Island, NY: Manning Publications Company, 2021. </div>

No notes link to this note

comments powered by Disqus