Underscore

14,703 views

Published on

Published in: Technology

Underscore

  1. 1. “Hey Underscore,You’re doing it wrong”You’re doing it wrong”
  2. 2. I <3 _
  3. 3. So what’s wrong then?
  4. 4. Agenda• Currying• Composition• Functors• Random stuff
  5. 5. Currying
  6. 6. Curried Function“A function that will return a new function until it receives all it’s arguments”
  7. 7. ...weird
  8. 8. Wu.js to the rescue! (well, one function at least) (well, one function at least)
  9. 9. not weird
  10. 10. Example
  11. 11. 0 0 ExampleFunctional Underscore
  12. 12. 1 0 ExampleFunctional Underscore
  13. 13. 2 0 ExampleFunctional Underscore
  14. 14. 3 0 ExampleFunctional Underscore
  15. 15. underscore’s apiprevents you from currying
  16. 16. Currying• Make generic functions - data is gone• Build new functions by applying args• Much more concise definitions• Make types “line up” for composition
  17. 17. Composition
  18. 18. Category Theory“The mathematical theory of transforming values and crap” *inaccurate definition
  19. 19. Example
  20. 20. 3 0 ExampleFunctional Underscore
  21. 21. 4 0 ExampleFunctional Underscore
  22. 22. 5 0 ExampleFunctional Underscore
  23. 23. underscorepromotes chain as the function of choice.
  24. 24. Composition• Build new functions from other functions• Helps build generic programs w/o args• Extremely high level coding• Mathematically backed
  25. 25. Functors
  26. 26. Example
  27. 27. 5 0 ExampleFunctional Underscore
  28. 28. 6 0 ExampleFunctional Underscore
  29. 29. 7 0 ExampleFunctional Underscore
  30. 30. underscore explicitly prevents extending map
  31. 31. s• Change behavior without altering function open/closed principle• Not just map - reduce, compose, etc• Intuition and “non proprietary” api• Free formulas• Dynamic type safety?
  32. 32. In conclusion

×