Skip to content

Files

Latest commit

 

History

History
147 lines (118 loc) · 3.29 KB

PITCHME.md

File metadata and controls

147 lines (118 loc) · 3.29 KB

@colorGoldenRod

functional programming?


before we jump to that...


What should we @colorIndianRed

from a fp workshop?


It's a bit like

@colorGoldenRod to program @colorIndianRed


@color[IndianRed](do not judge)

what you will see

@color[GoldenRod](with the eyes of)

what you know today


take this workashop as

a @colorGoldenRod and @colorGoldenRod

to @colorIndianRed and @colorIndianRed


@colorGoldenRod your @colorIndianRed


@colorGoldenRod

functional programming?


@colorGoldenRod


Functional Programming

@color[GoldenRod](compose functions) as a central

building block to write software


why @colorGoldenRod is so @colorIndianRed?


How do we solve problems? We decompose bigger problems into smaller problems. If the smaller problems are still too big, we decompose them further, and so on.


Finally, we write code that solves all the small problems.


And then comes the essence of programming: we compose those pieces of code to create solutions to larger problems.


Decomposition wouldn’t make sense if we weren’t able to put the pieces back together. - Bartosz Milewski


True Story

In Complex System we dedicate

@color[IndianRed](a significant portion)

of code and effort

@color[GoldenRod](to compose) pieces togheter


@colorGoldenRod is the number one @colorIndianRed of composition?


side-effects


it can't compose

val toS : Int => String = n => {
  appendAll("log.txt", "some content")
  n.toString
}

it can't compose

val list = collection.mutable.ListBuffer[Int]()

val toS : Int => String = n => {
  list += n
  if (list.size < 42) n.toString
  else "Yo!"
}

Side-effects are a @color[IndianRed](complexity source)

  • hide inputs and outputs
  • destroy testability
  • destroy composability

In other words

FP is about @colorIndianRed or @colorGoldenRod side-effects


How?

see “function” as the @colorIndianRed one:

  • @colorGoldenRod: it must yield a value for every possible input
  • @colorGoldenRod: it must yield the same value for the same input
  • @colorGoldenRod: it’s only effect must be the computation of its return value

We earn back

all functions become @color[GoldenRod](referentially transparent)


Referential Transparency

An @color[GoldenRod](expression can be replaced) with
its corresponding value @color[IndianRed](without changing)
the program's behavior


Referential Transparency

it means these two programs are @colorGoldenRod

val y = foo(x)
val z = y + y
val z = foo(x) + foo(x)

RT Benefits

functions get an @color[IndianRed](extraordinary quality) boost:


@colorGoldenRod

mathematicians do

@color[IndianRed](refactor their "code")

since long before us

\[ x(y + z) = (xy) + (xz) \]