SlideShare a Scribd company logo
WHY JAVASCRIPT FUNCTIONAL
PROGRAMMING
IS SO HARD?
Feb 2, 2016
Welcome to Fantasy Land!
Functional Programming Visualized
Core Functional Concepts
First Class Functions stored in variables, passed as arguments to functions,
created within functions and returned from functions
Higher Order Functions can accept functions as arguments, and/or can return a
function
Pure Functions is a function where the return value is only determined by its
input values, without observable Side Effects
Referential Transparency for a given set of arguments, the same code should
always output the same value, only by changing arguments can a output value be
different
Immutability is an inability for variables to change their values once created. In
other words, all things created stay constant
Core Functional Concepts
Currying / Partial Application - ability of a function to return a new function until
it receives all it's arguments. Calling a curried function with only some of its
arguments is called partial application
Tail Call Optimization - ability to avoid allocating a new stack frame for a function
call. The most common use is tail-recursion, where a recursive function uses
constant stack space.
Pattern matching is a form of conditional branching which allows you to concisely
match on data structure patterns and bind variables at the same time
Lazy Evaluation means that expressions are not evaluated when they are bound
to variables, but their evaluation is deferred until their results are needed by
other computations
Recommended Reading
Mostly Adequate Guide to Functional Programming,
https://drboolean.gitbooks.io/mostly-adequate-guide/content/
Tail call optimization in ECMAScript 6,
http://www.2ality.com/2015/06/tail-call-optimization.html
Functional Pattern Matching in JavaScript,
https://github.com/bramstein/funcy
Functional JavaScript Fundamentals
http://www.slideshare.net/Ssrdjan/functional-javascript-37401024
Want more? Put previously mentioned terms in Twitter ;)))
SO WHY FUNCTIONAL
PROGRAMMING
IS SO HARD?
WHY SO HARD?
Luck of understanding modern JavaScript aka ES6
https://github.com/reactima/reactima-redux-ecosystem/blob/master/JS.md
WHY SO HARD?
Imperative Habits
Most of us spend our lives,
in looping structures and if-then-else statements.
It’s hard to treat functions as variables and see chaining
process
99% of PROGRAMMERS DO THIS
FUNCTIONAL MINDED CODE
WHY SO HARD?
map, http://ramdajs.com/docs/#map
filter, http://ramdajs.com/docs/#filter
concatAll, http://ramdajs.com/docs/#concat
reduce, http://ramdajs.com/docs/#reduce
zip, http://ramdajs.com/docs/#zip
Luck of creativity with the most important functions
* - 80% of functional code in business apps
can be constituted from the above 5 function
WHY SO HARD?
MATH TERMS ARE ANNOYING
Most developers don’t bother to understand
underlying concepts
MONAD
Monad is defined computation as sequences of steps:
a type with a monad structure defines what it means
to chain operations, or nest functions of that type
together.
This allows the programmer to build pipelines that
process data in steps, in which each action
is decorated with additional processing rules provided
by the monad
https://en.wikipedia.org/wiki/Monad_(functional_programming)
Monads in JavaScript, https://curiosity-driven.org/monads-in-javascript
Functors, Applicatives, And Monads In Pictures http://adit.io/posts/2013-04-17-
functors,_applicatives,_and_monads_in_pictures.html
CRAZY?
99% of developers would never bother understand the next slide
WELCOME TO FANTASY LAND!
Spend some time with specification for interoperability
of common algebraic structures in JavaScript
VISIT US!
https://github.com/fantasyland/fantasy-land
DEATH CHART
Issue Open vs. Close Rate Over a Four Month Period
IMPERATIVE HABITS CONTRIBUTE A LOT TO THIS CHART!
NEXT?
I don’t understand concepts!
I just like to do coding!
SHOW ME THE CODE!
I don’t understand concepts!
SHOW ME THE CODE!
READ RAMDA TESTS!
https://github.com/ramda/ramda/tree/master/test
WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?
Thank you!
Ilya Sidorov @reactima
Interested to talk?
Let’s have a skype call: ilya.sidorov
1@ilya1.com
https://www.linkedin.com/in/reactima
https://github.com/reactima/

More Related Content

What's hot (20)

Function overloading in c++
Function overloading in c++
Learn By Watch
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India
 
Functions and tasks in verilog
Functions and tasks in verilog
Nallapati Anindra
 
Inline functions
Inline functions
DhwaniHingorani
 
Functional programming
Functional programming
Lhouceine OUHAMZA
 
Notes: Verilog Part 5 - Tasks and Functions
Notes: Verilog Part 5 - Tasks and Functions
Jay Baxi
 
virtual function
virtual function
VENNILAV6
 
Inline function in C++
Inline function in C++
Jenish Patel
 
Virtual function
Virtual function
Burhan Ahmed
 
Journey of a C# developer into Javascript
Journey of a C# developer into Javascript
Massimo Franciosa
 
Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6
Devang Garach
 
Functions in c++
Functions in c++
Maaz Hasan
 
Ruby Functional Programming
Ruby Functional Programming
Geison Goes
 
Inline Functions and Default arguments
Inline Functions and Default arguments
Nikhil Pandit
 
Functional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smart
Chen Fisher
 
Functional programming and ruby in functional style
Functional programming and ruby in functional style
Niranjan Sarade
 
Java script function
Java script function
suresh raj sharma
 
Create and analyse programs
Create and analyse programs
Dr. C.V. Suresh Babu
 
Annotation Processing - Demystifying Java's Dark Arts
Annotation Processing - Demystifying Java's Dark Arts
James Kirkbride
 
SOLID Principles
SOLID Principles
Yi-Huan Chan
 
Function overloading in c++
Function overloading in c++
Learn By Watch
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India
 
Functions and tasks in verilog
Functions and tasks in verilog
Nallapati Anindra
 
Notes: Verilog Part 5 - Tasks and Functions
Notes: Verilog Part 5 - Tasks and Functions
Jay Baxi
 
virtual function
virtual function
VENNILAV6
 
Inline function in C++
Inline function in C++
Jenish Patel
 
Journey of a C# developer into Javascript
Journey of a C# developer into Javascript
Massimo Franciosa
 
Advanced JavaScript - Internship Presentation - Week6
Advanced JavaScript - Internship Presentation - Week6
Devang Garach
 
Functions in c++
Functions in c++
Maaz Hasan
 
Ruby Functional Programming
Ruby Functional Programming
Geison Goes
 
Inline Functions and Default arguments
Inline Functions and Default arguments
Nikhil Pandit
 
Functional programming with Ruby - can make you look smart
Functional programming with Ruby - can make you look smart
Chen Fisher
 
Functional programming and ruby in functional style
Functional programming and ruby in functional style
Niranjan Sarade
 
Annotation Processing - Demystifying Java's Dark Arts
Annotation Processing - Demystifying Java's Dark Arts
James Kirkbride
 

Viewers also liked (7)

Hardcore functional programming
Hardcore functional programming
Leonardo Andres Garcia Crespo
 
Lars thorup-react-and-redux-2016-09
Lars thorup-react-and-redux-2016-09
BestBrains
 
Ramda, a functional JavaScript library
Ramda, a functional JavaScript library
Derek Willian Stavis
 
Ramda lets write declarative js
Ramda lets write declarative js
Pivorak MeetUp
 
Functional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis Atencio
Luis Atencio
 
Introduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScript
tmont
 
The Aggregation Framework
The Aggregation Framework
MongoDB
 
Lars thorup-react-and-redux-2016-09
Lars thorup-react-and-redux-2016-09
BestBrains
 
Ramda, a functional JavaScript library
Ramda, a functional JavaScript library
Derek Willian Stavis
 
Ramda lets write declarative js
Ramda lets write declarative js
Pivorak MeetUp
 
Functional Programming in JavaScript by Luis Atencio
Functional Programming in JavaScript by Luis Atencio
Luis Atencio
 
Introduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScript
tmont
 
The Aggregation Framework
The Aggregation Framework
MongoDB
 
Ad

Similar to WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? (20)

Functional programming is the most extreme programming
Functional programming is the most extreme programming
samthemonad
 
379008-rc217-functionalprogramming
379008-rc217-functionalprogramming
Luis Atencio
 
React & Redux JS
React & Redux JS
Hamed Farag
 
Introduction to functional programming
Introduction to functional programming
Thang Mai
 
Java 8 Interview Questions and Answers PDF By ScholarHat.pdf
Java 8 Interview Questions and Answers PDF By ScholarHat.pdf
Scholarhat
 
Corso su ReactJS
Corso su ReactJS
LinkMe Srl
 
Functional programming in TypeScript
Functional programming in TypeScript
binDebug WorkSpace
 
Introduction to Functional Reactive Web with Clojurescript
Introduction to Functional Reactive Web with Clojurescript
John Stevenson
 
imperative programming language, java, android
imperative programming language, java, android
i i
 
Functional Programming in Java
Functional Programming in Java
Narendran Solai Sridharan
 
Aspect-oriented programming in Perl
Aspect-oriented programming in Perl
megakott
 
Why functional programming in C# & F#
Why functional programming in C# & F#
Riccardo Terrell
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
Paul Jensen
 
Patterns in Python
Patterns in Python
dn
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
Codemotion
 
Important JavaScript Concepts Every Developer Must Know
Important JavaScript Concepts Every Developer Must Know
yashikanigam1
 
Unit 2
Unit 2
R S S RAJU BATTULA
 
Lecture: Refactoring
Lecture: Refactoring
Marcus Denker
 
SMI - Introduction to Java
SMI - Introduction to Java
SMIJava
 
Learn about SPARK tool and it's componemts
Learn about SPARK tool and it's componemts
siddharth30121
 
Functional programming is the most extreme programming
Functional programming is the most extreme programming
samthemonad
 
379008-rc217-functionalprogramming
379008-rc217-functionalprogramming
Luis Atencio
 
React & Redux JS
React & Redux JS
Hamed Farag
 
Introduction to functional programming
Introduction to functional programming
Thang Mai
 
Java 8 Interview Questions and Answers PDF By ScholarHat.pdf
Java 8 Interview Questions and Answers PDF By ScholarHat.pdf
Scholarhat
 
Corso su ReactJS
Corso su ReactJS
LinkMe Srl
 
Functional programming in TypeScript
Functional programming in TypeScript
binDebug WorkSpace
 
Introduction to Functional Reactive Web with Clojurescript
Introduction to Functional Reactive Web with Clojurescript
John Stevenson
 
imperative programming language, java, android
imperative programming language, java, android
i i
 
Aspect-oriented programming in Perl
Aspect-oriented programming in Perl
megakott
 
Why functional programming in C# & F#
Why functional programming in C# & F#
Riccardo Terrell
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
Paul Jensen
 
Patterns in Python
Patterns in Python
dn
 
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
Codemotion
 
Important JavaScript Concepts Every Developer Must Know
Important JavaScript Concepts Every Developer Must Know
yashikanigam1
 
Lecture: Refactoring
Lecture: Refactoring
Marcus Denker
 
SMI - Introduction to Java
SMI - Introduction to Java
SMIJava
 
Learn about SPARK tool and it's componemts
Learn about SPARK tool and it's componemts
siddharth30121
 
Ad

Recently uploaded (20)

UV_Unwrapping_Lecture_with_Figures.pptx presentation for lecture of animation
UV_Unwrapping_Lecture_with_Figures.pptx presentation for lecture of animation
17218
 
Networking_Essentials_version_3.0_-_Module_7.pptx
Networking_Essentials_version_3.0_-_Module_7.pptx
elestirmen
 
10 Latest Technologies and Their Benefits to End.pptx
10 Latest Technologies and Their Benefits to End.pptx
EphraimOOghodero
 
Unlocking Business Growth Through Targeted Social Engagement
Unlocking Business Growth Through Targeted Social Engagement
Digital Guider
 
PPT 18.03.2023.pptx for i smart programme
PPT 18.03.2023.pptx for i smart programme
AbhimanShastry
 
Inter-Mirifica-Navigating-Media-in-the-Modern-World.pptx
Inter-Mirifica-Navigating-Media-in-the-Modern-World.pptx
secretarysocom
 
3D Graphics an introduction and details .pptx
3D Graphics an introduction and details .pptx
islamicknowledge5224
 
rosoft PowcgnggerPoint Presentation.pptx
rosoft PowcgnggerPoint Presentation.pptx
sirbabu778
 
How to Make Money as a Cam Model – Tips, Tools & Real Talk
How to Make Money as a Cam Model – Tips, Tools & Real Talk
Cam Sites Expert
 
Internet_of_Things_Presentation_by-Humera.pptx
Internet_of_Things_Presentation_by-Humera.pptx
cshumerabashir
 
In order to install and use the device software, your computer must meet the ...
In order to install and use the device software, your computer must meet the ...
raguclc
 
ICP -2 Review – What It Is, and How to Participate and Provide Your Feedback
ICP -2 Review – What It Is, and How to Participate and Provide Your Feedback
APNIC
 
What to Expect When Hiring Shopify Development Services_ A Technical Walkthro...
What to Expect When Hiring Shopify Development Services_ A Technical Walkthro...
CartCoders
 
Google_Cloud_Computing_Fundamentals.pptx
Google_Cloud_Computing_Fundamentals.pptx
ektadangwal2005
 
Vigilanti-Cura-Protecting-the-Faith.pptx
Vigilanti-Cura-Protecting-the-Faith.pptx
secretarysocom
 
最新版西班牙加泰罗尼亚国际大学毕业证(UIC毕业证书)原版定制
最新版西班牙加泰罗尼亚国际大学毕业证(UIC毕业证书)原版定制
Taqyea
 
Cloud Computing - iCloud by Hamza Anwaar .pptx
Cloud Computing - iCloud by Hamza Anwaar .pptx
islamicknowledge5224
 
AI theory work for students to understand the logic
AI theory work for students to understand the logic
areeba15775n
 
Quantiuwewe e3er14e we3223 32222 m2.pptx
Quantiuwewe e3er14e we3223 32222 m2.pptx
cyberesearchprof
 
MOBILE PHONE DATA presentation with all necessary details
MOBILE PHONE DATA presentation with all necessary details
benamorraj
 
UV_Unwrapping_Lecture_with_Figures.pptx presentation for lecture of animation
UV_Unwrapping_Lecture_with_Figures.pptx presentation for lecture of animation
17218
 
Networking_Essentials_version_3.0_-_Module_7.pptx
Networking_Essentials_version_3.0_-_Module_7.pptx
elestirmen
 
10 Latest Technologies and Their Benefits to End.pptx
10 Latest Technologies and Their Benefits to End.pptx
EphraimOOghodero
 
Unlocking Business Growth Through Targeted Social Engagement
Unlocking Business Growth Through Targeted Social Engagement
Digital Guider
 
PPT 18.03.2023.pptx for i smart programme
PPT 18.03.2023.pptx for i smart programme
AbhimanShastry
 
Inter-Mirifica-Navigating-Media-in-the-Modern-World.pptx
Inter-Mirifica-Navigating-Media-in-the-Modern-World.pptx
secretarysocom
 
3D Graphics an introduction and details .pptx
3D Graphics an introduction and details .pptx
islamicknowledge5224
 
rosoft PowcgnggerPoint Presentation.pptx
rosoft PowcgnggerPoint Presentation.pptx
sirbabu778
 
How to Make Money as a Cam Model – Tips, Tools & Real Talk
How to Make Money as a Cam Model – Tips, Tools & Real Talk
Cam Sites Expert
 
Internet_of_Things_Presentation_by-Humera.pptx
Internet_of_Things_Presentation_by-Humera.pptx
cshumerabashir
 
In order to install and use the device software, your computer must meet the ...
In order to install and use the device software, your computer must meet the ...
raguclc
 
ICP -2 Review – What It Is, and How to Participate and Provide Your Feedback
ICP -2 Review – What It Is, and How to Participate and Provide Your Feedback
APNIC
 
What to Expect When Hiring Shopify Development Services_ A Technical Walkthro...
What to Expect When Hiring Shopify Development Services_ A Technical Walkthro...
CartCoders
 
Google_Cloud_Computing_Fundamentals.pptx
Google_Cloud_Computing_Fundamentals.pptx
ektadangwal2005
 
Vigilanti-Cura-Protecting-the-Faith.pptx
Vigilanti-Cura-Protecting-the-Faith.pptx
secretarysocom
 
最新版西班牙加泰罗尼亚国际大学毕业证(UIC毕业证书)原版定制
最新版西班牙加泰罗尼亚国际大学毕业证(UIC毕业证书)原版定制
Taqyea
 
Cloud Computing - iCloud by Hamza Anwaar .pptx
Cloud Computing - iCloud by Hamza Anwaar .pptx
islamicknowledge5224
 
AI theory work for students to understand the logic
AI theory work for students to understand the logic
areeba15775n
 
Quantiuwewe e3er14e we3223 32222 m2.pptx
Quantiuwewe e3er14e we3223 32222 m2.pptx
cyberesearchprof
 
MOBILE PHONE DATA presentation with all necessary details
MOBILE PHONE DATA presentation with all necessary details
benamorraj
 

WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD?

  • 1. WHY JAVASCRIPT FUNCTIONAL PROGRAMMING IS SO HARD? Feb 2, 2016 Welcome to Fantasy Land!
  • 3. Core Functional Concepts First Class Functions stored in variables, passed as arguments to functions, created within functions and returned from functions Higher Order Functions can accept functions as arguments, and/or can return a function Pure Functions is a function where the return value is only determined by its input values, without observable Side Effects Referential Transparency for a given set of arguments, the same code should always output the same value, only by changing arguments can a output value be different Immutability is an inability for variables to change their values once created. In other words, all things created stay constant
  • 4. Core Functional Concepts Currying / Partial Application - ability of a function to return a new function until it receives all it's arguments. Calling a curried function with only some of its arguments is called partial application Tail Call Optimization - ability to avoid allocating a new stack frame for a function call. The most common use is tail-recursion, where a recursive function uses constant stack space. Pattern matching is a form of conditional branching which allows you to concisely match on data structure patterns and bind variables at the same time Lazy Evaluation means that expressions are not evaluated when they are bound to variables, but their evaluation is deferred until their results are needed by other computations
  • 5. Recommended Reading Mostly Adequate Guide to Functional Programming, https://drboolean.gitbooks.io/mostly-adequate-guide/content/ Tail call optimization in ECMAScript 6, http://www.2ality.com/2015/06/tail-call-optimization.html Functional Pattern Matching in JavaScript, https://github.com/bramstein/funcy Functional JavaScript Fundamentals http://www.slideshare.net/Ssrdjan/functional-javascript-37401024 Want more? Put previously mentioned terms in Twitter ;)))
  • 7. WHY SO HARD? Luck of understanding modern JavaScript aka ES6 https://github.com/reactima/reactima-redux-ecosystem/blob/master/JS.md
  • 8. WHY SO HARD? Imperative Habits Most of us spend our lives, in looping structures and if-then-else statements. It’s hard to treat functions as variables and see chaining process
  • 11. WHY SO HARD? map, http://ramdajs.com/docs/#map filter, http://ramdajs.com/docs/#filter concatAll, http://ramdajs.com/docs/#concat reduce, http://ramdajs.com/docs/#reduce zip, http://ramdajs.com/docs/#zip Luck of creativity with the most important functions * - 80% of functional code in business apps can be constituted from the above 5 function
  • 12. WHY SO HARD? MATH TERMS ARE ANNOYING Most developers don’t bother to understand underlying concepts
  • 13. MONAD Monad is defined computation as sequences of steps: a type with a monad structure defines what it means to chain operations, or nest functions of that type together. This allows the programmer to build pipelines that process data in steps, in which each action is decorated with additional processing rules provided by the monad https://en.wikipedia.org/wiki/Monad_(functional_programming) Monads in JavaScript, https://curiosity-driven.org/monads-in-javascript Functors, Applicatives, And Monads In Pictures http://adit.io/posts/2013-04-17- functors,_applicatives,_and_monads_in_pictures.html
  • 14. CRAZY? 99% of developers would never bother understand the next slide
  • 15. WELCOME TO FANTASY LAND! Spend some time with specification for interoperability of common algebraic structures in JavaScript VISIT US! https://github.com/fantasyland/fantasy-land
  • 16. DEATH CHART Issue Open vs. Close Rate Over a Four Month Period IMPERATIVE HABITS CONTRIBUTE A LOT TO THIS CHART!
  • 17. NEXT? I don’t understand concepts! I just like to do coding! SHOW ME THE CODE! I don’t understand concepts! SHOW ME THE CODE!
  • 20. Thank you! Ilya Sidorov @reactima Interested to talk? Let’s have a skype call: ilya.sidorov [email protected] https://www.linkedin.com/in/reactima https://github.com/reactima/