Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?

Weitere Verwandte Inhalte

Ähnliche Bücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen

Ähnliche Hörbücher

Kostenlos mit einer 30-tägigen Testversion von Scribd

Alle anzeigen

WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?

  1. 1. WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? Feb 2, 2016 Welcome to Fantasy Land!
  2. 2. Functional Programming Visualized
  3. 3. Core Functional Concepts First Class Functions stored in variables, passed as arguments to functions, created within functions and returned from functions Higher Order Functions can accept functions as arguments, and/or can return a function Pure Functions is a function where the return value is only determined by its input values, without observable Side Effects Referential Transparency for a given set of arguments, the same code should always output the same value, only by changing arguments can a output value be different Immutability is an inability for variables to change their values once created. In other words, all things created stay constant
  4. 4. Core Functional Concepts Currying / Partial Application - ability of a function to return a new function until it receives all it's arguments. Calling a curried function with only some of its arguments is called partial application Tail Call Optimization - ability to avoid allocating a new stack frame for a function call. The most common use is tail-recursion, where a recursive function uses constant stack space. Pattern matching is a form of conditional branching which allows you to concisely match on data structure patterns and bind variables at the same time Lazy Evaluation means that expressions are not evaluated when they are bound to variables, but their evaluation is deferred until their results are needed by other computations
  5. 5. Recommended Reading Mostly Adequate Guide to Functional Programming, https://drboolean.gitbooks.io/mostly-adequate-guide/content/ Tail call optimization in ECMAScript 6, http://www.2ality.com/2015/06/tail-call-optimization.html Functional Pattern Matching in JavaScript, https://github.com/bramstein/funcy Functional JavaScript Fundamentals http://www.slideshare.net/Ssrdjan/functional-javascript-37401024 Want more? Put previously mentioned terms in Twitter ;)))
  6. 6. SO WHY FUNCTIONAL PROGRAMMING IS SO HARD?
  7. 7. WHY SO HARD? Luck of understanding modern JavaScript aka ES6 https://github.com/reactima/reactima-redux-ecosystem/blob/master/JS.md
  8. 8. WHY SO HARD? Imperative Habits Most of us spend our lives, in looping structures and if-then-else statements. It’s hard to treat functions as variables and see chaining process
  9. 9. 99% of PROGRAMMERS DO THIS
  10. 10. FUNCTIONAL MINDED CODE
  11. 11. WHY SO HARD? map, http://ramdajs.com/docs/#map filter, http://ramdajs.com/docs/#filter concatAll, http://ramdajs.com/docs/#concat reduce, http://ramdajs.com/docs/#reduce zip, http://ramdajs.com/docs/#zip Luck of creativity with the most important functions * - 80% of functional code in business apps can be constituted from the above 5 function
  12. 12. WHY SO HARD? MATH TERMS ARE ANNOYING Most developers don’t bother to understand underlying concepts
  13. 13. MONAD Monad is defined computation as sequences of steps: a type with a monad structure defines what it means to chain operations, or nest functions of that type together. This allows the programmer to build pipelines that process data in steps, in which each action is decorated with additional processing rules provided by the monad https://en.wikipedia.org/wiki/Monad_(functional_programming) Monads in JavaScript, https://curiosity-driven.org/monads-in-javascript Functors, Applicatives, And Monads In Pictures http://adit.io/posts/2013-04-17- functors,_applicatives,_and_monads_in_pictures.html
  14. 14. CRAZY? 99% of developers would never bother understand the next slide
  15. 15. WELCOME TO FANTASY LAND! Spend some time with specification for interoperability of common algebraic structures in JavaScript VISIT US! https://github.com/fantasyland/fantasy-land
  16. 16. DEATH CHART Issue Open vs. Close Rate Over a Four Month Period IMPERATIVE HABITS CONTRIBUTE A LOT TO THIS CHART!
  17. 17. NEXT? I don’t understand concepts! I just like to do coding! SHOW ME THE CODE! I don’t understand concepts! SHOW ME THE CODE!
  18. 18. READ RAMDA TESTS! https://github.com/ramda/ramda/tree/master/test
  19. 19. Thank you! Ilya Sidorov @reactima Interested to talk? Let’s have a skype call: ilya.sidorov 1@ilya1.com https://www.linkedin.com/in/reactima https://github.com/reactima/

×