Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Learning Functional Programming with JavaScript
Search
Anjana Sofia Vakil
April 24, 2016
Programming
0
840
Learning Functional Programming with JavaScript
Given at JSUnconf 2016 (
http://2016.jsunconf.eu/
)
Anjana Sofia Vakil
April 24, 2016
Tweet
Share
More Decks by Anjana Sofia Vakil
See All by Anjana Sofia Vakil
The Art of Functional Programming
vakila
0
230
First Steps into Functional Programming
vakila
7
2.4k
The Language of Programming
vakila
4
660
Recursion, Iteration, & JavaScript: A love story
vakila
1
440
From Big Band Web App to Serverless Bebop
vakila
0
520
Embracing Constraints
vakila
1
210
Programming across paradigms
vakila
1
740
Immutable data structures for functional JavaScript
vakila
7
1.8k
Functional Programming: What? Why? How?
vakila
1
300
Other Decks in Programming
See All in Programming
WebRTC と Rust と8K 60fps
tnoho
2
2k
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
390
WebRTC、 綺麗に見るか滑らかに見るか
sublimer
1
160
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
4
850
関数実行の裏側では何が起きているのか?
minop1205
1
690
俺流レスポンシブコーディング 2025
tak_dcxi
14
8.7k
著者と進める!『AIと個人開発したくなったらまずCursorで要件定義だ!』
yasunacoffee
0
130
S3 VectorsとStrands Agentsを利用したAgentic RAGシステムの構築
tosuri13
6
310
AIコーディングエージェント(skywork)
kondai24
0
170
MAP, Jigsaw, Code Golf 振り返り会 by 関東Kaggler会|Jigsaw 15th Solution
hasibirok0
0
240
DSPy Meetup Tokyo #1 - はじめてのDSPy
masahiro_nishimi
1
170
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
400
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Balancing Empowerment & Direction
lara
5
800
Art, The Web, and Tiny UX
lynnandtonic
303
21k
The Cult of Friendly URLs
andyhume
79
6.7k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.4k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Scaling GitHub
holman
464
140k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.6k
Transcript
Learning Functional Programming with JS @AnjanaVakil
The Recurse Center https://www.recurse.com/
What is functional programming?
What is functional programming? a programming paradigm
What is functional programming? a coding style
What is functional programming? a mindset
What is functional programming? a sexy, buzz-wordy trend
Why functional JavaScript?
Why functional JavaScript? object-oriented JS gets tricky (prototypes? this?!?)
Why functional JavaScript? safer, easier to debug/maintain
Why functional JavaScript? established community
OK, let’s do it!
OK, let’s do it! ...how?
Do everything with functions input -> output
Not functional: var name = “Anjana”; var greeting = “Hi,
I’m ”; console.log(greeting + name); => “Hi, I’m Anjana”
Functional: function greet(name) { return “Hi, I’m ” + name;
} greet(“Anjana”); => “Hi, I’m Anjana”
Avoid side effects use “pure” functions
Not pure: var name = “Anjana”; function greet() { console.log(“Hi,
I’m ” + name); }
Pure: function greet(name) { return “Hi, I’m ” + name;
}
Use higher-order functions functions can be inputs/outputs
function makeAdjectifier(adjective) { return function (string) { return adjective +
“ ” + string; }; } var coolifier = makeAdjectifier(“cool”); coolifier(“conference”); => “cool conference”
Don’t iterate use map, reduce, filter
http://www.datasciencecentral.com/forum/topics/what-is-map-reduce
Avoid mutability use immutable data
Mutation (bad!): var rooms = [“H1”, “H2”, “H3”]; rooms[2] =
“H4”; rooms; => ["H1", "H2", "H4"]
No mutation (good!): var rooms = [“H1”, “H2”, “H3”]; Var
newRooms = rooms.map(function (rm) { if (rm == “H3”) { return “H4”; } else { return rm; } }); newRooms; => ["H1", "H2", "H4"] rooms; => ["H1", "H2", "H3"]
Persistent data structures for efficient immutability Mori, Immutable.js
Ready to try it out?
FP libraries for JS • Mori (http://swannodette.github.io/mori/) • Immutable.js (https://facebook.github.
io/immutable-js/) • Underscore (http://underscorejs.org/) • Lodash (https://lodash.com/) • Ramda (http://ramdajs.com/) • ...and more!
Want to learn more?
“An introduction to functional programming” by Mary Rose Cook https://codewords.recurse.com/issues/one/an-introduction-to-functional-programming
Thanks for listening! I’m @AnjanaVakil Huge thanks to: JSUnconf organizers
Diversity sponsors The Recurse Center & alums