Functional Programming
(for mortals)
Follow Along
slides.com/willengler/fpmortals/live#/
Tracks
- Functional Programming for Mortals
- Ruby on Rails
Tell Us What You Think!
What I'm Gonna Say
- Why is everyone talking about FP all of a sudden?
- What is FP?
- Where can I learn more?
What I Want You to Get Out of It
- Understand that FP is not just for people with Phd's.
- Nod thoughtfully when people talk about lambdas.
- Get amped for the rest of the series.
Part 1: Functional Is Trendy
OOP on Trial
- "Object Oriented Programming Is an Expensive Disaster which Must End" (link)
Fear
- Do I need to learn category theory?
- Do I have to write everything in Clojure now?
- Does this make me a programming hipster?
Simple Concepts, Big Names
One of those things that I can do that makes me feel competent is to throw around buzzwords and have discussions where it’s like, “Yeah, we all know what we’re talking about here. We’re competent professionals who know what we’re talking about because we know these words.
- Avdi Grimm
Part 2: Demystifying FP
Functional Programming
... a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data.
- Wikipedia
Lambda (for Gods)
"... a function definition that is not bound to an identifier.
- Wikipedia
Lambda (for mortals)
What Isn't a Lambda?
If it has a name, it's just a function. (code)
First Class Functions (for Gods)
"... the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures."
- Wikipedia
First Class Functions (for mortals)
Let's Take a Closer Look
function add_one(func_that_returns_number){
return function(){
return func_that_returns_number() + 1
}
}
This function takes a function as an argument so we call it a higher order function.
When aren't functions first-class?
- C has function pointers
- Ability to pass functions around != first-class
void print_secret(){
printf("Will knows all the words to Shake It Off");
}
void embarrass_will( void (*action)() ){
/*Implementation classified*/
}
int main(){
void (*embarrassing_action)();
embarrassing_action = &print_secret;
embarrass_will(embarrassing_action);
}
Functional Programming
... a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data.
- Wikipedia
Part 3: Learn More
Resources I Like
-
An Introduction to Functional Programming
- Brief, plainspoken. Good for beginners.
-
Learn You a Haskell for Great Good!
- Lighthearted introduction to the most notorious functional language.
-
JavaScript Allongé
- If you like functional JS, see how deep the rabbit hole goes.
- I've only skimmed this, but it looks cool.
-
Ruby Rogues 180:Barriers to New Developers
- Not FP related, but it inspired part of this talk.
Talks to Come
- Lambdas and currying in Java 8 (1/26/15)
- Referential transparency is your friend.
- On side effects and mutability.
- Much more! (probably)
Functional Programming for Mortals
By Will Engler
Functional Programming for Mortals
A talk delivered at the 1/12/15 Pitt CSC meeting to kick off the functional programming for mortals track.
- 1,040