SlideShare a Scribd company logo
1 of 91
Download to read offline
An Introduction to Functional Programming
Andreas Pauley ā€“ @apauley
Pattern Matched Technologies
Lambda Luminaries @lambdaluminary
September 2, 2013
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 1 / 58
Pattern Matched Technologies
Developing ļ¬nancial applications in Erlang.
http://www.patternmatched.com/
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 2 / 58
Lambda Luminaries ā€“ @lambdaluminary
Local functional programming user group
We meet once a month, on the second Monday of the month.
http://www.meetup.com/lambda-luminaries/
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 3 / 58
Introduction
Table of Contents
1 Introduction
2 Deļ¬nition of Functional Programming
3 Function Recap
4 Common FP Idioms
Recursion
Pattern Matching
Higher-order Functions
5 Higher-order Functions and Lists
6 Advantages of Functional Programming
7 Disdvantages of Functional Programming
8 Companies using Functional Programming
9 Where do we go from here?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 4 / 58
Introduction
A word from the wise
ā€œ No matter what language you work in, programming in
a functional style provides beneļ¬ts. You should do it
whenever it is convenient, and you should think hard
about the decision when it isnā€™t convenient. ā€
ā€” John Carmack, ID Software [2]
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 5 / 58
Introduction
Quake
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 6 / 58
Introduction
A Few Functional Programming Languages
Haskell Strong focus on functional purity. Lazy evaluation.
Advanced static type system. Native-code compiler.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
Introduction
A Few Functional Programming Languages
Haskell Strong focus on functional purity. Lazy evaluation.
Advanced static type system. Native-code compiler.
Erlang Focused around concurrency and distributed programming.
Strict evaluation. Dynamic typing. Runs on the BEAM VM.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
Introduction
A Few Functional Programming Languages
Haskell Strong focus on functional purity. Lazy evaluation.
Advanced static type system. Native-code compiler.
Erlang Focused around concurrency and distributed programming.
Strict evaluation. Dynamic typing. Runs on the BEAM VM.
Clojure A modern Lisp language. Focus on concurrency. Lazy
evaluation. Dynamic typing. Runs on the JVM.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
Introduction
A Few Functional Programming Languages
Haskell Strong focus on functional purity. Lazy evaluation.
Advanced static type system. Native-code compiler.
Erlang Focused around concurrency and distributed programming.
Strict evaluation. Dynamic typing. Runs on the BEAM VM.
Clojure A modern Lisp language. Focus on concurrency. Lazy
evaluation. Dynamic typing. Runs on the JVM.
Scala FP and OO. Strict evaluation by default, but supports lazy
evaluation. Advanced static type system. Runs on the JVM.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
Introduction
A Few Functional Programming Languages
Haskell Strong focus on functional purity. Lazy evaluation.
Advanced static type system. Native-code compiler.
Erlang Focused around concurrency and distributed programming.
Strict evaluation. Dynamic typing. Runs on the BEAM VM.
Clojure A modern Lisp language. Focus on concurrency. Lazy
evaluation. Dynamic typing. Runs on the JVM.
Scala FP and OO. Strict evaluation by default, but supports lazy
evaluation. Advanced static type system. Runs on the JVM.
OCaml FP and OO. Part of the ML family. Sometimes claimed to
be ā€œfaster than Cā€. Strict evaluation. Advanced static type
system. Native-code compiler.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
Introduction
A Few Functional Programming Languages
Haskell Strong focus on functional purity. Lazy evaluation.
Advanced static type system. Native-code compiler.
Erlang Focused around concurrency and distributed programming.
Strict evaluation. Dynamic typing. Runs on the BEAM VM.
Clojure A modern Lisp language. Focus on concurrency. Lazy
evaluation. Dynamic typing. Runs on the JVM.
Scala FP and OO. Strict evaluation by default, but supports lazy
evaluation. Advanced static type system. Runs on the JVM.
OCaml FP and OO. Part of the ML family. Sometimes claimed to
be ā€œfaster than Cā€. Strict evaluation. Advanced static type
system. Native-code compiler.
F# FP and OO. Based on OCaml. Strict evaluation by default,
but supports lazy evaluation. Advanced static type system.
Runs on the .NET CLR.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
Deļ¬nition of Functional Programming
Table of Contents
1 Introduction
2 Deļ¬nition of Functional Programming
3 Function Recap
4 Common FP Idioms
Recursion
Pattern Matching
Higher-order Functions
5 Higher-order Functions and Lists
6 Advantages of Functional Programming
7 Disdvantages of Functional Programming
8 Companies using Functional Programming
9 Where do we go from here?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 8 / 58
Deļ¬nition of Functional Programming
So what exactly is Functional Programming?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 9 / 58
Deļ¬nition of Functional Programming
Functional Programming, noun:
ā€œ Functional Programming is a list
of things you CANā€™T do. ā€
[7]
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 10 / 58
Deļ¬nition of Functional Programming
When programming in a functional style/language:
You canā€™t vary your variables.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 11 / 58
Deļ¬nition of Functional Programming
When programming in a functional style/language:
You canā€™t vary your variables.
You canā€™t mutate or change your state.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 11 / 58
Deļ¬nition of Functional Programming
When programming in a functional style/language:
You canā€™t vary your variables.
You canā€™t mutate or change your state.
No while/for loops, sorry.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 11 / 58
Deļ¬nition of Functional Programming
When programming in a functional style/language:
You canā€™t vary your variables.
You canā€™t mutate or change your state.
No while/for loops, sorry.
You canā€™t have side-eļ¬€ects.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 11 / 58
Deļ¬nition of Functional Programming
When programming in a functional style/language:
You canā€™t vary your variables.
You canā€™t mutate or change your state.
No while/for loops, sorry.
You canā€™t have side-eļ¬€ects.
You canā€™t control the order of execution (lazy evaluated languages).
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 11 / 58
Deļ¬nition of Functional Programming
Are you kidding me?
How can anyone program like this???
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 12 / 58
Deļ¬nition of Functional Programming
GOTO 10
This sounds like
ā€œYou canā€™t have GOTO statementsā€
See Hughes and Dijkstra [1, 3]
Also framed in the negative (you canā€™t).
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 13 / 58
Deļ¬nition of Functional Programming
GOTO 10
This sounds like
ā€œYou canā€™t have GOTO statementsā€
See Hughes and Dijkstra [1, 3]
Also framed in the negative (you canā€™t).
In hindsight we donā€™t really need GOTOā€™s.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 13 / 58
Deļ¬nition of Functional Programming
GOTO 10
This sounds like
ā€œYou canā€™t have GOTO statementsā€
See Hughes and Dijkstra [1, 3]
Also framed in the negative (you canā€™t).
In hindsight we donā€™t really need GOTOā€™s.
In hindsight it is not about what you cannot do.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 13 / 58
Deļ¬nition of Functional Programming
Structured Programming and Functional Programming
Structured Programming introduced subroutines with ļ¬xed entry/exit
points (instead of GOTOā€™s), resulting in improved
modularity.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 14 / 58
Deļ¬nition of Functional Programming
Structured Programming and Functional Programming
Structured Programming introduced subroutines with ļ¬xed entry/exit
points (instead of GOTOā€™s), resulting in improved
modularity.
Functional Programming provides similar important beneļ¬ts ā€“ more about
this later.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 14 / 58
Deļ¬nition of Functional Programming
We need a better deļ¬nition for Functional Programming.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 15 / 58
Deļ¬nition of Functional Programming
Functional Programming, noun:
ā€œ Functional programming is so called because a program
consists entirely of functions. ā€
ā€” John Hughes, Why Functional Programming Matters [1, p. 1]
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 16 / 58
Deļ¬nition of Functional Programming
OK... so what exactly is a function?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 17 / 58
Function Recap
Table of Contents
1 Introduction
2 Deļ¬nition of Functional Programming
3 Function Recap
4 Common FP Idioms
Recursion
Pattern Matching
Higher-order Functions
5 Higher-order Functions and Lists
6 Advantages of Functional Programming
7 Disdvantages of Functional Programming
8 Companies using Functional Programming
9 Where do we go from here?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 18 / 58
Function Recap
An example function
f (x) = 2x + 3
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 19 / 58
Function Recap
Variables in functions
f (x) = 2x + 3
When we evaluate the function:
f (4) = 2 āˆ— 4 + 3 = 11
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 20 / 58
Function Recap
Variables in functions
f (x) = 2x + 3
When we evaluate the function:
f (4) = 2 āˆ— 4 + 3 = 11
The value of x will not change inside the function body.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 20 / 58
Function Recap
Variables in functions
f (x) = 2x + 3
When we evaluate the function:
f (4) = 2 āˆ— 4 + 3 = 11
The value of x will not change inside the function body.
No x = 4 and later x = 21 in the same function body.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 20 / 58
Function Recap
Variables in functions
f (x) = 2x + 3
When we evaluate the function:
f (4) = 2 āˆ— 4 + 3 = 11
The value of x will not change inside the function body.
No x = 4 and later x = 21 in the same function body.
Same input, same output. Every time.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 20 / 58
Function Recap
Variables in functions
f (x) = 2x + 3
When we evaluate the function:
f (4) = 2 āˆ— 4 + 3 = 11
The value of x will not change inside the function body.
No x = 4 and later x = 21 in the same function body.
Same input, same output. Every time.
In other words, we can replace any occurrence of f (4) with 11
(Referential Transparency)
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 20 / 58
Function Recap
Functions can call other functions
g(x) = f (x) + 1
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 21 / 58
Function Recap
Values are functions
Constant values are just functions with no input parameters
k = 42
def k():
return 42
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 22 / 58
Function Recap
Functions can be combined
h(x) = f (g(x))
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 23 / 58
Function Recap
Higher-order Functions
Functions can take functions as input and/or return
functions as the result.
h(p, q, x) = p(x) + q(2)
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 24 / 58
Function Recap
Higher-order Functions
Functions can take functions as input and/or return
functions as the result.
h(p, q, x) = p(x) + q(2)
h(f , g, 3) = f (3) + g(2)
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 24 / 58
Function Recap
Higher-order Functions
The derivative of cos(x) returns another function.
d
dx cos(x) = āˆ’ sin(x)
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 25 / 58
Function Recap
A functional program consists entirely of functions
def main(args):
result = do_something_with_args(args)
print result
def do_something_with_args(args):
return ā€™-ā€™.join(args[1:])
./justfunctions.py hello functional programming
hello-functional-programming
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 26 / 58
Function Recap
A functional program consists entirely of functions
main :: IO()
main = do
args <- getArgs
let result = do_something_with_args args
putStrLn result
do_something_with_args :: [String] -> String
do_something_with_args args = intercalate "-" args
./justfunctions hello functional programming
hello-functional-programming
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 27 / 58
Common FP Idioms
Table of Contents
1 Introduction
2 Deļ¬nition of Functional Programming
3 Function Recap
4 Common FP Idioms
Recursion
Pattern Matching
Higher-order Functions
5 Higher-order Functions and Lists
6 Advantages of Functional Programming
7 Disdvantages of Functional Programming
8 Companies using Functional Programming
9 Where do we go from here?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 28 / 58
Common FP Idioms Recursion
Recursive function: Haskell
doubleAll :: Num a => [a] -> [a]
doubleAll [] = []
doubleAll (x:xs) = x*2 : doubleAll xs
Example use in the interactive interpreter:
Prelude Main> doubleAll [8,2,3]
[16,4,6]
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 29 / 58
Common FP Idioms Recursion
Recursive function: Python
def doubleAll(numbers):
if numbers == []:
return []
else:
first = numbers[0]
rest = numbers[1:]
return [first * 2] + doubleAll(rest)
Example use in the interactive interpreter:
>>> doubleAll([8,2,3])
[16, 4, 6]
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 30 / 58
Common FP Idioms Recursion
An iterative version in Python
def doubleAll(numbers):
doubled = []
for num in numbers:
doubled.append(num * 2)
return doubled
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 31 / 58
Common FP Idioms Pattern Matching
Pattern Matching: Haskell
doubleAll :: Num a => [a] -> [a]
doubleAll [] = []
doubleAll (x:xs) = x*2 : doubleAll xs
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 32 / 58
Common FP Idioms Higher-order Functions
Higher-order functions: Python
f (x) = 2x + 3
g(x) = f (x) + 1
h(p, q, x) = p(x) + q(2)
def f(x):
return (2*x) + 3
def g(x):
return f(x) + 1
def h(func_a, func_b, x):
return func_a(x) + func_b(2)
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 33 / 58
Common FP Idioms Higher-order Functions
Higher-order functions: Haskell
f (x) = 2x + 3
g(x) = f (x) + 1
h(p, q, x) = p(x) + q(2)
f x = (2*x) + 3
g x = (f x) + 1
h :: (Int->Int) -> (Int->Int) -> Int -> Int
h func_a func_b x = (func_a x) + (func_b 2)
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 34 / 58
Higher-order Functions and Lists
Table of Contents
1 Introduction
2 Deļ¬nition of Functional Programming
3 Function Recap
4 Common FP Idioms
Recursion
Pattern Matching
Higher-order Functions
5 Higher-order Functions and Lists
6 Advantages of Functional Programming
7 Disdvantages of Functional Programming
8 Companies using Functional Programming
9 Where do we go from here?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 35 / 58
Higher-order Functions and Lists
3 Basic List Operations
Map Convert each element of a list into some other value.
Example: Convert a list of students to a list of exam scores.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 36 / 58
Higher-order Functions and Lists
3 Basic List Operations
Map Convert each element of a list into some other value.
Example: Convert a list of students to a list of exam scores.
Filter Get a subset of a list based on some condition. Example:
Filter the entire list of students down to only those that
passed the exam.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 36 / 58
Higher-order Functions and Lists
3 Basic List Operations
Map Convert each element of a list into some other value.
Example: Convert a list of students to a list of exam scores.
Filter Get a subset of a list based on some condition. Example:
Filter the entire list of students down to only those that
passed the exam.
Fold Reduce a list of items to a single value. Example: Reduce
the list of students to a single string of all names.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 36 / 58
Higher-order Functions and Lists
Map
doubleAll :: Num a => [a] -> [a]
doubleAll [] = []
doubleAll (x:xs) = x*2 : doubleAll xs
Looks very similar to the builtin map function:
map :: (a -> b) -> [a] -> [b]
map _ [] = []
map f (x:xs) = f x : map f xs
So our doubleAll can actually be simpliļ¬ed as:
doubleAll = map (*2)
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 37 / 58
Higher-order Functions and Lists
Student Data
data Student = Student { firstName :: String
, lastName :: String
, finalExamScore :: Double}
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 38 / 58
Higher-order Functions and Lists
Student Data
[Student {firstName="John",
lastName="Deer",
finalExamScore=60},
Student {firstName="Billy",
lastName="Bob",
finalExamScore=49.1},
Student {firstName="Jane",
lastName="Doe",
finalExamScore=89},
Student {firstName="Jack",
lastName="Johnson",
finalExamScore=29.3}]
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 39 / 58
Higher-order Functions and Lists
Map
Map type signature:
map :: (a -> b) -> [a] -> [b]
Map on student data:
allscores :: [Student] -> [Double]
allscores students = map finalExamScore students
ļ¬nalExamScore type signature:
finalExamScore :: Student -> Double
Output:
Final Exam Scores: [60.0,49.1,89.0,29.3]
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 40 / 58
Higher-order Functions and Lists
Filter
Filter type signature:
filter :: (a -> Bool) -> [a] -> [a]
Filter on student data:
passed :: [Student] -> [Student]
passed students = filter has_passed students
has_passed :: Student -> Bool
has_passed student = finalExamScore student >= 60
Output:
Students that have passed:
[John Deer (60.0),Jane Doe (89.0)]
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 41 / 58
Higher-order Functions and Lists
Fold
Fold type signature:
foldl :: (a -> b -> a) -> a -> [b] -> a
Fold on student data:
namecat :: [Student] -> String
namecat students = foldl catfun "" students
catfun :: String -> Student -> String
catfun acc student = acc ++ (firstName student) ++ "n"
Output:
"JohnnBillynJanenJackn"
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 42 / 58
Higher-order Functions and Lists
Shortened Map, Filter, Fold
allscores = map finalExamScore
passed = filter has_passed
has_passed student = finalExamScore student >= 60
namecat = foldl catfun ""
where catfun = (acc student ->
acc ++ (firstName student) ++ "n")
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 43 / 58
Higher-order Functions and Lists
Imperative Filter Example
class Student:
def __init__(self, firstname, lastname, finalexamscore):
self.firstname = firstname
self.lastname = lastname
self.finalexamscore = finalexamscore
def has_passed(self):
return self.finalexamscore >= 60
def passed(students):
passed_students = []
for student in students:
if student.has_passed():
passed_students.append(student)
return passed_students
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 44 / 58
Advantages of Functional Programming
Table of Contents
1 Introduction
2 Deļ¬nition of Functional Programming
3 Function Recap
4 Common FP Idioms
Recursion
Pattern Matching
Higher-order Functions
5 Higher-order Functions and Lists
6 Advantages of Functional Programming
7 Disdvantages of Functional Programming
8 Companies using Functional Programming
9 Where do we go from here?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 45 / 58
Advantages of Functional Programming
Perlisism #19
ā€œ A language that doesnā€™t aļ¬€ect the way you think about
programming, is not worth knowing. ā€
ā€” Alan Perlis[5]
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 46 / 58
Advantages of Functional Programming
Advantages of Functional Programming
Changes the way you think about programming and problem solving.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
Advantages of Functional Programming
Advantages of Functional Programming
Changes the way you think about programming and problem solving.
Improvements on the types of abstractions we can do with eg.
higher-order functions.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
Advantages of Functional Programming
Advantages of Functional Programming
Changes the way you think about programming and problem solving.
Improvements on the types of abstractions we can do with eg.
higher-order functions.
Lock-free concurrency.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
Advantages of Functional Programming
Advantages of Functional Programming
Changes the way you think about programming and problem solving.
Improvements on the types of abstractions we can do with eg.
higher-order functions.
Lock-free concurrency.
Improved ways of testing - QuickCheck.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
Advantages of Functional Programming
Advantages of Functional Programming
Changes the way you think about programming and problem solving.
Improvements on the types of abstractions we can do with eg.
higher-order functions.
Lock-free concurrency.
Improved ways of testing - QuickCheck.
More eļ¬€ective reasoning about code.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
Advantages of Functional Programming
Advantages of Functional Programming
Changes the way you think about programming and problem solving.
Improvements on the types of abstractions we can do with eg.
higher-order functions.
Lock-free concurrency.
Improved ways of testing - QuickCheck.
More eļ¬€ective reasoning about code.
Declare possible Null values explicitly if you need them. Goodbye
NullPointerException (mostly).
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
Disdvantages of Functional Programming
Table of Contents
1 Introduction
2 Deļ¬nition of Functional Programming
3 Function Recap
4 Common FP Idioms
Recursion
Pattern Matching
Higher-order Functions
5 Higher-order Functions and Lists
6 Advantages of Functional Programming
7 Disdvantages of Functional Programming
8 Companies using Functional Programming
9 Where do we go from here?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 48 / 58
Disdvantages of Functional Programming
Disadvantages of Functional Programming
Steep learning curve.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 49 / 58
Disdvantages of Functional Programming
Disadvantages of Functional Programming
Steep learning curve.
There are some very cryptic concepts.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 49 / 58
Disdvantages of Functional Programming
Disadvantages of Functional Programming
Steep learning curve.
There are some very cryptic concepts.
Tools/IDEā€™s are not as advanced as the mainstream equivalents.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 49 / 58
Disdvantages of Functional Programming
Disadvantages of Functional Programming
Steep learning curve.
There are some very cryptic concepts.
Tools/IDEā€™s are not as advanced as the mainstream equivalents.
Order of execution may be diļ¬ƒcult to reason about in a lazy language.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 49 / 58
Disdvantages of Functional Programming
Unfamiliar Territory
Functional Programming is unfamiliar territory for most.
ā€œ If you want everything to be familiar you will never learn
anything new. ā€
ā€” Rich Hickey, author of Clojure[6]
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 50 / 58
Companies using Functional Programming
Table of Contents
1 Introduction
2 Deļ¬nition of Functional Programming
3 Function Recap
4 Common FP Idioms
Recursion
Pattern Matching
Higher-order Functions
5 Higher-order Functions and Lists
6 Advantages of Functional Programming
7 Disdvantages of Functional Programming
8 Companies using Functional Programming
9 Where do we go from here?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 51 / 58
Companies using Functional Programming
Companies In South Africa
Pattern Matched Technologies, Midrand Using Erlang for all systems, eg.
processing high volumes of ļ¬nancial transactions.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
Companies using Functional Programming
Companies In South Africa
Pattern Matched Technologies, Midrand Using Erlang for all systems, eg.
processing high volumes of ļ¬nancial transactions.
Eldo Energy, Johannesburg Using Clojure for automated meter reading
and intelligent monitoring of consumer energy.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
Companies using Functional Programming
Companies In South Africa
Pattern Matched Technologies, Midrand Using Erlang for all systems, eg.
processing high volumes of ļ¬nancial transactions.
Eldo Energy, Johannesburg Using Clojure for automated meter reading
and intelligent monitoring of consumer energy.
Rheo Systems, Pretoria Using Clojure for supply chain integration.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
Companies using Functional Programming
Companies In South Africa
Pattern Matched Technologies, Midrand Using Erlang for all systems, eg.
processing high volumes of ļ¬nancial transactions.
Eldo Energy, Johannesburg Using Clojure for automated meter reading
and intelligent monitoring of consumer energy.
Rheo Systems, Pretoria Using Clojure for supply chain integration.
Yuppiechef, Cape Town Using Clojure for their Warehouse Management
System.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
Companies using Functional Programming
Companies In South Africa
Pattern Matched Technologies, Midrand Using Erlang for all systems, eg.
processing high volumes of ļ¬nancial transactions.
Eldo Energy, Johannesburg Using Clojure for automated meter reading
and intelligent monitoring of consumer energy.
Rheo Systems, Pretoria Using Clojure for supply chain integration.
Yuppiechef, Cape Town Using Clojure for their Warehouse Management
System.
Eļ¬€ective Control Systems, Kyalami Using Erlang for printer management.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
Companies using Functional Programming
Companies In South Africa
Pattern Matched Technologies, Midrand Using Erlang for all systems, eg.
processing high volumes of ļ¬nancial transactions.
Eldo Energy, Johannesburg Using Clojure for automated meter reading
and intelligent monitoring of consumer energy.
Rheo Systems, Pretoria Using Clojure for supply chain integration.
Yuppiechef, Cape Town Using Clojure for their Warehouse Management
System.
Eļ¬€ective Control Systems, Kyalami Using Erlang for printer management.
Mira Networks, Somerset West Using Erlang for billing administration and
mobile development.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
Companies using Functional Programming
Companies In South Africa
Pattern Matched Technologies, Midrand Using Erlang for all systems, eg.
processing high volumes of ļ¬nancial transactions.
Eldo Energy, Johannesburg Using Clojure for automated meter reading
and intelligent monitoring of consumer energy.
Rheo Systems, Pretoria Using Clojure for supply chain integration.
Yuppiechef, Cape Town Using Clojure for their Warehouse Management
System.
Eļ¬€ective Control Systems, Kyalami Using Erlang for printer management.
Mira Networks, Somerset West Using Erlang for billing administration and
mobile development.
Amazon.com, Cape Town Using Scala in EC2.
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
Where do we go from here?
Table of Contents
1 Introduction
2 Deļ¬nition of Functional Programming
3 Function Recap
4 Common FP Idioms
Recursion
Pattern Matching
Higher-order Functions
5 Higher-order Functions and Lists
6 Advantages of Functional Programming
7 Disdvantages of Functional Programming
8 Companies using Functional Programming
9 Where do we go from here?
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 53 / 58
Where do we go from here?
Lambda Luminaries ā€“ @lambdaluminary
Local functional programming user group
We meet once a month, on the second Monday of the month.
http://www.meetup.com/lambda-luminaries/
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 54 / 58
Where do we go from here?
Online Courses
Functional Programming Principles in Scala
EPFL University
https://www.coursera.org/course/progfun
School of Haskell
FP Complete
https://www.fpcomplete.com/school
Programming Languages
University of Washington
https://www.coursera.org/course/proglang
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 55 / 58
Where do we go from here?
Books
Miran LipovaĖ‡ca
Learn You a Haskell for Great Good!
http://learnyouahaskell.com/
Fred HĀ“ebert
Learn You Some Erlang for Great Good!
http://learnyousomeerlang.com/
Yaron Minski, Anil Madhavapeddy, Jason Hickey
Real World OCaml
https://realworldocaml.org/
Paul Chiusano, RĀ“unar Bjarnason
Functional Programming in Scala
http://www.manning.com/bjarnason/
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 56 / 58
Where do we go from here?
References I
John Hughes
Why Functional Programming Matters
http:
//www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf
John Carmack
Functional Programming in C++
http://www.altdevblogaday.com/2012/04/26/
functional-programming-in-c/
Edsger W. Dijkstra
Go To Statement Considered Harmful
http://www.u.arizona.edu/~rubinson/copyright_violations/
Go_To_Considered_Harmful.html
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 57 / 58
Where do we go from here?
References II
Tweet by Michael Feathers
https://twitter.com/mfeathers/status/29581296216
Alan Jay Perlis
http://www.cs.yale.edu/quotes.html
Rich Hickey
http://www.infoq.com/presentations/Simple-Made-Easy
Andreas Pauley
An Introduction to Functional Programming
https://github.com/apauley/fp_presentation
Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 58 / 58

More Related Content

What's hot

API Docs Made Right / RAML - Swagger rant
API Docs Made Right / RAML - Swagger rantAPI Docs Made Right / RAML - Swagger rant
API Docs Made Right / RAML - Swagger rantVladimir Shulyak
Ā 
REST Coder: Auto Generating Client Stubs and Documentation for REST APIs
REST Coder: Auto Generating Client Stubs and Documentation for REST APIsREST Coder: Auto Generating Client Stubs and Documentation for REST APIs
REST Coder: Auto Generating Client Stubs and Documentation for REST APIsHiranya Jayathilaka
Ā 
What is Swagger?
What is Swagger?What is Swagger?
What is Swagger?Philip Senger
Ā 
NLP using JavaScript Natural Library
NLP using JavaScript Natural LibraryNLP using JavaScript Natural Library
NLP using JavaScript Natural LibraryAniruddha Chakrabarti
Ā 
PDQ Programming Languages plus an overview of Alice - Frank Ducrest
PDQ Programming Languages plus an overview of Alice - Frank DucrestPDQ Programming Languages plus an overview of Alice - Frank Ducrest
PDQ Programming Languages plus an overview of Alice - Frank DucrestMatthew Turland
Ā 
Creating multillingual apps for android
Creating multillingual apps for androidCreating multillingual apps for android
Creating multillingual apps for androidSergi MartĆ­nez
Ā 
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...apidays
Ā 

What's hot (8)

API Docs Made Right / RAML - Swagger rant
API Docs Made Right / RAML - Swagger rantAPI Docs Made Right / RAML - Swagger rant
API Docs Made Right / RAML - Swagger rant
Ā 
Empathic API-Design
Empathic API-DesignEmpathic API-Design
Empathic API-Design
Ā 
REST Coder: Auto Generating Client Stubs and Documentation for REST APIs
REST Coder: Auto Generating Client Stubs and Documentation for REST APIsREST Coder: Auto Generating Client Stubs and Documentation for REST APIs
REST Coder: Auto Generating Client Stubs and Documentation for REST APIs
Ā 
What is Swagger?
What is Swagger?What is Swagger?
What is Swagger?
Ā 
NLP using JavaScript Natural Library
NLP using JavaScript Natural LibraryNLP using JavaScript Natural Library
NLP using JavaScript Natural Library
Ā 
PDQ Programming Languages plus an overview of Alice - Frank Ducrest
PDQ Programming Languages plus an overview of Alice - Frank DucrestPDQ Programming Languages plus an overview of Alice - Frank Ducrest
PDQ Programming Languages plus an overview of Alice - Frank Ducrest
Ā 
Creating multillingual apps for android
Creating multillingual apps for androidCreating multillingual apps for android
Creating multillingual apps for android
Ā 
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...
apidays LIVE London 2021 - Consumer-first APIs in Open Banking by Chris Dudle...
Ā 

Viewers also liked

Introduction To Functional Programming
Introduction To Functional ProgrammingIntroduction To Functional Programming
Introduction To Functional Programmingnewmedio
Ā 
Functional Programming Fundamentals
Functional Programming FundamentalsFunctional Programming Fundamentals
Functional Programming FundamentalsShahriar Hyder
Ā 
From Imperative to Functional Programming (for Absolute Beginners)
From Imperative to Functional Programming (for Absolute Beginners)From Imperative to Functional Programming (for Absolute Beginners)
From Imperative to Functional Programming (for Absolute Beginners)Alex Bunardzic
Ā 
Functional programming for optimization problems in Big Data
Functional programming for optimization problems in Big DataFunctional programming for optimization problems in Big Data
Functional programming for optimization problems in Big DataPaco Nathan
Ā 
Functional Programming Principles & Patterns
Functional Programming Principles & PatternsFunctional Programming Principles & Patterns
Functional Programming Principles & Patternszupzup.org
Ā 
Practical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan HodorogPractical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan Hodorog3Pillar Global
Ā 
Intro to functional programming
Intro to functional programmingIntro to functional programming
Intro to functional programmingAssaf Gannon
Ā 
那äŗ› Functional Programming ꕙꈑēš„äŗ‹
那äŗ› Functional Programming ꕙꈑēš„äŗ‹é‚£äŗ› Functional Programming ꕙꈑēš„äŗ‹
那äŗ› Functional Programming ꕙꈑēš„äŗ‹Wen-Tien Chang
Ā 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Scott Wlaschin
Ā 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scalapramode_ce
Ā 
Computability, turing machines and lambda calculus
Computability, turing machines and lambda calculusComputability, turing machines and lambda calculus
Computability, turing machines and lambda calculusEdward Blurock
Ā 
Functional programming
Functional programmingFunctional programming
Functional programmingedusmildo
Ā 
Functional programming
Functional programmingFunctional programming
Functional programmingPrateek Jain
Ā 
Intro to functional programming
Intro to functional programmingIntro to functional programming
Intro to functional programmingAssaf Gannon
Ā 
Functional programming in clojure
Functional programming in clojureFunctional programming in clojure
Functional programming in clojureJuan-Manuel Gimeno
Ā 
Csc1100 lecture01 ch01 pt2-paradigm
Csc1100 lecture01 ch01 pt2-paradigmCsc1100 lecture01 ch01 pt2-paradigm
Csc1100 lecture01 ch01 pt2-paradigmIIUM
Ā 
Core FP Concepts
Core FP ConceptsCore FP Concepts
Core FP ConceptsDiego Pacheco
Ā 
Uses of Cupcakes For Any Occasion in Hyderabad!
 Uses of Cupcakes For Any Occasion in Hyderabad! Uses of Cupcakes For Any Occasion in Hyderabad!
Uses of Cupcakes For Any Occasion in Hyderabad!bookthecake.com
Ā 
Oop project briefing sem 1 2015 2016
Oop project briefing  sem 1 2015 2016Oop project briefing  sem 1 2015 2016
Oop project briefing sem 1 2015 2016IIUM
Ā 
Functional Programming and Big Data
Functional Programming and Big DataFunctional Programming and Big Data
Functional Programming and Big DataDataWorks Summit
Ā 

Viewers also liked (20)

Introduction To Functional Programming
Introduction To Functional ProgrammingIntroduction To Functional Programming
Introduction To Functional Programming
Ā 
Functional Programming Fundamentals
Functional Programming FundamentalsFunctional Programming Fundamentals
Functional Programming Fundamentals
Ā 
From Imperative to Functional Programming (for Absolute Beginners)
From Imperative to Functional Programming (for Absolute Beginners)From Imperative to Functional Programming (for Absolute Beginners)
From Imperative to Functional Programming (for Absolute Beginners)
Ā 
Functional programming for optimization problems in Big Data
Functional programming for optimization problems in Big DataFunctional programming for optimization problems in Big Data
Functional programming for optimization problems in Big Data
Ā 
Functional Programming Principles & Patterns
Functional Programming Principles & PatternsFunctional Programming Principles & Patterns
Functional Programming Principles & Patterns
Ā 
Practical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan HodorogPractical Functional Programming Presentation by Bogdan Hodorog
Practical Functional Programming Presentation by Bogdan Hodorog
Ā 
Intro to functional programming
Intro to functional programmingIntro to functional programming
Intro to functional programming
Ā 
那äŗ› Functional Programming ꕙꈑēš„äŗ‹
那äŗ› Functional Programming ꕙꈑēš„äŗ‹é‚£äŗ› Functional Programming ꕙꈑēš„äŗ‹
那äŗ› Functional Programming ꕙꈑēš„äŗ‹
Ā 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)
Ā 
Introduction to Functional Programming with Scala
Introduction to Functional Programming with ScalaIntroduction to Functional Programming with Scala
Introduction to Functional Programming with Scala
Ā 
Computability, turing machines and lambda calculus
Computability, turing machines and lambda calculusComputability, turing machines and lambda calculus
Computability, turing machines and lambda calculus
Ā 
Functional programming
Functional programmingFunctional programming
Functional programming
Ā 
Functional programming
Functional programmingFunctional programming
Functional programming
Ā 
Intro to functional programming
Intro to functional programmingIntro to functional programming
Intro to functional programming
Ā 
Functional programming in clojure
Functional programming in clojureFunctional programming in clojure
Functional programming in clojure
Ā 
Csc1100 lecture01 ch01 pt2-paradigm
Csc1100 lecture01 ch01 pt2-paradigmCsc1100 lecture01 ch01 pt2-paradigm
Csc1100 lecture01 ch01 pt2-paradigm
Ā 
Core FP Concepts
Core FP ConceptsCore FP Concepts
Core FP Concepts
Ā 
Uses of Cupcakes For Any Occasion in Hyderabad!
 Uses of Cupcakes For Any Occasion in Hyderabad! Uses of Cupcakes For Any Occasion in Hyderabad!
Uses of Cupcakes For Any Occasion in Hyderabad!
Ā 
Oop project briefing sem 1 2015 2016
Oop project briefing  sem 1 2015 2016Oop project briefing  sem 1 2015 2016
Oop project briefing sem 1 2015 2016
Ā 
Functional Programming and Big Data
Functional Programming and Big DataFunctional Programming and Big Data
Functional Programming and Big Data
Ā 

Similar to Introduction to Functional Programming

Reverse engineering and instrumentation of android apps
Reverse engineering and instrumentation of android appsReverse engineering and instrumentation of android apps
Reverse engineering and instrumentation of android appsGaurav Lochan
Ā 
Hadoop at Lookout
Hadoop at LookoutHadoop at Lookout
Hadoop at LookoutYash Ranadive
Ā 
Functional Groovy - Confess
Functional Groovy - ConfessFunctional Groovy - Confess
Functional Groovy - ConfessAndres Almiray
Ā 
API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?Akana
Ā 
API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?Akana
Ā 
Get Functional Programming with Clojure
Get Functional Programming with ClojureGet Functional Programming with Clojure
Get Functional Programming with ClojureJohn Stevenson
Ā 
Open event (show&tell april 2016)
Open event (show&tell april 2016)Open event (show&tell april 2016)
Open event (show&tell april 2016)Jorge LĆ³pez-Lago
Ā 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to ClojureRenzo Borgatti
Ā 
Grooming with Groovy
Grooming with GroovyGrooming with Groovy
Grooming with GroovyDhaval Dalal
Ā 
Maintenance of Dynamically vs. Statically typed Languages
Maintenance of Dynamically vs. Statically typed LanguagesMaintenance of Dynamically vs. Statically typed Languages
Maintenance of Dynamically vs. Statically typed LanguagesAmin Bandeali
Ā 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3Martin Odersky
Ā 
Functional conf 2014_schedule
Functional conf 2014_scheduleFunctional conf 2014_schedule
Functional conf 2014_schedulegetdownload
Ā 
Pyspark vs Spark Let's Unravel the Bond!
Pyspark vs Spark Let's Unravel the Bond!Pyspark vs Spark Let's Unravel the Bond!
Pyspark vs Spark Let's Unravel the Bond!ankitbhandari32
Ā 
java traning report_Summer.docx
java traning report_Summer.docxjava traning report_Summer.docx
java traning report_Summer.docxGauravSharma164138
Ā 
Functional programming in scala coursera
Functional programming in scala  courseraFunctional programming in scala  coursera
Functional programming in scala courseraKetan Raval
Ā 
Languages used by web app development services remotestac x
Languages used by web app development services  remotestac xLanguages used by web app development services  remotestac x
Languages used by web app development services remotestac xRemote Stacx
Ā 

Similar to Introduction to Functional Programming (20)

Reverse engineering and instrumentation of android apps
Reverse engineering and instrumentation of android appsReverse engineering and instrumentation of android apps
Reverse engineering and instrumentation of android apps
Ā 
Hadoop at Lookout
Hadoop at LookoutHadoop at Lookout
Hadoop at Lookout
Ā 
Functional Groovy - Confess
Functional Groovy - ConfessFunctional Groovy - Confess
Functional Groovy - Confess
Ā 
API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?
Ā 
API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?API Description Languages: Which is the Right One for Me?
API Description Languages: Which is the Right One for Me?
Ā 
Get Functional Programming with Clojure
Get Functional Programming with ClojureGet Functional Programming with Clojure
Get Functional Programming with Clojure
Ā 
Open event (show&tell april 2016)
Open event (show&tell april 2016)Open event (show&tell april 2016)
Open event (show&tell april 2016)
Ā 
Scala: An OO Surprise
Scala: An OO SurpriseScala: An OO Surprise
Scala: An OO Surprise
Ā 
Introduction to Clojure
Introduction to ClojureIntroduction to Clojure
Introduction to Clojure
Ā 
Grooming with Groovy
Grooming with GroovyGrooming with Groovy
Grooming with Groovy
Ā 
Maintenance of Dynamically vs. Statically typed Languages
Maintenance of Dynamically vs. Statically typed LanguagesMaintenance of Dynamically vs. Statically typed Languages
Maintenance of Dynamically vs. Statically typed Languages
Ā 
Preparing for Scala 3
Preparing for Scala 3Preparing for Scala 3
Preparing for Scala 3
Ā 
Apache Zeppelin Helium and Beyond
Apache Zeppelin Helium and BeyondApache Zeppelin Helium and Beyond
Apache Zeppelin Helium and Beyond
Ā 
Csharp tp
Csharp tpCsharp tp
Csharp tp
Ā 
Functional conf 2014_schedule
Functional conf 2014_scheduleFunctional conf 2014_schedule
Functional conf 2014_schedule
Ā 
Pyspark vs Spark Let's Unravel the Bond!
Pyspark vs Spark Let's Unravel the Bond!Pyspark vs Spark Let's Unravel the Bond!
Pyspark vs Spark Let's Unravel the Bond!
Ā 
Presentation
PresentationPresentation
Presentation
Ā 
java traning report_Summer.docx
java traning report_Summer.docxjava traning report_Summer.docx
java traning report_Summer.docx
Ā 
Functional programming in scala coursera
Functional programming in scala  courseraFunctional programming in scala  coursera
Functional programming in scala coursera
Ā 
Languages used by web app development services remotestac x
Languages used by web app development services  remotestac xLanguages used by web app development services  remotestac x
Languages used by web app development services remotestac x
Ā 

Recently uploaded

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
Ā 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
Ā 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
Ā 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
Ā 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
Ā 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
Ā 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
Ā 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
Ā 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
Ā 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
Ā 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...gurkirankumar98700
Ā 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
Ā 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
Ā 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
Ā 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
Ā 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
Ā 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
Ā 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
Ā 
Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024The Digital Insurer
Ā 

Recently uploaded (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
Ā 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
Ā 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Ā 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
Ā 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Ā 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Ā 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Ā 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Ā 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
Ā 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
Ā 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Ā 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Ā 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
Ā 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Ā 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Ā 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Ā 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
Ā 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Ā 
Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024
Ā 

Introduction to Functional Programming

  • 1. An Introduction to Functional Programming Andreas Pauley ā€“ @apauley Pattern Matched Technologies Lambda Luminaries @lambdaluminary September 2, 2013 Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 1 / 58
  • 2. Pattern Matched Technologies Developing ļ¬nancial applications in Erlang. http://www.patternmatched.com/ Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 2 / 58
  • 3. Lambda Luminaries ā€“ @lambdaluminary Local functional programming user group We meet once a month, on the second Monday of the month. http://www.meetup.com/lambda-luminaries/ Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 3 / 58
  • 4. Introduction Table of Contents 1 Introduction 2 Deļ¬nition of Functional Programming 3 Function Recap 4 Common FP Idioms Recursion Pattern Matching Higher-order Functions 5 Higher-order Functions and Lists 6 Advantages of Functional Programming 7 Disdvantages of Functional Programming 8 Companies using Functional Programming 9 Where do we go from here? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 4 / 58
  • 5. Introduction A word from the wise ā€œ No matter what language you work in, programming in a functional style provides beneļ¬ts. You should do it whenever it is convenient, and you should think hard about the decision when it isnā€™t convenient. ā€ ā€” John Carmack, ID Software [2] Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 5 / 58
  • 6. Introduction Quake Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 6 / 58
  • 7. Introduction A Few Functional Programming Languages Haskell Strong focus on functional purity. Lazy evaluation. Advanced static type system. Native-code compiler. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
  • 8. Introduction A Few Functional Programming Languages Haskell Strong focus on functional purity. Lazy evaluation. Advanced static type system. Native-code compiler. Erlang Focused around concurrency and distributed programming. Strict evaluation. Dynamic typing. Runs on the BEAM VM. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
  • 9. Introduction A Few Functional Programming Languages Haskell Strong focus on functional purity. Lazy evaluation. Advanced static type system. Native-code compiler. Erlang Focused around concurrency and distributed programming. Strict evaluation. Dynamic typing. Runs on the BEAM VM. Clojure A modern Lisp language. Focus on concurrency. Lazy evaluation. Dynamic typing. Runs on the JVM. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
  • 10. Introduction A Few Functional Programming Languages Haskell Strong focus on functional purity. Lazy evaluation. Advanced static type system. Native-code compiler. Erlang Focused around concurrency and distributed programming. Strict evaluation. Dynamic typing. Runs on the BEAM VM. Clojure A modern Lisp language. Focus on concurrency. Lazy evaluation. Dynamic typing. Runs on the JVM. Scala FP and OO. Strict evaluation by default, but supports lazy evaluation. Advanced static type system. Runs on the JVM. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
  • 11. Introduction A Few Functional Programming Languages Haskell Strong focus on functional purity. Lazy evaluation. Advanced static type system. Native-code compiler. Erlang Focused around concurrency and distributed programming. Strict evaluation. Dynamic typing. Runs on the BEAM VM. Clojure A modern Lisp language. Focus on concurrency. Lazy evaluation. Dynamic typing. Runs on the JVM. Scala FP and OO. Strict evaluation by default, but supports lazy evaluation. Advanced static type system. Runs on the JVM. OCaml FP and OO. Part of the ML family. Sometimes claimed to be ā€œfaster than Cā€. Strict evaluation. Advanced static type system. Native-code compiler. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
  • 12. Introduction A Few Functional Programming Languages Haskell Strong focus on functional purity. Lazy evaluation. Advanced static type system. Native-code compiler. Erlang Focused around concurrency and distributed programming. Strict evaluation. Dynamic typing. Runs on the BEAM VM. Clojure A modern Lisp language. Focus on concurrency. Lazy evaluation. Dynamic typing. Runs on the JVM. Scala FP and OO. Strict evaluation by default, but supports lazy evaluation. Advanced static type system. Runs on the JVM. OCaml FP and OO. Part of the ML family. Sometimes claimed to be ā€œfaster than Cā€. Strict evaluation. Advanced static type system. Native-code compiler. F# FP and OO. Based on OCaml. Strict evaluation by default, but supports lazy evaluation. Advanced static type system. Runs on the .NET CLR. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 7 / 58
  • 13. Deļ¬nition of Functional Programming Table of Contents 1 Introduction 2 Deļ¬nition of Functional Programming 3 Function Recap 4 Common FP Idioms Recursion Pattern Matching Higher-order Functions 5 Higher-order Functions and Lists 6 Advantages of Functional Programming 7 Disdvantages of Functional Programming 8 Companies using Functional Programming 9 Where do we go from here? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 8 / 58
  • 14. Deļ¬nition of Functional Programming So what exactly is Functional Programming? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 9 / 58
  • 15. Deļ¬nition of Functional Programming Functional Programming, noun: ā€œ Functional Programming is a list of things you CANā€™T do. ā€ [7] Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 10 / 58
  • 16. Deļ¬nition of Functional Programming When programming in a functional style/language: You canā€™t vary your variables. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 11 / 58
  • 17. Deļ¬nition of Functional Programming When programming in a functional style/language: You canā€™t vary your variables. You canā€™t mutate or change your state. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 11 / 58
  • 18. Deļ¬nition of Functional Programming When programming in a functional style/language: You canā€™t vary your variables. You canā€™t mutate or change your state. No while/for loops, sorry. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 11 / 58
  • 19. Deļ¬nition of Functional Programming When programming in a functional style/language: You canā€™t vary your variables. You canā€™t mutate or change your state. No while/for loops, sorry. You canā€™t have side-eļ¬€ects. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 11 / 58
  • 20. Deļ¬nition of Functional Programming When programming in a functional style/language: You canā€™t vary your variables. You canā€™t mutate or change your state. No while/for loops, sorry. You canā€™t have side-eļ¬€ects. You canā€™t control the order of execution (lazy evaluated languages). Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 11 / 58
  • 21. Deļ¬nition of Functional Programming Are you kidding me? How can anyone program like this??? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 12 / 58
  • 22. Deļ¬nition of Functional Programming GOTO 10 This sounds like ā€œYou canā€™t have GOTO statementsā€ See Hughes and Dijkstra [1, 3] Also framed in the negative (you canā€™t). Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 13 / 58
  • 23. Deļ¬nition of Functional Programming GOTO 10 This sounds like ā€œYou canā€™t have GOTO statementsā€ See Hughes and Dijkstra [1, 3] Also framed in the negative (you canā€™t). In hindsight we donā€™t really need GOTOā€™s. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 13 / 58
  • 24. Deļ¬nition of Functional Programming GOTO 10 This sounds like ā€œYou canā€™t have GOTO statementsā€ See Hughes and Dijkstra [1, 3] Also framed in the negative (you canā€™t). In hindsight we donā€™t really need GOTOā€™s. In hindsight it is not about what you cannot do. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 13 / 58
  • 25. Deļ¬nition of Functional Programming Structured Programming and Functional Programming Structured Programming introduced subroutines with ļ¬xed entry/exit points (instead of GOTOā€™s), resulting in improved modularity. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 14 / 58
  • 26. Deļ¬nition of Functional Programming Structured Programming and Functional Programming Structured Programming introduced subroutines with ļ¬xed entry/exit points (instead of GOTOā€™s), resulting in improved modularity. Functional Programming provides similar important beneļ¬ts ā€“ more about this later. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 14 / 58
  • 27. Deļ¬nition of Functional Programming We need a better deļ¬nition for Functional Programming. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 15 / 58
  • 28. Deļ¬nition of Functional Programming Functional Programming, noun: ā€œ Functional programming is so called because a program consists entirely of functions. ā€ ā€” John Hughes, Why Functional Programming Matters [1, p. 1] Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 16 / 58
  • 29. Deļ¬nition of Functional Programming OK... so what exactly is a function? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 17 / 58
  • 30. Function Recap Table of Contents 1 Introduction 2 Deļ¬nition of Functional Programming 3 Function Recap 4 Common FP Idioms Recursion Pattern Matching Higher-order Functions 5 Higher-order Functions and Lists 6 Advantages of Functional Programming 7 Disdvantages of Functional Programming 8 Companies using Functional Programming 9 Where do we go from here? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 18 / 58
  • 31. Function Recap An example function f (x) = 2x + 3 Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 19 / 58
  • 32. Function Recap Variables in functions f (x) = 2x + 3 When we evaluate the function: f (4) = 2 āˆ— 4 + 3 = 11 Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 20 / 58
  • 33. Function Recap Variables in functions f (x) = 2x + 3 When we evaluate the function: f (4) = 2 āˆ— 4 + 3 = 11 The value of x will not change inside the function body. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 20 / 58
  • 34. Function Recap Variables in functions f (x) = 2x + 3 When we evaluate the function: f (4) = 2 āˆ— 4 + 3 = 11 The value of x will not change inside the function body. No x = 4 and later x = 21 in the same function body. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 20 / 58
  • 35. Function Recap Variables in functions f (x) = 2x + 3 When we evaluate the function: f (4) = 2 āˆ— 4 + 3 = 11 The value of x will not change inside the function body. No x = 4 and later x = 21 in the same function body. Same input, same output. Every time. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 20 / 58
  • 36. Function Recap Variables in functions f (x) = 2x + 3 When we evaluate the function: f (4) = 2 āˆ— 4 + 3 = 11 The value of x will not change inside the function body. No x = 4 and later x = 21 in the same function body. Same input, same output. Every time. In other words, we can replace any occurrence of f (4) with 11 (Referential Transparency) Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 20 / 58
  • 37. Function Recap Functions can call other functions g(x) = f (x) + 1 Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 21 / 58
  • 38. Function Recap Values are functions Constant values are just functions with no input parameters k = 42 def k(): return 42 Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 22 / 58
  • 39. Function Recap Functions can be combined h(x) = f (g(x)) Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 23 / 58
  • 40. Function Recap Higher-order Functions Functions can take functions as input and/or return functions as the result. h(p, q, x) = p(x) + q(2) Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 24 / 58
  • 41. Function Recap Higher-order Functions Functions can take functions as input and/or return functions as the result. h(p, q, x) = p(x) + q(2) h(f , g, 3) = f (3) + g(2) Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 24 / 58
  • 42. Function Recap Higher-order Functions The derivative of cos(x) returns another function. d dx cos(x) = āˆ’ sin(x) Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 25 / 58
  • 43. Function Recap A functional program consists entirely of functions def main(args): result = do_something_with_args(args) print result def do_something_with_args(args): return ā€™-ā€™.join(args[1:]) ./justfunctions.py hello functional programming hello-functional-programming Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 26 / 58
  • 44. Function Recap A functional program consists entirely of functions main :: IO() main = do args <- getArgs let result = do_something_with_args args putStrLn result do_something_with_args :: [String] -> String do_something_with_args args = intercalate "-" args ./justfunctions hello functional programming hello-functional-programming Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 27 / 58
  • 45. Common FP Idioms Table of Contents 1 Introduction 2 Deļ¬nition of Functional Programming 3 Function Recap 4 Common FP Idioms Recursion Pattern Matching Higher-order Functions 5 Higher-order Functions and Lists 6 Advantages of Functional Programming 7 Disdvantages of Functional Programming 8 Companies using Functional Programming 9 Where do we go from here? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 28 / 58
  • 46. Common FP Idioms Recursion Recursive function: Haskell doubleAll :: Num a => [a] -> [a] doubleAll [] = [] doubleAll (x:xs) = x*2 : doubleAll xs Example use in the interactive interpreter: Prelude Main> doubleAll [8,2,3] [16,4,6] Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 29 / 58
  • 47. Common FP Idioms Recursion Recursive function: Python def doubleAll(numbers): if numbers == []: return [] else: first = numbers[0] rest = numbers[1:] return [first * 2] + doubleAll(rest) Example use in the interactive interpreter: >>> doubleAll([8,2,3]) [16, 4, 6] Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 30 / 58
  • 48. Common FP Idioms Recursion An iterative version in Python def doubleAll(numbers): doubled = [] for num in numbers: doubled.append(num * 2) return doubled Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 31 / 58
  • 49. Common FP Idioms Pattern Matching Pattern Matching: Haskell doubleAll :: Num a => [a] -> [a] doubleAll [] = [] doubleAll (x:xs) = x*2 : doubleAll xs Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 32 / 58
  • 50. Common FP Idioms Higher-order Functions Higher-order functions: Python f (x) = 2x + 3 g(x) = f (x) + 1 h(p, q, x) = p(x) + q(2) def f(x): return (2*x) + 3 def g(x): return f(x) + 1 def h(func_a, func_b, x): return func_a(x) + func_b(2) Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 33 / 58
  • 51. Common FP Idioms Higher-order Functions Higher-order functions: Haskell f (x) = 2x + 3 g(x) = f (x) + 1 h(p, q, x) = p(x) + q(2) f x = (2*x) + 3 g x = (f x) + 1 h :: (Int->Int) -> (Int->Int) -> Int -> Int h func_a func_b x = (func_a x) + (func_b 2) Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 34 / 58
  • 52. Higher-order Functions and Lists Table of Contents 1 Introduction 2 Deļ¬nition of Functional Programming 3 Function Recap 4 Common FP Idioms Recursion Pattern Matching Higher-order Functions 5 Higher-order Functions and Lists 6 Advantages of Functional Programming 7 Disdvantages of Functional Programming 8 Companies using Functional Programming 9 Where do we go from here? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 35 / 58
  • 53. Higher-order Functions and Lists 3 Basic List Operations Map Convert each element of a list into some other value. Example: Convert a list of students to a list of exam scores. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 36 / 58
  • 54. Higher-order Functions and Lists 3 Basic List Operations Map Convert each element of a list into some other value. Example: Convert a list of students to a list of exam scores. Filter Get a subset of a list based on some condition. Example: Filter the entire list of students down to only those that passed the exam. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 36 / 58
  • 55. Higher-order Functions and Lists 3 Basic List Operations Map Convert each element of a list into some other value. Example: Convert a list of students to a list of exam scores. Filter Get a subset of a list based on some condition. Example: Filter the entire list of students down to only those that passed the exam. Fold Reduce a list of items to a single value. Example: Reduce the list of students to a single string of all names. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 36 / 58
  • 56. Higher-order Functions and Lists Map doubleAll :: Num a => [a] -> [a] doubleAll [] = [] doubleAll (x:xs) = x*2 : doubleAll xs Looks very similar to the builtin map function: map :: (a -> b) -> [a] -> [b] map _ [] = [] map f (x:xs) = f x : map f xs So our doubleAll can actually be simpliļ¬ed as: doubleAll = map (*2) Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 37 / 58
  • 57. Higher-order Functions and Lists Student Data data Student = Student { firstName :: String , lastName :: String , finalExamScore :: Double} Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 38 / 58
  • 58. Higher-order Functions and Lists Student Data [Student {firstName="John", lastName="Deer", finalExamScore=60}, Student {firstName="Billy", lastName="Bob", finalExamScore=49.1}, Student {firstName="Jane", lastName="Doe", finalExamScore=89}, Student {firstName="Jack", lastName="Johnson", finalExamScore=29.3}] Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 39 / 58
  • 59. Higher-order Functions and Lists Map Map type signature: map :: (a -> b) -> [a] -> [b] Map on student data: allscores :: [Student] -> [Double] allscores students = map finalExamScore students ļ¬nalExamScore type signature: finalExamScore :: Student -> Double Output: Final Exam Scores: [60.0,49.1,89.0,29.3] Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 40 / 58
  • 60. Higher-order Functions and Lists Filter Filter type signature: filter :: (a -> Bool) -> [a] -> [a] Filter on student data: passed :: [Student] -> [Student] passed students = filter has_passed students has_passed :: Student -> Bool has_passed student = finalExamScore student >= 60 Output: Students that have passed: [John Deer (60.0),Jane Doe (89.0)] Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 41 / 58
  • 61. Higher-order Functions and Lists Fold Fold type signature: foldl :: (a -> b -> a) -> a -> [b] -> a Fold on student data: namecat :: [Student] -> String namecat students = foldl catfun "" students catfun :: String -> Student -> String catfun acc student = acc ++ (firstName student) ++ "n" Output: "JohnnBillynJanenJackn" Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 42 / 58
  • 62. Higher-order Functions and Lists Shortened Map, Filter, Fold allscores = map finalExamScore passed = filter has_passed has_passed student = finalExamScore student >= 60 namecat = foldl catfun "" where catfun = (acc student -> acc ++ (firstName student) ++ "n") Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 43 / 58
  • 63. Higher-order Functions and Lists Imperative Filter Example class Student: def __init__(self, firstname, lastname, finalexamscore): self.firstname = firstname self.lastname = lastname self.finalexamscore = finalexamscore def has_passed(self): return self.finalexamscore >= 60 def passed(students): passed_students = [] for student in students: if student.has_passed(): passed_students.append(student) return passed_students Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 44 / 58
  • 64. Advantages of Functional Programming Table of Contents 1 Introduction 2 Deļ¬nition of Functional Programming 3 Function Recap 4 Common FP Idioms Recursion Pattern Matching Higher-order Functions 5 Higher-order Functions and Lists 6 Advantages of Functional Programming 7 Disdvantages of Functional Programming 8 Companies using Functional Programming 9 Where do we go from here? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 45 / 58
  • 65. Advantages of Functional Programming Perlisism #19 ā€œ A language that doesnā€™t aļ¬€ect the way you think about programming, is not worth knowing. ā€ ā€” Alan Perlis[5] Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 46 / 58
  • 66. Advantages of Functional Programming Advantages of Functional Programming Changes the way you think about programming and problem solving. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
  • 67. Advantages of Functional Programming Advantages of Functional Programming Changes the way you think about programming and problem solving. Improvements on the types of abstractions we can do with eg. higher-order functions. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
  • 68. Advantages of Functional Programming Advantages of Functional Programming Changes the way you think about programming and problem solving. Improvements on the types of abstractions we can do with eg. higher-order functions. Lock-free concurrency. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
  • 69. Advantages of Functional Programming Advantages of Functional Programming Changes the way you think about programming and problem solving. Improvements on the types of abstractions we can do with eg. higher-order functions. Lock-free concurrency. Improved ways of testing - QuickCheck. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
  • 70. Advantages of Functional Programming Advantages of Functional Programming Changes the way you think about programming and problem solving. Improvements on the types of abstractions we can do with eg. higher-order functions. Lock-free concurrency. Improved ways of testing - QuickCheck. More eļ¬€ective reasoning about code. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
  • 71. Advantages of Functional Programming Advantages of Functional Programming Changes the way you think about programming and problem solving. Improvements on the types of abstractions we can do with eg. higher-order functions. Lock-free concurrency. Improved ways of testing - QuickCheck. More eļ¬€ective reasoning about code. Declare possible Null values explicitly if you need them. Goodbye NullPointerException (mostly). Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 47 / 58
  • 72. Disdvantages of Functional Programming Table of Contents 1 Introduction 2 Deļ¬nition of Functional Programming 3 Function Recap 4 Common FP Idioms Recursion Pattern Matching Higher-order Functions 5 Higher-order Functions and Lists 6 Advantages of Functional Programming 7 Disdvantages of Functional Programming 8 Companies using Functional Programming 9 Where do we go from here? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 48 / 58
  • 73. Disdvantages of Functional Programming Disadvantages of Functional Programming Steep learning curve. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 49 / 58
  • 74. Disdvantages of Functional Programming Disadvantages of Functional Programming Steep learning curve. There are some very cryptic concepts. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 49 / 58
  • 75. Disdvantages of Functional Programming Disadvantages of Functional Programming Steep learning curve. There are some very cryptic concepts. Tools/IDEā€™s are not as advanced as the mainstream equivalents. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 49 / 58
  • 76. Disdvantages of Functional Programming Disadvantages of Functional Programming Steep learning curve. There are some very cryptic concepts. Tools/IDEā€™s are not as advanced as the mainstream equivalents. Order of execution may be diļ¬ƒcult to reason about in a lazy language. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 49 / 58
  • 77. Disdvantages of Functional Programming Unfamiliar Territory Functional Programming is unfamiliar territory for most. ā€œ If you want everything to be familiar you will never learn anything new. ā€ ā€” Rich Hickey, author of Clojure[6] Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 50 / 58
  • 78. Companies using Functional Programming Table of Contents 1 Introduction 2 Deļ¬nition of Functional Programming 3 Function Recap 4 Common FP Idioms Recursion Pattern Matching Higher-order Functions 5 Higher-order Functions and Lists 6 Advantages of Functional Programming 7 Disdvantages of Functional Programming 8 Companies using Functional Programming 9 Where do we go from here? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 51 / 58
  • 79. Companies using Functional Programming Companies In South Africa Pattern Matched Technologies, Midrand Using Erlang for all systems, eg. processing high volumes of ļ¬nancial transactions. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
  • 80. Companies using Functional Programming Companies In South Africa Pattern Matched Technologies, Midrand Using Erlang for all systems, eg. processing high volumes of ļ¬nancial transactions. Eldo Energy, Johannesburg Using Clojure for automated meter reading and intelligent monitoring of consumer energy. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
  • 81. Companies using Functional Programming Companies In South Africa Pattern Matched Technologies, Midrand Using Erlang for all systems, eg. processing high volumes of ļ¬nancial transactions. Eldo Energy, Johannesburg Using Clojure for automated meter reading and intelligent monitoring of consumer energy. Rheo Systems, Pretoria Using Clojure for supply chain integration. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
  • 82. Companies using Functional Programming Companies In South Africa Pattern Matched Technologies, Midrand Using Erlang for all systems, eg. processing high volumes of ļ¬nancial transactions. Eldo Energy, Johannesburg Using Clojure for automated meter reading and intelligent monitoring of consumer energy. Rheo Systems, Pretoria Using Clojure for supply chain integration. Yuppiechef, Cape Town Using Clojure for their Warehouse Management System. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
  • 83. Companies using Functional Programming Companies In South Africa Pattern Matched Technologies, Midrand Using Erlang for all systems, eg. processing high volumes of ļ¬nancial transactions. Eldo Energy, Johannesburg Using Clojure for automated meter reading and intelligent monitoring of consumer energy. Rheo Systems, Pretoria Using Clojure for supply chain integration. Yuppiechef, Cape Town Using Clojure for their Warehouse Management System. Eļ¬€ective Control Systems, Kyalami Using Erlang for printer management. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
  • 84. Companies using Functional Programming Companies In South Africa Pattern Matched Technologies, Midrand Using Erlang for all systems, eg. processing high volumes of ļ¬nancial transactions. Eldo Energy, Johannesburg Using Clojure for automated meter reading and intelligent monitoring of consumer energy. Rheo Systems, Pretoria Using Clojure for supply chain integration. Yuppiechef, Cape Town Using Clojure for their Warehouse Management System. Eļ¬€ective Control Systems, Kyalami Using Erlang for printer management. Mira Networks, Somerset West Using Erlang for billing administration and mobile development. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
  • 85. Companies using Functional Programming Companies In South Africa Pattern Matched Technologies, Midrand Using Erlang for all systems, eg. processing high volumes of ļ¬nancial transactions. Eldo Energy, Johannesburg Using Clojure for automated meter reading and intelligent monitoring of consumer energy. Rheo Systems, Pretoria Using Clojure for supply chain integration. Yuppiechef, Cape Town Using Clojure for their Warehouse Management System. Eļ¬€ective Control Systems, Kyalami Using Erlang for printer management. Mira Networks, Somerset West Using Erlang for billing administration and mobile development. Amazon.com, Cape Town Using Scala in EC2. Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 52 / 58
  • 86. Where do we go from here? Table of Contents 1 Introduction 2 Deļ¬nition of Functional Programming 3 Function Recap 4 Common FP Idioms Recursion Pattern Matching Higher-order Functions 5 Higher-order Functions and Lists 6 Advantages of Functional Programming 7 Disdvantages of Functional Programming 8 Companies using Functional Programming 9 Where do we go from here? Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 53 / 58
  • 87. Where do we go from here? Lambda Luminaries ā€“ @lambdaluminary Local functional programming user group We meet once a month, on the second Monday of the month. http://www.meetup.com/lambda-luminaries/ Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 54 / 58
  • 88. Where do we go from here? Online Courses Functional Programming Principles in Scala EPFL University https://www.coursera.org/course/progfun School of Haskell FP Complete https://www.fpcomplete.com/school Programming Languages University of Washington https://www.coursera.org/course/proglang Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 55 / 58
  • 89. Where do we go from here? Books Miran LipovaĖ‡ca Learn You a Haskell for Great Good! http://learnyouahaskell.com/ Fred HĀ“ebert Learn You Some Erlang for Great Good! http://learnyousomeerlang.com/ Yaron Minski, Anil Madhavapeddy, Jason Hickey Real World OCaml https://realworldocaml.org/ Paul Chiusano, RĀ“unar Bjarnason Functional Programming in Scala http://www.manning.com/bjarnason/ Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 56 / 58
  • 90. Where do we go from here? References I John Hughes Why Functional Programming Matters http: //www.cs.kent.ac.uk/people/staff/dat/miranda/whyfp90.pdf John Carmack Functional Programming in C++ http://www.altdevblogaday.com/2012/04/26/ functional-programming-in-c/ Edsger W. Dijkstra Go To Statement Considered Harmful http://www.u.arizona.edu/~rubinson/copyright_violations/ Go_To_Considered_Harmful.html Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 57 / 58
  • 91. Where do we go from here? References II Tweet by Michael Feathers https://twitter.com/mfeathers/status/29581296216 Alan Jay Perlis http://www.cs.yale.edu/quotes.html Rich Hickey http://www.infoq.com/presentations/Simple-Made-Easy Andreas Pauley An Introduction to Functional Programming https://github.com/apauley/fp_presentation Andreas Pauley ā€“ @apauley (Pattern Matched TechnologiesLambda Luminaries @lambdaluminary)Functional Programming September 2, 2013 58 / 58