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.

Make javascript great again | OdessaFrontend Meetup #8

136 views

Published on

Функциональная парадигма или функциональное програмирование — способ написания кода, покрытый множеством мифов и недопониманий. Сторонники говорят, что это самый элегантный способ писать код, а скептики утверждают о непрагматичности и излишней сложности подхода. Алексей Шулев рассказывает об основах функционального програмирования и о том, как писать код в этом стиле в ваших текущих javascript проектах.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Make javascript great again | OdessaFrontend Meetup #8

  1. 1. MAKE JAVASCRIPT GREAT AGAIN FUNCTIONAL PROGRAMMING OR HOW TO Alex Shulev: https://www.facebook.com/Allexy.sleeps

  2. 2. MY HISTORY TO SLAP A FORM ▸ Layout ▸ Basic JS ▸ React/Angular/Vue ▸ Some Node.js ▸ ∞ number of libraries and frameworks ▸ Death
  3. 3. FUNCTIONAL PROGRAMMING ADD UNNEEDED COMPLICATION INTO YOUR CODE Core Functional Programming Concepts ▸ Immutability ▸ Purity ▸ First class functions & Lambda functions (Lambda calculus)
  4. 4. IMMUTABILITY RETURN NEW DATA INSTEAD OF MODIFYING AN OLD ONE var let push pop shift unshift splice for while const concat {...} slice reduce reduceRight map filter
  5. 5. PURITY SAY NO TO SIDE EFFECTS
  6. 6. LAMBDA CALCULUS PASS AND RETURN FUNCTIONS AS VARIABLES
  7. 7. COMPOSING FUNCTION f(a, b, c)(x) = f(a(b(c(x))))
  8. 8. CURRYING f(a, b, c)(x) = f(a)(b)(c)(x)
  9. 9. FUNCTIONAL STYLE IN ACTION ▸ Pointfree ▸ Data last ▸ Abstractions over native methods ▸ Separate Pure functions from Impure 0/ ▸ Sexy “one liners” <3
  10. 10. SUMMARY ▸ Controlling side effects ▸ Testing ▸ Compressed and predictable code Pros Cons ▸ Slow in some specific tasks ▸ Can be confused in the beginning
  11. 11. WANT MORE? ▸ Data structures and algorithms ▸ Mostly adequate guide to functional programming ▸ Libraries: 
 Data transformation: Rambda, Lodash/FP, 
 Monoids: crocks.js, folktale ▸ Fantasy-land, Lambda Calculus ▸ Pure functional languages: Clojure, Haskell, Scala … ▸ Books ▸ Bravery
  12. 12. Ωuestions?

×