Skip to content

Instantly share code, notes, and snippets.

@jdwolk
Created June 5, 2020 19:15
Show Gist options
  • Save jdwolk/ec774510ec2281a46c4ab726b3b49672 to your computer and use it in GitHub Desktop.
Save jdwolk/ec774510ec2281a46c4ab726b3b49672 to your computer and use it in GitHub Desktop.
FP in 5 mins

Functional Programming in 5 minutes

* What is it (in general)?
  * Programming w/ functions!!!































* What is it (specifically)
  * Higher order fns
  * immutable data
  * (in typed langs) higher-kinded types
  * minimizing stateful interactions
  * separating side-effectful code from "pure" (referentially transparent) code

































* How to apply concepts in existing codebases, not necessarily in pure FP langs/libs/frameworks
  * leverage higher order fns (or make them)
  * separate out pure functions from side effets
  * don't use object local state if you don't need it
  * think in terms of verbs/actions rather than nouns/things
  * pass around data structures rather than embedding it in objects
    * let data be data


































* Upsides
  * Lends itself to easier concurrency
  * Tends to be easier to reason about (depending on your brain)
  * Eliminates whole classes of errors
    * No ordering problems related to when state is changed out from under you
    * higher order fns + "pointfree" programming generally mean less variables / less code. Less code == less bugs






























* Tradeoffs
 * The expression problem
 * Certain problems are more difficult to represent
 * Education / team buy-in



































                  THANKS!!!!!!!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment