SlideShare a Scribd company logo
“Hey Underscore,
You’re doing it wrong”
You’re doing it wrong”
I <3 _
So what’s wrong then?
Underscore
Agenda

• Currying
• Composition
• Functors
• Random stuff
Currying
Curried Function
“A function that will return a new function until it
           receives all it’s arguments”
Underscore
Underscore
Underscore
...weird
Wu.js to the rescue!
  (well, one function at least)
  (well, one function at least)
Underscore
Underscore
not weird
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Example
0      0
   Example
Functional   Underscore
1      0
   Example
Functional   Underscore
2      0
   Example
Functional   Underscore
3      0
   Example
Functional   Underscore
underscore’s api
prevents you from
     currying
Underscore
Currying

• Make generic functions - data is gone
• Build new functions by applying args
• Much more concise definitions
• Make types “line up” for composition
Composition
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Category Theory
“The mathematical theory of transforming values
                  and crap”



                                *inaccurate definition
Underscore
Underscore
Underscore
Example
3      0
   Example
Functional   Underscore
4      0
   Example
Functional   Underscore
5      0
   Example
Functional   Underscore
Underscore
underscore
promotes chain as
  the function of
      choice.
Underscore
Composition
• Build new functions from other functions
• Helps build generic programs w/o args
• Extremely high level coding
• Mathematically backed
Functors
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Underscore
Example
5      0
   Example
Functional   Underscore
6      0
   Example
Functional   Underscore
7      0
   Example
Functional   Underscore
underscore explicitly
 prevents extending
        map
Underscore
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?
In conclusion

More Related Content

Underscore