Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

10 good reasons to invest your time in FP

http://www.thedevelopersconference.com.br/tdc/2014/portoalegre/trilha-linguagens-funcionais

  • Login to see the comments

  • Be the first to like this

10 good reasons to invest your time in FP

  1. 1. #10 good reasons to invest your time in FP Humberto Streb @humbertostreb Joel Corrêa @joelcorrea_
  2. 2. #1 Learn
  3. 3. #2 Parallel collections
  4. 4. Multicore powered Parallel collections F#
  5. 5. Collection operations: Map - Reduce
  6. 6. Higher order functions Map –> Applies a given fn to each element Reduce –> Combine / Accumulate / fold / compress results though combining operation
  7. 7. Sample
  8. 8. Map Map age 20 18 25 41 29 32 38 30
  9. 9. Reduce 20 18 25 44 29 32 … 236 Combining fn: a+b (operation = +)
  10. 10. + Data Map age Map age Map age Map age
  11. 11. map in parallel
  12. 12. reduce in parallel
  13. 13. filter in parallel
  14. 14. #3 Focus
  15. 15. Boilerplate code
  16. 16. REPL
  17. 17. #4 Troubleshooting
  18. 18. Same result value given the same arguments
  19. 19. Troubleshooting in FP Referential transparency Consistency No global state Arguments only Once wrong, always wrong
  20. 20. #5 State discipline
  21. 21. Side effects…
  22. 22. Pure function
  23. 23. Immutable It is highly recommended that value objects be immutable. They are created with a constructor, and never modified during their life time. Eric Evans
  24. 24. Immutable
  25. 25. Immutable
  26. 26. #6 Built-ins
  27. 27. Futures Non-Blocking Parallel
  28. 28. Optionals Null checks Explicit
  29. 29. Interoperability
  30. 30. #8 Simplicity #7 Simplicity
  31. 31. #8 Simplicity Salesmen…
  32. 32. #8 Simplicity
  33. 33. #8 Composition
  34. 34. # Building blocks Inheritance Polymorphism HOFs Composition OOP = Objects FP = Functions Real world / Complex scenarios
  35. 35. # HOFs Receives fn
  36. 36. # Partially applied Returns fn
  37. 37. # Composition
  38. 38. #9 Testability
  39. 39. Hard to test if($player->getScore() > 0) {! !$player->setSwizzle(7);! } else {! !$player->setSwizzle(! ! !$player->getSwizzle() + 1;! !);! }!
  40. 40. #10 Principles
  41. 41. FP in non-FP languages Referen'al transparency Side effects Immutabilit y Guidelines
  42. 42. FP in non-FP languages functools LuaFun
  43. 43. # Challenges ahead
  44. 44. Readability / Expressiveness
  45. 45. Learning curve
  46. 46. Samples https://github.com/jjcorrea/ TenGoodReasonsToInvestYourTimeInFP Resources http://twitter.github.io/scala_school/ http://twitter.github.io/effectivescala http://coursera.org/course/progfun

×