Forget what you think you know: Redefining functional programming for Scala

Forget what you think you know:
Redefining Functional
Programming
Engineering Team Lead

@kelleyrobinson
Kelley Robinson
Forget what you think you know:
Redefining Functional
Programming
(This is not
a real book)
“Standardized” Ladder of
Functional Programming
really
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Forget what you think you know:
Redefining Functional
Programming
Engineering Team Lead

@kelleyrobinson
Kelley Robinson
Engineering Team Lead

@kelleyrobinson
Kelley Robinson
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Why this matters
FP In Scala
Origins
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Why this matters
FP In Scala
Origins
Origins
Paradigms
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
How did we get here?
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Origins
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
“..in the same way that
music is not a set of
instruments, functional
programming is not a
set of abstractions that
we need to learn and
memorize.”
- José Calderón
Origins
The Lambda Calculus
Alonzo Church (1930s)
@KELLEYROBINSONFUNCTIONAL PROGRAMMING ESSENTIALS
Origins
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
λx.x+1
variable
function application
expression
Origins
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
λx.x+1
scala> { x: Int => x + 1 }
res1: Int => Int = <function1>
Origins
The Lambda Calculus
Alonzo Church (1930s)
Theoretical foundation
Pure functions - no state
Not a programming language
@KELLEYROBINSONFUNCTIONAL PROGRAMMING ESSENTIALS
Origins
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
“Modern functional
languages can be thought
of as (nontrivial)
embellishments of the
lambda calculus”
- Paul Hudak (1989)
Fortran
John Backus (1954)
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Origins
Logic Theory Machine
Newell and Simon (1956)
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Origins
Logic Theory Machine
Newell and Simon (1956)
IPL (Information Processing
Language)
List processing
Recursion
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Origins
Lisp
John McCarthy (1958)
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Origins
Functional
abstraction
Evolution of Functional Programming
An Early History
Higher level
languages
List processing &
recursion
Lisp popularizes
paradigm
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
1930s 1950s
Origins
Paradigms
Revisited
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Origins
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Why this matters
FP In Scala
Origins
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
If you can understand
expressions and
data structures, you understand
functional programming
Functional
programming hasn’t
materially changed
since 1975
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Recursive
Programming
Techniques
W.H. Burge (1975)
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
This was before…
Polymorphic type inference
Algebraic data types
Lazy languages
Category-theoretic terminology
Introduction: Burge School of Functional Programming
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
W.H. Burge (1975)
Essentials
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Functional Programming
doesn’t care about your
monads or type systems
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Expressions
Expressions
Expressions
Expressions
Expressions
Essentials
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
3x2 + y3x2 + y
Essentials
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
+ (* (3, square(x)), y)
3x2 + y
operators
operands
Essentials
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
+ (* (3, square(2)), 1)
for x = 2, y = 1
operators
operands
Essentials
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
+ (* (3, 4), 1)
operators
operands
for x = 2, y = 1
Essentials
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
+ (12, 1)
operators
operands
for x = 2, y = 1
Essentials
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
13
for x = 2, y = 1
Essentials
Side Effects
Changes outside of function scope
Modifies state
Not predictable
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Expressions
Instead of statements
Related:
Pure functions
Immutable data
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Referential
transparency
An expression can be replaced by
its value without changing the
program behavior
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Immutable data
Avoid modifying state
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Stateful
programming is
inherently complex
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Expressions
The programmer benefits
Understanding
Predictability
Unit testing
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Data Structures
Constructing and Deconstructing
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Data Structures
Constructing and Deconstructing
1. How do you make the data?
2. How do you take it apart?
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
sealed abstract class List[+A]

case class Cons[A](head: A, tail: List[A]) extends List[A]

case object Null extends List[Nothing]
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
def listFunction(list: List[Int]) =

list match {

case Cons(x, xs) =>
// ... something that uses x and xs...

case Null =>
// ... something that can’t use x and xs... 

}
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
def length(l: List[Int]): Int =

l match {

case Cons(x, xs) => 1 + length(xs)

case Null => 0

}
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
def sum(l: List[Int]): Int =

l match {

case Cons(x, xs) => x + sum(xs)

case Null => 0

}
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
def product(l: List[Int]): Int =

l match {

case Cons(x, xs) => x * product(xs)

case Null => 1

}
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
def list[A, B](f: (A,B) => B,
d: B,
xs: List[A]): B =

xs match {

case Cons(y, ys) => f(y, list(f,d,ys))

case Null => d

}
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
def list[A, B](f: (A,B) => B, d: B, xs: List[A]): B
def length ... = list((_, b) => 1 + b, 0, xs)


def sum ... = list((a, b) => a + b, 0, xs)
def product ... = list((a, b) => a * b, 1, xs)
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
If you can understand
expressions and
data structures, you
understand functional
programming
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Why this matters
FP In Scala
Origins
“Standardized” Ladder of
Functional Programming
really
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
“Modern” Functional
Programming is
cluttered with jargon
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Why this matters
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
“Jargon comes with an
inherent cost. It needs
to earn its place. (And it
often does: jargon is
necessary to discuss
complex and domain-
specific ideas.)”
- Bonnie Eisenman
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON@KELLEYROBINSON
Why this matters
Research proves:
Vocabulary and
comprehension are
directly correlated
“It is also a striking demonstration
of the fact that even definitions of
very high quality are often
inadequate as sources of
information on usage.”
Vocabulary and
context are necessary
for understanding
Ladder of
Functional Programming
really
“Standardized”**Updated!🙄**
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
✨ Expressions & Data Structures ✨
🤔 Abstraction FooBar
Buzzword Baz 🤷
trends
core
concepts}
}
Someone has to
maintain the
code we write
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Why this matters
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
“It may be fun to brag
about knowing how to
use "embedded DSL
with combinators,"
but is that really the
best thing to help your
startup succeed?”
- Hacker News
Why this matters
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Jargon is
alienating
Why this matters
Please.
Stop.
Saying.
This.
Please.
@KELLEYROBINSONFUNCTIONAL PROGRAMMING ESSENTIALS
Why this matters
(also not
a real book)
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
Why this matters
FP In Scala
Origins
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
FP In Scala
higher kinded types
applied materialization
existential types autotupling
Dependent Types
profunctor optics
the cake pattern
Existential quantifier
CQRS
Isomorphisms
fundep materializers
implicit resolution
typeclass pattern
vampire methods
trampolining
co-optic bananas
the kitten pattern
lupus ordering
Comwell’s principle
Meijer’s law
Miller’s paradox
Eta bindings
endomonadic functors
the jigsaw pattern
Enum generators
Dependent expressions
Squid lenses
hypelevel Scalareactive pandas
multiverse inequalityproactive streams
effectful constants
lambda generators
effectual effects
semimonads
WAR handles
isomorphic esoterics
Skolemization
category philosophic
Odersky indentation
catamorphisms
Hylomorphisms
Lifted arrows
recursive constants
injuncted functions
composable cats
parachutes
Mutumorphisms
banana brackets
algebraic idempotency
contextual zygotes
hyloadjoinct
zygoid
magma
schema devolution
Moors’ law
compartial function
generic serial versionable view
triangular rings
immuteratorreflexive ornaments
Naperian functors delimited lambda buffer
coinductive resumption monad
lizards
kleisli compositionCo-Yoneda lemmas
GADT
PJAs
transfiguration
covfefe monad
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
FP In Scala
higher kinded types
applied materialization
existential types autotupling
Dependent Types
profunctor optics
the cake pattern
Existential quantifier
CQRS
Isomorphisms
fundep materializers
implicit resolution
typeclass pattern
vampire methods
trampolining
co-optic bananas
the kitten pattern
lupus ordering
Comwell’s principle
Meijer’s law
Miller’s paradox
Eta bindings
endomonadic functors
the jigsaw pattern
Enum generators
Dependent expressions
Squid lenses
hypelevel Scalareactive pandas
multiverse inequalityproactive streams
effectful constants
lambda generators
effectual effects
semimonads
WAR handles
isomorphic esoterics
Skolemization
category philosophic
Odersky indentation
catamorphisms
Hylomorphisms
Lifted arrows
recursive constants
injuncted functions
composable cats
parachutes
Mutumorphisms
banana brackets
algebraic idempotency
contextual zygotes
hyloadjoinct
zygoid
magma
schema devolution
Moors’ law
compartial function
generic serial versionable view
triangular rings
immuteratorreflexive ornaments
Naperian functors delimited lambda buffer
coinductive resumption monad
lizards
kleisli compositionCo-Yoneda lemmas
GADT
PJAs
🙅
transfiguration
covfefe monad
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Storing data val var
Iterating map for loop
pattern
matching
procedural
statements
Deconstructing data
preferred possible
FP In Scala
What about…?
Cats…Scalaz…FREE MONADS!?
Basics are built into Scala
(think `map`, `fold`)
Libraries have other syntactic
sugar
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
FP In Scala
• Build community
• Promote understanding
• Minimize jargon
@KELLEYROBINSONFUNCTIONAL PROGRAMMING ESSENTIALS
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
FP In Scala
higher kinded types
applied materialization
existential types autotupling
Dependent Types
profunctor optics
the cake pattern
Existential quantifier
CQRS
Isomorphisms
fundep materializers
implicit resolution
typeclass pattern
vampire methods
trampolining
co-optic bananas
the kitten pattern
lupus ordering
Comwell’s principle
Meijer’s law
Miller’s paradox
Eta bindings
endomonadic functors
the jigsaw pattern
Enum generators
Dependent expressions
Squid lenses
hypelevel Scalareactive pandas
multiverse inequalityproactive streams
effectful constants
lambda generators
effectual effects
semimonads
WAR handles
isomorphic esoterics
Skolemization
category philosophic
Odersky indentation
catamorphisms
Hylomorphisms
Lifted arrows
recursive constants
injuncted functions
composable cats
parachutes
Mutumorphisms
banana brackets
algebraic idempotency
contextual zygotes
hyloadjoinct
zygoid
magma
schema devolution
Moors’ law
compartial function
generic serial versionable view
triangular rings
immuteratorreflexive ornaments
Naperian functors delimited lambda buffer
coinductive resumption monad
lizards
kleisli compositionCo-Yoneda lemmas
GADT
PJAs
transfiguration
covfefe monad
FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
Essentials
bitly.com/scalajargon
Thank You!
@kelleyrobinson
hello@krobinson.me
FUNCTIONAL PROGRAMMING ESSENTIALS
Special thanks to
• Sharethrough
• José Calderón
• Heather Miller
• Bonnie Eisenman
Resources
• Mentioned in this talk:
• Bonnie Eisenman on Scala Jargon
• José Calderón's Burge School of Functional Programming
• Conception, Evolution, and Application of Functional Programming Languages
• Original LambdaConf ladder and Updated LambdaConf ladder
• Vocabulary Processes
• Further Reading & Watching:
• Functional programming
• Lambda calculus
• John McCarthy - History of Lisp
• Lambda Calculus - Computerphile
• Mark Priestley - New Problems, New Paradigms
• John Hughes, Mary Sheeran - Keynote: Why Functional Programming Matters
• Vocabulary and Comprehension Research:
• The Relationship between Reading Comprehension and Vocabulary Knowledge
• The Relationship between Vocabulary Size and Reading Comprehension
• Vocabulary and Word Study to Increase Comprehension in Content Areas
• Why Vocabulary Instruction Matters
• Effects of long-term vocabulary instruction on reading comprehension
@KELLEYROBINSON
@KELLEYROBINSONFUNCTIONAL PROGRAMMING ESSENTIALSFUNCTIONAL PROGRAMMING ESSENTIALS
Photography credits
• Opening image
• Solving imaginary scaling issues
• Paradigms
• Orchestra
• Alonzo Church
• Philip Wadler
• Glitter
• Fortran
• Chess
• A Lisp machine in the MIT Museum
• 1975 SNL cast
• Side effects
• Escher print
• Legos
• Jargon
• Child reading
• University
• The thinker
• Jargon is alienating
• Cat typing
@KELLEYROBINSON
1 of 78

More Related Content

Similar to Forget what you think you know: Redefining functional programming for Scala

Similar to Forget what you think you know: Redefining functional programming for Scala(20)

Functional programming in pythonFunctional programming in python
Functional programming in python
Edward D. Weinberger48 views
F# and functional programmingF# and functional programming
F# and functional programming
ramikarjalainen716 views
Fp for the oo programmerFp for the oo programmer
Fp for the oo programmer
Shawn Button202 views
Reviewing OOP Design patternsReviewing OOP Design patterns
Reviewing OOP Design patterns
Olivier Bacs54 views
Extreme SwiftExtreme Swift
Extreme Swift
Movel1K views
Monad Fact #6Monad Fact #6
Monad Fact #6
Philip Schwarz481 views
Unison Language - ContactUnison Language - Contact
Unison Language - Contact
Philip Schwarz438 views
Boolean GuidanceBoolean Guidance
Boolean Guidance
Syed Yaseen Ahmed654 views
Boolean guidanceBoolean guidance
Boolean guidance
Syed Yaseen Ahmed528 views
Booting into functional programmingBooting into functional programming
Booting into functional programming
Dhaval Dalal2.5K views
PresentationPresentation
Presentation
pnathan_logos245 views
PRESENTATION ON PYTHON.pptxPRESENTATION ON PYTHON.pptx
PRESENTATION ON PYTHON.pptx
abhishek364864171 views

More from Kelley Robinson(20)

Auth on the web: better authenticationAuth on the web: better authentication
Auth on the web: better authentication
Kelley Robinson138 views
WebAuthnWebAuthn
WebAuthn
Kelley Robinson338 views
Introduction to Public Key CryptographyIntroduction to Public Key Cryptography
Introduction to Public Key Cryptography
Kelley Robinson218 views
2FA in 2020 and Beyond2FA in 2020 and Beyond
2FA in 2020 and Beyond
Kelley Robinson213 views
Introduction to SHAKEN/STIRIntroduction to SHAKEN/STIR
Introduction to SHAKEN/STIR
Kelley Robinson104 views
Intro to SHAKEN/STIRIntro to SHAKEN/STIR
Intro to SHAKEN/STIR
Kelley Robinson182 views
PSD2, SCA, WTF?PSD2, SCA, WTF?
PSD2, SCA, WTF?
Kelley Robinson228 views
Building a Better Scala CommunityBuilding a Better Scala Community
Building a Better Scala Community
Kelley Robinson355 views
Communication @ StartupsCommunication @ Startups
Communication @ Startups
Kelley Robinson409 views
Contact Center AuthenticationContact Center Authentication
Contact Center Authentication
Kelley Robinson440 views
Authentication Beyond SMSAuthentication Beyond SMS
Authentication Beyond SMS
Kelley Robinson667 views
SIGNAL - Practical CryptographySIGNAL - Practical Cryptography
SIGNAL - Practical Cryptography
Kelley Robinson184 views
2FA Best Practices2FA Best Practices
2FA Best Practices
Kelley Robinson381 views
Practical CryptographyPractical Cryptography
Practical Cryptography
Kelley Robinson225 views
2FA, WTF!?2FA, WTF!?
2FA, WTF!?
Kelley Robinson147 views

Recently uploaded(20)

802.11 Computer Networks802.11 Computer Networks
802.11 Computer Networks
TusharChoudhary720159 views
Wire RopeWire Rope
Wire Rope
Iwiss Tools Co.,Ltd8 views
SEMI CONDUCTORSSEMI CONDUCTORS
SEMI CONDUCTORS
pavaniaalla200516 views
Stone Masonry and Brick Masonry.pdfStone Masonry and Brick Masonry.pdf
Stone Masonry and Brick Masonry.pdf
Mohammed Abdullah Laskar19 views
FLOW IN PIPES NOTES.pdfFLOW IN PIPES NOTES.pdf
FLOW IN PIPES NOTES.pdf
Dearest Arhelo85 views
Electrical CrimpingElectrical Crimping
Electrical Crimping
Iwiss Tools Co.,Ltd19 views
2_DVD_ASIC_Design_FLow.pdf2_DVD_ASIC_Design_FLow.pdf
2_DVD_ASIC_Design_FLow.pdf
Usha Mehta10 views
Investor PresentationInvestor Presentation
Investor Presentation
eser sevinç15 views
Object Oriented Programming with JAVAObject Oriented Programming with JAVA
Object Oriented Programming with JAVA
Demian Antony D'Mello58 views
String.pptxString.pptx
String.pptx
Ananthi Palanisamy47 views
PlumbingPlumbing
Plumbing
Iwiss Tools Co.,Ltd11 views
LFA-NPG-Paper.pdfLFA-NPG-Paper.pdf
LFA-NPG-Paper.pdf
harinsrikanth40 views
13_DVD_Latch-up_prevention.pdf13_DVD_Latch-up_prevention.pdf
13_DVD_Latch-up_prevention.pdf
Usha Mehta7 views

Forget what you think you know: Redefining functional programming for Scala

  • 1. Forget what you think you know: Redefining Functional Programming Engineering Team Lead @kelleyrobinson Kelley Robinson
  • 2. Forget what you think you know: Redefining Functional Programming
  • 3. (This is not a real book)
  • 4. “Standardized” Ladder of Functional Programming really FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
  • 5. Forget what you think you know: Redefining Functional Programming Engineering Team Lead @kelleyrobinson Kelley Robinson
  • 7. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials Why this matters FP In Scala Origins
  • 8. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials Why this matters FP In Scala Origins
  • 10. How did we get here? FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Origins
  • 11. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON “..in the same way that music is not a set of instruments, functional programming is not a set of abstractions that we need to learn and memorize.” - José Calderón Origins
  • 12. The Lambda Calculus Alonzo Church (1930s) @KELLEYROBINSONFUNCTIONAL PROGRAMMING ESSENTIALS Origins
  • 13. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON λx.x+1 variable function application expression Origins
  • 14. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON λx.x+1 scala> { x: Int => x + 1 } res1: Int => Int = <function1> Origins
  • 15. The Lambda Calculus Alonzo Church (1930s) Theoretical foundation Pure functions - no state Not a programming language @KELLEYROBINSONFUNCTIONAL PROGRAMMING ESSENTIALS Origins
  • 17. “Modern functional languages can be thought of as (nontrivial) embellishments of the lambda calculus” - Paul Hudak (1989)
  • 18. Fortran John Backus (1954) FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Origins
  • 19. Logic Theory Machine Newell and Simon (1956) FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Origins
  • 20. Logic Theory Machine Newell and Simon (1956) IPL (Information Processing Language) List processing Recursion FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Origins
  • 21. Lisp John McCarthy (1958) FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Origins
  • 22. Functional abstraction Evolution of Functional Programming An Early History Higher level languages List processing & recursion Lisp popularizes paradigm FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON 1930s 1950s Origins
  • 24. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials Why this matters FP In Scala Origins
  • 25. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials If you can understand expressions and data structures, you understand functional programming
  • 26. Functional programming hasn’t materially changed since 1975 FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials
  • 27. Recursive Programming Techniques W.H. Burge (1975) FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials
  • 28. This was before… Polymorphic type inference Algebraic data types Lazy languages Category-theoretic terminology Introduction: Burge School of Functional Programming FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON W.H. Burge (1975) Essentials
  • 29. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials Functional Programming doesn’t care about your monads or type systems
  • 30. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Expressions Expressions Expressions Expressions Expressions Essentials
  • 31. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON 3x2 + y3x2 + y Essentials
  • 32. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON + (* (3, square(x)), y) 3x2 + y operators operands Essentials
  • 33. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON + (* (3, square(2)), 1) for x = 2, y = 1 operators operands Essentials
  • 34. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON + (* (3, 4), 1) operators operands for x = 2, y = 1 Essentials
  • 35. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON + (12, 1) operators operands for x = 2, y = 1 Essentials
  • 36. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON 13 for x = 2, y = 1 Essentials
  • 37. Side Effects Changes outside of function scope Modifies state Not predictable FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials
  • 38. Expressions Instead of statements Related: Pure functions Immutable data FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials
  • 39. Referential transparency An expression can be replaced by its value without changing the program behavior FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials
  • 40. Immutable data Avoid modifying state FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials
  • 41. Stateful programming is inherently complex FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials
  • 42. Expressions The programmer benefits Understanding Predictability Unit testing FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials
  • 43. Data Structures Constructing and Deconstructing FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials
  • 44. Data Structures Constructing and Deconstructing 1. How do you make the data? 2. How do you take it apart? FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials
  • 45. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON sealed abstract class List[+A]
 case class Cons[A](head: A, tail: List[A]) extends List[A]
 case object Null extends List[Nothing]
  • 46. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON def listFunction(list: List[Int]) =
 list match {
 case Cons(x, xs) => // ... something that uses x and xs...
 case Null => // ... something that can’t use x and xs... 
 }
  • 47. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON def length(l: List[Int]): Int =
 l match {
 case Cons(x, xs) => 1 + length(xs)
 case Null => 0
 }
  • 48. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON def sum(l: List[Int]): Int =
 l match {
 case Cons(x, xs) => x + sum(xs)
 case Null => 0
 }
  • 49. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON def product(l: List[Int]): Int =
 l match {
 case Cons(x, xs) => x * product(xs)
 case Null => 1
 }
  • 50. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON def list[A, B](f: (A,B) => B, d: B, xs: List[A]): B =
 xs match {
 case Cons(y, ys) => f(y, list(f,d,ys))
 case Null => d
 }
  • 51. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON def list[A, B](f: (A,B) => B, d: B, xs: List[A]): B def length ... = list((_, b) => 1 + b, 0, xs) 
 def sum ... = list((a, b) => a + b, 0, xs) def product ... = list((a, b) => a * b, 1, xs)
  • 52. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials If you can understand expressions and data structures, you understand functional programming
  • 54. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials Why this matters FP In Scala Origins
  • 55. “Standardized” Ladder of Functional Programming really FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON
  • 56. “Modern” Functional Programming is cluttered with jargon FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Why this matters
  • 58. “Jargon comes with an inherent cost. It needs to earn its place. (And it often does: jargon is necessary to discuss complex and domain- specific ideas.)” - Bonnie Eisenman FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON@KELLEYROBINSON Why this matters
  • 60. “It is also a striking demonstration of the fact that even definitions of very high quality are often inadequate as sources of information on usage.”
  • 61. Vocabulary and context are necessary for understanding
  • 63. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON ✨ Expressions & Data Structures ✨ 🤔 Abstraction FooBar Buzzword Baz 🤷 trends core concepts} }
  • 64. Someone has to maintain the code we write FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Why this matters
  • 65. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON “It may be fun to brag about knowing how to use "embedded DSL with combinators," but is that really the best thing to help your startup succeed?” - Hacker News Why this matters
  • 66. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Jargon is alienating Why this matters
  • 68. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials Why this matters FP In Scala Origins
  • 69. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON FP In Scala higher kinded types applied materialization existential types autotupling Dependent Types profunctor optics the cake pattern Existential quantifier CQRS Isomorphisms fundep materializers implicit resolution typeclass pattern vampire methods trampolining co-optic bananas the kitten pattern lupus ordering Comwell’s principle Meijer’s law Miller’s paradox Eta bindings endomonadic functors the jigsaw pattern Enum generators Dependent expressions Squid lenses hypelevel Scalareactive pandas multiverse inequalityproactive streams effectful constants lambda generators effectual effects semimonads WAR handles isomorphic esoterics Skolemization category philosophic Odersky indentation catamorphisms Hylomorphisms Lifted arrows recursive constants injuncted functions composable cats parachutes Mutumorphisms banana brackets algebraic idempotency contextual zygotes hyloadjoinct zygoid magma schema devolution Moors’ law compartial function generic serial versionable view triangular rings immuteratorreflexive ornaments Naperian functors delimited lambda buffer coinductive resumption monad lizards kleisli compositionCo-Yoneda lemmas GADT PJAs transfiguration covfefe monad
  • 70. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON FP In Scala higher kinded types applied materialization existential types autotupling Dependent Types profunctor optics the cake pattern Existential quantifier CQRS Isomorphisms fundep materializers implicit resolution typeclass pattern vampire methods trampolining co-optic bananas the kitten pattern lupus ordering Comwell’s principle Meijer’s law Miller’s paradox Eta bindings endomonadic functors the jigsaw pattern Enum generators Dependent expressions Squid lenses hypelevel Scalareactive pandas multiverse inequalityproactive streams effectful constants lambda generators effectual effects semimonads WAR handles isomorphic esoterics Skolemization category philosophic Odersky indentation catamorphisms Hylomorphisms Lifted arrows recursive constants injuncted functions composable cats parachutes Mutumorphisms banana brackets algebraic idempotency contextual zygotes hyloadjoinct zygoid magma schema devolution Moors’ law compartial function generic serial versionable view triangular rings immuteratorreflexive ornaments Naperian functors delimited lambda buffer coinductive resumption monad lizards kleisli compositionCo-Yoneda lemmas GADT PJAs 🙅 transfiguration covfefe monad
  • 71. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Storing data val var Iterating map for loop pattern matching procedural statements Deconstructing data preferred possible FP In Scala
  • 72. What about…? Cats…Scalaz…FREE MONADS!? Basics are built into Scala (think `map`, `fold`) Libraries have other syntactic sugar FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON FP In Scala
  • 73. • Build community • Promote understanding • Minimize jargon @KELLEYROBINSONFUNCTIONAL PROGRAMMING ESSENTIALS
  • 74. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON FP In Scala higher kinded types applied materialization existential types autotupling Dependent Types profunctor optics the cake pattern Existential quantifier CQRS Isomorphisms fundep materializers implicit resolution typeclass pattern vampire methods trampolining co-optic bananas the kitten pattern lupus ordering Comwell’s principle Meijer’s law Miller’s paradox Eta bindings endomonadic functors the jigsaw pattern Enum generators Dependent expressions Squid lenses hypelevel Scalareactive pandas multiverse inequalityproactive streams effectful constants lambda generators effectual effects semimonads WAR handles isomorphic esoterics Skolemization category philosophic Odersky indentation catamorphisms Hylomorphisms Lifted arrows recursive constants injuncted functions composable cats parachutes Mutumorphisms banana brackets algebraic idempotency contextual zygotes hyloadjoinct zygoid magma schema devolution Moors’ law compartial function generic serial versionable view triangular rings immuteratorreflexive ornaments Naperian functors delimited lambda buffer coinductive resumption monad lizards kleisli compositionCo-Yoneda lemmas GADT PJAs transfiguration covfefe monad
  • 75. FUNCTIONAL PROGRAMMING ESSENTIALS @KELLEYROBINSON Essentials bitly.com/scalajargon
  • 77. FUNCTIONAL PROGRAMMING ESSENTIALS Special thanks to • Sharethrough • José Calderón • Heather Miller • Bonnie Eisenman Resources • Mentioned in this talk: • Bonnie Eisenman on Scala Jargon • José Calderón's Burge School of Functional Programming • Conception, Evolution, and Application of Functional Programming Languages • Original LambdaConf ladder and Updated LambdaConf ladder • Vocabulary Processes • Further Reading & Watching: • Functional programming • Lambda calculus • John McCarthy - History of Lisp • Lambda Calculus - Computerphile • Mark Priestley - New Problems, New Paradigms • John Hughes, Mary Sheeran - Keynote: Why Functional Programming Matters • Vocabulary and Comprehension Research: • The Relationship between Reading Comprehension and Vocabulary Knowledge • The Relationship between Vocabulary Size and Reading Comprehension • Vocabulary and Word Study to Increase Comprehension in Content Areas • Why Vocabulary Instruction Matters • Effects of long-term vocabulary instruction on reading comprehension @KELLEYROBINSON
  • 78. @KELLEYROBINSONFUNCTIONAL PROGRAMMING ESSENTIALSFUNCTIONAL PROGRAMMING ESSENTIALS Photography credits • Opening image • Solving imaginary scaling issues • Paradigms • Orchestra • Alonzo Church • Philip Wadler • Glitter • Fortran • Chess • A Lisp machine in the MIT Museum • 1975 SNL cast • Side effects • Escher print • Legos • Jargon • Child reading • University • The thinker • Jargon is alienating • Cat typing @KELLEYROBINSON