Functional Programming “As simple as it could be” By: Ayat Khraisat
What we are going to discuss? • We are not going to discuss code. • What’s pure function is? • First class citizens, higher order functions. • Referentially Transparent. • Functional, Imperative or Reactive. • Functional benefits.
We are not talking about something new
Pure Functions • You are not pure if you changes with time. • You are not pure if you changes you answer. • You are not pure if you mutate the system state or any side effects. • You not pure if you depends on global state.
Change state produces Bugs So Use constants as much as you can. No statements just expressions. Also as much as you can No void functions.
Higher Order Functions a function that takes function or returns
Function is considered First Class Citizen if it can assigned to variables or stored in data structures and and sent/returned from other one.
Referentially transparent There are many ways to REFERENCE that thing. You should read “transparent” to mean “doesn’t make a difference” A function Referentially transparent is call to this method may be replaced by its return value X= 5+(1+3) or X= 5+4 or X=9
Functional does not mean Reactive
Functional programming does not conflict with OOP
Why Should we change?
1. No Asking what’s is the state? “Easier Debugging” 2. Simpler Easier and more Cleaner. 3. less NPE. 4. Less change state errors. 5. Less Interfaces and delegates. 6. Reusability. 7. You will find more when you start using it. Functional Programming Benefits
No program can be functional forever “At some point, it needs to be imperative and spell out to the computer exactly how to do something, and it needs to modify state (whether that is updating a View, writing to the server, or just printing to console)”
What do you think, should we change?

Functional programmning

  • 1.
    Functional Programming “As simpleas it could be” By: Ayat Khraisat
  • 2.
    What we aregoing to discuss? • We are not going to discuss code. • What’s pure function is? • First class citizens, higher order functions. • Referentially Transparent. • Functional, Imperative or Reactive. • Functional benefits.
  • 3.
    We are nottalking about something new
  • 4.
    Pure Functions • Youare not pure if you changes with time. • You are not pure if you changes you answer. • You are not pure if you mutate the system state or any side effects. • You not pure if you depends on global state.
  • 5.
    Change state producesBugs So Use constants as much as you can. No statements just expressions. Also as much as you can No void functions.
  • 6.
    Higher Order Functions afunction that takes function or returns
  • 7.
    Function is consideredFirst Class Citizen if it can assigned to variables or stored in data structures and and sent/returned from other one.
  • 8.
    Referentially transparent There aremany ways to REFERENCE that thing. You should read “transparent” to mean “doesn’t make a difference” A function Referentially transparent is call to this method may be replaced by its return value X= 5+(1+3) or X= 5+4 or X=9
  • 9.
    Functional does notmean Reactive
  • 10.
    Functional programming doesnot conflict with OOP
  • 11.
  • 12.
    1. No Askingwhat’s is the state? “Easier Debugging” 2. Simpler Easier and more Cleaner. 3. less NPE. 4. Less change state errors. 5. Less Interfaces and delegates. 6. Reusability. 7. You will find more when you start using it. Functional Programming Benefits
  • 13.
    No program canbe functional forever “At some point, it needs to be imperative and spell out to the computer exactly how to do something, and it needs to modify state (whether that is updating a View, writing to the server, or just printing to console)”
  • 14.
    What do youthink, should we change?

Editor's Notes

  • #4 Functional programming was invented in 1957 before OO and structured. But memory was too expensive to make it practical. Memory is cheap now. https://www.youtube.com/watch?v=7Zlp9rKHGD4
  • #5 https://www.youtube.com/watch?v=7Zlp9rKHGD4
  • #6 There is no void in Kotlin Statements vs Expression https://blog.kotlin-academy.com/kotlin-programmer-dictionary-statement-vs-expression-e6743ba1aaa0
  • #7 Not All languages support Higher order functions, Swift, Kotlin do!
  • #14 Excerpt From: Christopher Arriola. “Reactive Programming on Android with RxJava”