WarsawJS Presentation Template

We talk about JavaScript. Each month in Warsaw, Poland.

Functional techniques and tools for the frontend

Piotr Klibert

The 2 rather distinct traditions

  1. ML-based: statically typed + inference, AOT compilation (invented: 1966)
    • Examples: Haskell, Scala, OCaml, F#, Idris, Rust...
  2. Lisp-based: dynamic, reflective, dynamically typed, interpreted or JIT compiled (invented: 1958)
    • Examples: Clojure, Dylan, Pyret, Erlang, ... and also JavaScript!

Important cultural note:

Both are equally FP!

Despite what some people like to say, neither static typing nor purity, laziness or deep mathematical knowledge are required for programming in functional style or using FP techniques.

In practice FP is about:

  1. declarative instead of imperative style
  2. composability of abstractions
  3. simplicity of functions
  4. preference for:
    • immutability
    • purity/referential transparency

Practical benefits of FP

  1. brevity, conciseness
  2. easier unit testing
  3. easier to follow code
  4. less opportunities to screw up

Language support for FP

  1. functions as first class values
  2. lexical-scoping and closures
  3. (optional) tail-recursion optimization
  4. (optional) automatic currying

Library support for FP

Available tools: libraries

Available tools: languages

Isn't plain JavaScript enough?

Functional techniques

by example

Examples live on a different page because of a "literate-like" format I used to create them: feel free to go look at them and get back here when you're bored.

Not covered/next time

Links, more info

Fork me on Github