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)

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

Viewers also liked (7)

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

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

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

Recently uploaded (20)

PPTX
西班牙巴利阿里群岛大学电子版毕业证{UIBLetterUIB文凭证书}文凭复刻
Taqyea
 
PDF
Boardroom AI: The Next 10 Moves | Cerebraix Talent Tech
ssuser73bdb11
 
DOCX
Custom vs. Off-the-Shelf Banking Software
KristenCarter35
 
PPTX
Softuni - Psychology of entrepreneurship
Kalin Karakehayov
 
PDF
BRKAPP-1102 - Proactive Network and Application Monitoring.pdf
fcesargonca
 
PDF
The Hidden Benefits of Outsourcing IT Hardware Procurement for Small Businesses
Carley Cramer
 
PPTX
Networking_Essentials_version_3.0_-_Module_3.pptx
ryan622010
 
PDF
The Internet - By the numbers, presented at npNOG 11
APNIC
 
PPTX
04 Output 1 Instruments & Tools (3).pptx
GEDYIONGebre
 
PPTX
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
PDF
Digital burnout toolkit for youth workers and teachers
asociatiastart123
 
PPTX
美国电子毕业证帕克大学电子版成绩单UMCP学费发票办理学历认证
Taqyea
 
PDF
BRKSP-2551 - Introduction to Segment Routing.pdf
fcesargonca
 
PPTX
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
PDF
FutureCon Seattle 2025 Presentation Slides - You Had One Job
Suzanne Aldrich
 
PPTX
Networking_Essentials_version_3.0_-_Module_5.pptx
ryan622010
 
PPTX
原版一样(LHU毕业证书)英国利物浦希望大学毕业证办理方法
Taqyea
 
PDF
Top 10 Testing Procedures to Ensure Your Magento to Shopify Migration Success...
CartCoders
 
PPTX
Academic Debate: Creation vs Evolution.pptx
JOHNPATRICKMARTINEZ5
 
PPTX
PHIPA-Compliant Web Hosting in Toronto: What Healthcare Providers Must Know
steve198109
 
西班牙巴利阿里群岛大学电子版毕业证{UIBLetterUIB文凭证书}文凭复刻
Taqyea
 
Boardroom AI: The Next 10 Moves | Cerebraix Talent Tech
ssuser73bdb11
 
Custom vs. Off-the-Shelf Banking Software
KristenCarter35
 
Softuni - Psychology of entrepreneurship
Kalin Karakehayov
 
BRKAPP-1102 - Proactive Network and Application Monitoring.pdf
fcesargonca
 
The Hidden Benefits of Outsourcing IT Hardware Procurement for Small Businesses
Carley Cramer
 
Networking_Essentials_version_3.0_-_Module_3.pptx
ryan622010
 
The Internet - By the numbers, presented at npNOG 11
APNIC
 
04 Output 1 Instruments & Tools (3).pptx
GEDYIONGebre
 
Lec15_Mutability Immutability-converted.pptx
khanjahanzaib1
 
Digital burnout toolkit for youth workers and teachers
asociatiastart123
 
美国电子毕业证帕克大学电子版成绩单UMCP学费发票办理学历认证
Taqyea
 
BRKSP-2551 - Introduction to Segment Routing.pdf
fcesargonca
 
L1A Season 1 ENGLISH made by A hegy fixed
toszolder91
 
FutureCon Seattle 2025 Presentation Slides - You Had One Job
Suzanne Aldrich
 
Networking_Essentials_version_3.0_-_Module_5.pptx
ryan622010
 
原版一样(LHU毕业证书)英国利物浦希望大学毕业证办理方法
Taqyea
 
Top 10 Testing Procedures to Ensure Your Magento to Shopify Migration Success...
CartCoders
 
Academic Debate: Creation vs Evolution.pptx
JOHNPATRICKMARTINEZ5
 
PHIPA-Compliant Web Hosting in Toronto: What Healthcare Providers Must Know
steve198109
 

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/