SlideShare a Scribd company logo
MAKING LIFE EASIER WITH JUST
TYPES AND FUNCTIONS
CHANDAN SINGH
ThoughtWorks
the curse of functional programming!
once you understand it well enough, you lose the
ability to explain it to others...
why (typed) functional programming?
it looks cool on your résumé!
complaints against FP?
it’s weird,
impractical,
why do it when OO/Procedural just works?
theoretical/academic nonsense,
no one really does it
who’s doing FP?
Facebook,
Twitter,
LinkedIn,
Microsoft,
Chef,
Many banks...
There’s something about the
culture of software that has
impeded the use of
specification. We have a
wonderful way of describing
things precisely that has been
developed over the last couple
of millennia, and it’s called
Mathematics.
-- Leslie Lamport,
Turing Award Winner, 2013.
what does FP bring to the table?
good code
easy to read
easy to understand
easy to test
easy to maintain
insanity!
doing the same thing over
and over again, and
expecting different
results!
--Albert Einstein
launchMissiles();
=> destroys enemy units
launchMissiles();
=> throws OutOfMissilesException
what is FP?
lambda calculus
id(x) = x
x -> x
square_sum(x, y) = x * x + y * y
(x, y) -> x * x + y * y
x -> (y -> (x * x + y * y))
confused? let’s make it simple!
pure functions, no side effects
also, higher order functions
what’s a function?
a mapping,
each input mapped to exactly
one output,
domain co-domain
functions are inherently typed
meaningful mappings,
transformation rules => constraints,
capture constraints precisely
public Integer square(Integer n)
{
n = n * n;
return n;
}
mutation, side effecting => impure
public Integer square(Integer n)
{
return n * n;
}
no side effect, does only one thing => pure
impure stuff
setters,
void/unit methods,
in-memory updates,
random()
what’s wrong with impure stuff?
contextual dependency
state changes
order of execution is important
far too much guessing to be done
stop talking, show some code!
so why is this FP suddenly a rage?
concurrency ...
immutability, ftw!
code, code, more code...
so again, why (typed) FP?
making things easier,
programming with less effort,
developer happiness!
thank you!

More Related Content

Viewers also liked

Kamen Rider Benkyoukai
Kamen Rider BenkyoukaiKamen Rider Benkyoukai
Kamen Rider Benkyoukai
Katsumi Yagi
 
MRI Letter
MRI LetterMRI Letter
MRI Letter
Patti Beller
 
OSCP
OSCPOSCP
OSCP
Ip S
 
формування інд.стилю вчителя музики
формування інд.стилю вчителя музикиформування інд.стилю вчителя музики
формування інд.стилю вчителя музикиnatalia0803
 
نموذج خطة تعليمية فردية
نموذج خطة تعليمية فرديةنموذج خطة تعليمية فردية
نموذج خطة تعليمية فردية
LAILAF_M
 
فلسفة التخلق
فلسفة التخلقفلسفة التخلق
فلسفة التخلق
Ali Abo Al-hasan
 
ثراء العلاقات
ثراء العلاقاتثراء العلاقات
ثراء العلاقات
Ali Abo Al-hasan
 
The Romantic Movement
The Romantic MovementThe Romantic Movement
The Romantic Movement
treasuretrove78
 
родина
родинародина
родина
treasuretrove78
 
ذكاء المشاعر والتحكم فى الانفعالات
ذكاء المشاعر والتحكم فى الانفعالاتذكاء المشاعر والتحكم فى الانفعالات
ذكاء المشاعر والتحكم فى الانفعالات
Muhammed Rashed
 
Психологічні особливості підліткового віку
Психологічні особливості підліткового вікуПсихологічні особливості підліткового віку
Психологічні особливості підліткового віку
nataliyu roschina
 
Конкурс профспілок Миколаївщини
Конкурс профспілок МиколаївщиниКонкурс профспілок Миколаївщини
Конкурс профспілок Миколаївщини
nataliyu roschina
 
نهاية و بداية العام [ الهجرة ]
نهاية و بداية العام [ الهجرة ]نهاية و بداية العام [ الهجرة ]
نهاية و بداية العام [ الهجرة ]
Ali Abo Al-hasan
 
السلسلة الرمضانية الكاملة
السلسلة الرمضانية الكاملة السلسلة الرمضانية الكاملة
السلسلة الرمضانية الكاملة
Ali Abo Al-hasan
 
15 Common Myths you were taught to believe about Cars
15 Common Myths you were taught to believe about Cars15 Common Myths you were taught to believe about Cars
15 Common Myths you were taught to believe about Cars
Eason Chan
 

Viewers also liked (15)

Kamen Rider Benkyoukai
Kamen Rider BenkyoukaiKamen Rider Benkyoukai
Kamen Rider Benkyoukai
 
MRI Letter
MRI LetterMRI Letter
MRI Letter
 
OSCP
OSCPOSCP
OSCP
 
формування інд.стилю вчителя музики
формування інд.стилю вчителя музикиформування інд.стилю вчителя музики
формування інд.стилю вчителя музики
 
نموذج خطة تعليمية فردية
نموذج خطة تعليمية فرديةنموذج خطة تعليمية فردية
نموذج خطة تعليمية فردية
 
فلسفة التخلق
فلسفة التخلقفلسفة التخلق
فلسفة التخلق
 
ثراء العلاقات
ثراء العلاقاتثراء العلاقات
ثراء العلاقات
 
The Romantic Movement
The Romantic MovementThe Romantic Movement
The Romantic Movement
 
родина
родинародина
родина
 
ذكاء المشاعر والتحكم فى الانفعالات
ذكاء المشاعر والتحكم فى الانفعالاتذكاء المشاعر والتحكم فى الانفعالات
ذكاء المشاعر والتحكم فى الانفعالات
 
Психологічні особливості підліткового віку
Психологічні особливості підліткового вікуПсихологічні особливості підліткового віку
Психологічні особливості підліткового віку
 
Конкурс профспілок Миколаївщини
Конкурс профспілок МиколаївщиниКонкурс профспілок Миколаївщини
Конкурс профспілок Миколаївщини
 
نهاية و بداية العام [ الهجرة ]
نهاية و بداية العام [ الهجرة ]نهاية و بداية العام [ الهجرة ]
نهاية و بداية العام [ الهجرة ]
 
السلسلة الرمضانية الكاملة
السلسلة الرمضانية الكاملة السلسلة الرمضانية الكاملة
السلسلة الرمضانية الكاملة
 
15 Common Myths you were taught to believe about Cars
15 Common Myths you were taught to believe about Cars15 Common Myths you were taught to believe about Cars
15 Common Myths you were taught to believe about Cars
 

Similar to Making life easier with just types and functions

Web2.0 And You Ppt
Web2.0 And You PptWeb2.0 And You Ppt
Web2.0 And You Ppt
Lisa Read
 
Yenikod Yazılım Kursu - Kodlama Öğrenebilir Miyim? Kodlama Bana Göre Mi?
Yenikod Yazılım Kursu - Kodlama Öğrenebilir Miyim? Kodlama Bana Göre Mi?Yenikod Yazılım Kursu - Kodlama Öğrenebilir Miyim? Kodlama Bana Göre Mi?
Yenikod Yazılım Kursu - Kodlama Öğrenebilir Miyim? Kodlama Bana Göre Mi?
Mustafa Ekim
 
All worksheet
All worksheetAll worksheet
All worksheet
Namrata Mehta
 
System Dynamics and FOSS
System Dynamics and FOSSSystem Dynamics and FOSS
System Dynamics and FOSS
Maikel Mardjan
 
Good programming
Good programmingGood programming
Good programming
Won Kwang University
 
Mastering python lesson1
Mastering python lesson1Mastering python lesson1
Mastering python lesson1
Ruth Marvin
 
Machine Learning Workshop, TSEC 2020
Machine Learning Workshop, TSEC 2020Machine Learning Workshop, TSEC 2020
Machine Learning Workshop, TSEC 2020
Siddharth Adelkar
 
Distributed cat herding
Distributed cat herdingDistributed cat herding
Distributed cat herding
Jilles van Gurp
 
'10 Great but now Overlooked Tools' by Graham Thomas
'10 Great but now Overlooked Tools' by Graham Thomas'10 Great but now Overlooked Tools' by Graham Thomas
'10 Great but now Overlooked Tools' by Graham Thomas
TEST Huddle
 
LEARNING BASIC PROGRAMMING PRINCIPLES THROUGH A GAME
LEARNING BASIC PROGRAMMING PRINCIPLES THROUGH A GAMELEARNING BASIC PROGRAMMING PRINCIPLES THROUGH A GAME
LEARNING BASIC PROGRAMMING PRINCIPLES THROUGH A GAME
ChamithSaranga
 
The Quest for the Ultimate UX Portfolio
The Quest for the Ultimate UX PortfolioThe Quest for the Ultimate UX Portfolio
The Quest for the Ultimate UX Portfolio
Pradeep Nayar
 
Functional programming
Functional programmingFunctional programming
Functional programming
OpenAgile Romania
 
Lec 1 25_jul13
Lec 1 25_jul13Lec 1 25_jul13
Lec 1 25_jul13
Palak Sanghani
 
Mastering python lesson2
Mastering python lesson2Mastering python lesson2
Mastering python lesson2
Ruth Marvin
 
Computer science basics for nonit students
Computer science basics for nonit studentsComputer science basics for nonit students
Computer science basics for nonit students
Srikanth KS
 
Learning to code in 2020
Learning to code in 2020Learning to code in 2020
Learning to code in 2020
Nicholas Sterling
 
Julia: compiler and community
Julia: compiler and communityJulia: compiler and community
Julia: compiler and community
Jiahao Chen
 
UCD / IxD Introduction - User centric design, interaction design
UCD / IxD Introduction - User centric design, interaction designUCD / IxD Introduction - User centric design, interaction design
UCD / IxD Introduction - User centric design, interaction design
sdavis6b
 
UPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer TidwellUPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer Tidwell
nikrao
 
UPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer TidwellUPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer Tidwell
guestf59d1c4
 

Similar to Making life easier with just types and functions (20)

Web2.0 And You Ppt
Web2.0 And You PptWeb2.0 And You Ppt
Web2.0 And You Ppt
 
Yenikod Yazılım Kursu - Kodlama Öğrenebilir Miyim? Kodlama Bana Göre Mi?
Yenikod Yazılım Kursu - Kodlama Öğrenebilir Miyim? Kodlama Bana Göre Mi?Yenikod Yazılım Kursu - Kodlama Öğrenebilir Miyim? Kodlama Bana Göre Mi?
Yenikod Yazılım Kursu - Kodlama Öğrenebilir Miyim? Kodlama Bana Göre Mi?
 
All worksheet
All worksheetAll worksheet
All worksheet
 
System Dynamics and FOSS
System Dynamics and FOSSSystem Dynamics and FOSS
System Dynamics and FOSS
 
Good programming
Good programmingGood programming
Good programming
 
Mastering python lesson1
Mastering python lesson1Mastering python lesson1
Mastering python lesson1
 
Machine Learning Workshop, TSEC 2020
Machine Learning Workshop, TSEC 2020Machine Learning Workshop, TSEC 2020
Machine Learning Workshop, TSEC 2020
 
Distributed cat herding
Distributed cat herdingDistributed cat herding
Distributed cat herding
 
'10 Great but now Overlooked Tools' by Graham Thomas
'10 Great but now Overlooked Tools' by Graham Thomas'10 Great but now Overlooked Tools' by Graham Thomas
'10 Great but now Overlooked Tools' by Graham Thomas
 
LEARNING BASIC PROGRAMMING PRINCIPLES THROUGH A GAME
LEARNING BASIC PROGRAMMING PRINCIPLES THROUGH A GAMELEARNING BASIC PROGRAMMING PRINCIPLES THROUGH A GAME
LEARNING BASIC PROGRAMMING PRINCIPLES THROUGH A GAME
 
The Quest for the Ultimate UX Portfolio
The Quest for the Ultimate UX PortfolioThe Quest for the Ultimate UX Portfolio
The Quest for the Ultimate UX Portfolio
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Lec 1 25_jul13
Lec 1 25_jul13Lec 1 25_jul13
Lec 1 25_jul13
 
Mastering python lesson2
Mastering python lesson2Mastering python lesson2
Mastering python lesson2
 
Computer science basics for nonit students
Computer science basics for nonit studentsComputer science basics for nonit students
Computer science basics for nonit students
 
Learning to code in 2020
Learning to code in 2020Learning to code in 2020
Learning to code in 2020
 
Julia: compiler and community
Julia: compiler and communityJulia: compiler and community
Julia: compiler and community
 
UCD / IxD Introduction - User centric design, interaction design
UCD / IxD Introduction - User centric design, interaction designUCD / IxD Introduction - User centric design, interaction design
UCD / IxD Introduction - User centric design, interaction design
 
UPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer TidwellUPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer Tidwell
 
UPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer TidwellUPA2007 Designing Interfaces Jenifer Tidwell
UPA2007 Designing Interfaces Jenifer Tidwell
 

Making life easier with just types and functions