February 23, 2020

Functional Programming is Terrible


RĂșnar Bjarnason, Software Developer


I tried to learn Scala in the past and I still have several books about it. I am not so inclined to get back to it either, but I like to watch presentations about concepts and how the Scala community handles some issues.

That seems really complicated. I can’t understand the type system correctly and the syntax is very terse as well (says the lisp guy…​).

But the last point of his talk about happiness is interesting. But, for some reason, people into FP seems really more engaged with software development and willing to make this right.

The idea of building something that just works and is simple, concise, with small branches for unexpected behavior is the same kind of pride that mathematicians have about their axioms and proofs.


Reason #1: Tail call elimination

Trampolines trade-offs

  1. Memory overhead

  2. Programmer overhead

  3. Performance overhead

  4. But.. monads in Scala are basically useless without them

Reason #2: Higher-kinded types that allow you to write higher order abstractions

Kinds in Scala

  1. Never inferred

  2. Never polymorphic

  3. Never curried


  1. The solution to R#1 because of Java requirements for having a stack is trampolines

  2. FP made less terrible

    1. Tail call elimination

    2. Kind inference

    3. Better type inference (recursive functions, etc.)

    4. Unboxed function references

    5. Existential types rather than Any

    6. Universal quantification

    7. Effects tracked in types

  3. Modularity: Software is modular to the extent that its parts can be separated and recombined

  4. FP makes us happy!

    1. Programming is exhilarating! (at least at the beginning!)

    2. it quickly becomes a huge ball of mud.

    3. Less friction and frustration

    4. More predictable

    5. Less cognitive load

    6. Smaller solution space

    7. Pride

Tags: programming functional